annotate lisp/textmodes/reftex.el @ 20829:f9ac469887a8

(reftex-toc): Fixed bug with split-window. Using split-window instead of split-window-vertically. (reftex-reset-mode): Removed obsolete buffer from kill list. (reftex-make-and-insert-label-list, reftex-do-citation): Delete other windows before displaying selection. (reftex-cite-format-builtin): Fixed bug in Chicago format. (reftex-enlarge-to-fit): New function. (reftex-nicify-text): Cut context-string at \item,\\. Changed match sequence for efficiency reasons. (reftex-parse-from-file): Include files can be ignored with `reftex-no-include-regexps'. (reftex-no-include-regexps): New option. (reftex-do-parse): Initialize appendix flag. (reftex-parse-from-file): Interprete appendix. (reftex-section-info): Use changed version of reftex-section-number. (reftex-where-am-I): Interprete appendix match. (reftex-init-section-numbers): New arg: appendix. (reftex-section-number): Treat appendix enumeration. (reftex-toc-external): Improved message. (reftex-compute-ref-cite-tables): Regular expression extended for appendix. (reftex-toc-rescan): Renamed from reftex-toc-redo. (reftex-toc-Rescan): Renamed from reftex-toc-Redo. (reftex-toc-revert): New function. (reftex-select-external-document): Completion on label prefixes. (reftex-find-file-on-path): Added an extra call to expand-file-name for the directory. (reftex-locate-bibliography-files): Added expand-file-name call. (reftex-guess-label-type): New function. (reftex-word-before-point): Function removed. (reftex-reference): Uses reftex-guess-label-type. Changed meaning of `~' in reference format. Magic words are regular expressions. (reftex-compute-ref-cite-tables): Convert magic words to regexps. (reftex-select-label-maps): Default bindings for TAB, up, down, RET. (reftex-select-read-string): Now uses completion. (reftex-make-and-insert-label-list): Prepare for completion. (reftex-where-am-I): Fixed bug with input files. (reftex-save-all-document-buffers): New command. (reftex-select-next-heading): New function. (reftex-select-previous-heading): New function. (reftex-select-read-string): New function. (reftex-offer-label-menu): Handle string value from reftex-select-item. (reftex-reference): Fixed bug (missing save-excursion). (reftex-toc-map): Added binding for ?n and ?p. (reftex-do-citation): Changed to use reftex-default-bibliography. (reftex-default-bibliography): New option. (reftex-find-tex-file): Check for file-name-absolute-p first. (reftex-format-label-function,reftex-format-ref-function, reftex-format-cite-function): New hooks (reftex-info): New function. (reftex-compute-ref-cite-tables): Removed interactive form. (reftex-where-am-I): Removed interactive form (reftex-format-names): Removed interactive form (reftex-vref-is-default): New customization variable (reftex-mode-menu): Capitalize citation options (reftex-last-cnt): Variable removed. (reftex-last-data,reftex-last-line): New variables. (reftex-select-toggle-varioref): New function. (reftex-offer-label-menu): Changed mode-line-format for varioref. (reftex-select-label-help): Help string updated. (reftex-do-parse): Fixed bug with empty xr list. (reftex-view-crossref): Prefix argument interpretation changed. (reftex-get-offset): New function. (reftex-label): Remove selection buffer to force update. (reftex-access-scan-info): Remove selection buffers. (reftex-select-external-document): Fixed bug with highest index. (reftex-label-index-list, reftex-found-list): Variables removed. (reftex-offer-label-menu, reftex-make-and-insert-label-list) (reftex-select-item, reftex-citation, reftex-select-label-callback) (reftex-bibtex-selection-callback,reftex-select-callback): Changed to put the scan data directly into the text property :data, instead of doing this indirectly with an index-list. (reftex-make-selection-buffer-name): New function. (reftex-tie-multifile-symbols): Store master-index-as-property. (reftex-kill-buffer): New function. (reftex-erase-buffer): New function. (reftex-erase-all-selection-buffers): New function. (reftex-mode-menu): Button "Restore from file" no longer sensitive to existence of the file. This had caused problems for LateX style files. Quoted `:style' and `:selected' for compatibility. (reftex-access-parse-file): `Restore' action now throws an exception when the file is not found. (reftex-create-customize-menu): New function. (reftex-label): Fixed bug which made naked labels in \footnotes. (reftex-select-label-map, reftex-select-bib-map): New keymaps for the RefTeX Select buffer. (reftex-select-next, reftex-select-previous, reftex-select-scroll-down) (reftex-select-scroll-up, reftex-select-quit) (reftex-select-toggle-follow, reftex-select-callback) (reftex-select-accept, reftex-select-help) (reftex-select-recursive-edit, reftex-select-search-forward) (reftex-select-search-backward, reftex-select-search) (reftex-select-scroll-other-window) (reftex-select-scroll-other-window-down): New commands for use in the two new keymaps. (reftex-select-item): Now uses the appropriate keymaps. (reftex-toc-map): New keymap (a keymap for the toc buffer. (reftex-toc): Now uses reftex-toc-map. (reftex-fontify-select-label-buffer): New function (reftex-select-font-lock-fontify-region): New function. (reftex-make-and-insert-label-list): Refontification now uses `reftex-select-font-lock-fontify-region'. (reftex-show-entry): Refontification generalized. (reftex-select-search-minibuffer-map): New constant. (reftex-parse-from-file): Look for \begin{thebibliography} (reftex-do-citation): Check also for thebibliography (reftex-bibtex-selection-callback): Handle bibitem. (reftex-view-crossref): Handle bibitem. (reftex-extract-bib-entries-from-thebibliography): New function. (reftex-format-bibitem): New function. (reftex-parse-bibitem): New function. (reftex-make-desparate-section-regexp): Changed name to reftex-make-desperate-section-regexp. (reftex-do-parse, reftex-locate-bibliography-files) (reftex-string-to-label, reftex-select-external-document) (reftex-find-duplicate-labels, reftex-format-bib-entry) (reftex-do-citation, reftex-insert-bib-matches) (reftex-select-search-minibuffer-map, reftex-access-search-path) (reftex-compute-ref-cite-tables, reftex-recursive-directory-list): All lambda expressions now quoted with `function'. (reftex-view-crossref,reftex-mouse-view-crossref): Fixed bug with multiple calls. (reftex-get-buffer-visiting): Error message changed. (reftex-select-external-document, reftex-query-label-type) (reftex-do-citation, reftex-select-help): Use `reftex-enlarge-to-fit' now. (reftex-pop-to-bibtex-entry): No longer beep on failure, to make it work better with follow mode.
author Richard M. Stallman <rms@gnu.org>
date Tue, 03 Feb 1998 06:26:34 +0000
parents 6ebc3e300106
children f3f9df46d008
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
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
233 (subfigure "Subfigure environments/macro"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
234 (("subfigure" ?f nil nil caption)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
235 ("subfigure*" ?f nil nil caption)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
236 ("\\subfigure[]{}" ?f nil nil 1)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
237
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
238 (supertab "Supertabular environment"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
239 (("supertabular" ?t nil nil "\\tablecaption{")))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
240
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
241 (wrapfig "The wrapfigure environment"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
242 (("wrapfigure" ?f nil nil caption)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
243
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
244 ;; The LaTeX core stuff
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
245 (LaTeX "LaTeX default environments"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
246 (("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
247 (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
248 "Paragraphs?" "Par\\."
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
249 "\\\\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
250 "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
251
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
252 ("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
253 (regexp "Items?" "Punkte?"))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
254
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
255 ("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
256 (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
257 ("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
258
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
259 ("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
260 (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
261 ("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
262
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
263 ("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
264 (regexp "Tables?" "Tab\\." "Tabellen?"))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
265 ("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
266
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
267 ("\\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
268 (regexp "Footnotes?" "Notes?"))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
269
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
270 ("any" ?\ " " "~\\ref{%s}" nil)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
271
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
272 )
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
273 "The default label environment descriptions.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
274 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
275 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
276
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
277 (defconst reftex-cite-format-builtin
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
278 '(
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
279 (default "Default macro \\cite{%l}"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
280 "\\cite{%l}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
281 (natbib "The Natbib package"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
282 ((?\C-m . "\\cite{%l}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
283 (?t . "\\citet{%l}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
284 (?T . "\\citet*{%l}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
285 (?p . "\\citep{%l}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
286 (?P . "\\citep*{%l}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
287 (?e . "\\citep[e.g.][]{%l}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
288 (?a . "\\citeauthor{%l}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
289 (?y . "\\citeyear{%l}")))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
290 (harvard "The Harvard package"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
291 ((?\C-m . "\\cite{%l}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
292 (?p . "\\cite{%l}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
293 (?t . "\\citeasnoun{%l}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
294 (?n . "\\citeasnoun{%l}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
295 (?s . "\\possessivecite{%l}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
296 (?e . "\\citeaffixed{%l}{?}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
297 (?y . "\\citeyear{%l}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
298 (?a . "\\citename{%l}")))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
299 (chicago "The Chicago package"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
300 ((?\C-m . "\\cite{%l}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
301 (?t . "\\citeN{%l}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
302 (?T . "\\shortciteN{%l}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
303 (?p . "\\cite{%l}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
304 (?P . "\\shortcite{%l}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
305 (?a . "\\citeA{%l}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
306 (?A . "\\shortciteA{%l}")
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
307 (?y . "\\citeyear{%l}")))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
308 (astron "The Astron package"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
309 ((?\C-m . "\\cite{%l}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
310 (?p . "\\cite{%l}" )
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
311 (?t . "%2a (\\cite{%l})")))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
312 (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
313 ((?\C-m . "\\cite{%l}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
314 (?t . "%2a (%y)\\nocite{%l}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
315 (?p . "(%2a %y\\nocite{%l})")))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
316 (locally "Full info in parenthesis"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
317 "(%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
318 ;; 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
319 )
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
320 "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
321 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
322 `?\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
323 `?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
324 `?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
325 )
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
326
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
327 ;; Configuration Variables and User Options for RefTeX ------------------
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
328
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
329 (defgroup reftex nil
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
330 "LaTeX label and citation support."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
331 :tag "RefTeX"
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
332 :link '(url-link :tag "Home Page"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
333 "http://strw.leidenuniv.nl/~dominik/Tools/")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
334 :link '(emacs-commentary-link :tag "Commentary in reftex.el" "reftex.el")
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
335 :prefix "reftex-"
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
336 :group 'tex)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
337
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
338 (defun reftex-customize ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
339 "Call the customize function with reftex as argument."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
340 (interactive)
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
341 ;; 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
342 (cond
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
343 ((fboundp 'customize-browse)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
344 (customize-browse 'reftex))
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
345 ((fboundp 'customize-group)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
346 (customize-group 'reftex))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
347 ((fboundp 'customize)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
348 (customize 'reftex))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
349 (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
350
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
351 (defun reftex-create-customize-menu ()
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
352 "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
353 (interactive)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
354 (if (fboundp 'customize-menu-create)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
355 (progn
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
356 (easy-menu-change
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
357 '("Ref") "Customize"
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
358 `(["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
359 "---"
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
360 ,(customize-menu-create 'reftex)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
361 ["Set" Custom-set t]
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
362 ["Save" Custom-save t]
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
363 ["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
364 ["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
365 ["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
366 (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
367 (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
368
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
369 (defun reftex-show-commentary ()
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
370 "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
371 (interactive)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
372 (require 'finder)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
373 (finder-commentary "reftex.el"))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
374
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
375 (defun reftex-info ()
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
376 "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
377 (interactive)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
378 (require 'info)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
379 (Info-goto-node "(reftex)"))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
380
18123
7831ac89a334 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18050
diff changeset
381 ;; Support for \label and \ref --------------------------------------
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
382
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
383 (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
384 "Support for creation, insertion and referencing of labels in LaTeX."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
385 :group 'reftex)
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-defining-label-environments nil
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
388 "Definition of environments and macros to do with label."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
389 :group 'reftex-label-support)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
390
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
391 ;; 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
392 (eval-and-compile
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
393 (defconst reftex-tmp
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
394 '((const :tag "Default position" t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
395 (const :tag "After label" nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
396 (number :tag "Macro arg nr" 1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
397 (regexp :tag "Regexp" "")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
398 (const :tag "Caption in float" caption)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
399 (const :tag "Item in list" item)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
400 (const :tag "Eqnarray-like" eqnarray-like)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
401 (const :tag "Alignat-like" alignat-like)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
402 (symbol :tag "Function" my-func))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
403
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
404 (defcustom reftex-default-label-alist-entries
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
405 '(amsmath endnotes fancybox floatfig longtable picinpar
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
406 rotating subfigure supertab wrapfig LaTeX)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
407 "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
408 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
409 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
410
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
411 The options include:
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
412 LaTeX The standard LaTeX environments.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
413 Sideways The sidewaysfigure and sidewaystable environments.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
414 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
415
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
416 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
417
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
418 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
419 :group 'reftex-defining-label-environments
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
420 :set 'reftex-set-dirty
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
421 :type `(set
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
422 :indent 4
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
423 :inline t
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
424 :greedy t
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
425 ,@(mapcar
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
426 (function
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
427 (lambda (x)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
428 (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
429 ": " (nth 1 x))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
430 (nth 0 x))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
431 reftex-label-alist-builtin)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
432
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
433 (defcustom reftex-label-alist nil
18123
7831ac89a334 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18050
diff changeset
434 "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
435
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
436 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
437 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
438 `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
439
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
440 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
441 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
442 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
443 places in the code.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
444
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
445 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
446 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
447 one of its arguments. The elements of each list entry are:
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
448
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
449 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
450 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
451 \"\\\\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
452 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
453 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
454 its arguments.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
455 Special names: `section' for section labels, `any' to define a group
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
456 which contains all labels.
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
457 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
458 associated with the type indicator character (see below).
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
459
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
460 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
461 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
462 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
463 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
464 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
465 `equation' and `eqnarray').
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
466
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
467 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
468 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
469 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
470 %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
471 %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
472 %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
473
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
474 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
475
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
476 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
477 the label.
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
478 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
479 there is not already a whitespace before point.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
480
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
481 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
482 - 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
483 - If t, use
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
484 - 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
485 - 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
486 (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
487 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
488 - 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
489 - 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
490 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
491 - 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
492 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
493 \"\\\\\\\\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
494 environment.
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
495 \"\\\\\\\\begin{eqnarray}\\\\|\\\\\\\\\\\\\\\\\" works for eqnarrays.
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
496 - 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
497 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
498 (see also the variable `reftex-default-context-regexps').
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
499 - 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
500 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
501 function is expected to return a suitable context string. It should
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
502 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
503 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
504 the label macro as context:
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
505
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
506 (defun my-context-function (env-or-mac)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
507 (if (> (point-max) (+ 10 (point)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
508 (buffer-substring (point) (+ 10 (point)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
509 (error \"Buffer too small\")))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
510
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
511 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
512 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
513 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
514 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
515 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
516 actually used for section labels.
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
517
18220
36a61aa59b9d (tex-main-file, outline-minor-mode): Add defvars.
Richard M. Stallman <rms@gnu.org>
parents: 18219
diff changeset
518 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
519 overrides the setting here.
36a61aa59b9d (tex-main-file, outline-minor-mode): Add defvars.
Richard M. Stallman <rms@gnu.org>
parents: 18219
diff changeset
520
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
521 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
522 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
523 `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
524 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
525 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
526 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
527 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
528
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
529 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
530 will use
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
531 - the first non-nil format and prefix
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
532 - the magic words of all involved entries.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
533
18220
36a61aa59b9d (tex-main-file, outline-minor-mode): Add defvars.
Richard M. Stallman <rms@gnu.org>
parents: 18219
diff changeset
534 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
535 `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
536 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
537 `reftex-default-label-alist-entries."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
538 :group 'reftex-defining-label-environments
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
539 :set 'reftex-set-dirty
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
540 :type
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
541 `(repeat
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
542 (choice
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
543 :value ("" ?a nil nil nil nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
544 (list :tag "Detailed label alist entry"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
545 :value ("" ?a nil nil nil nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
546 (choice :tag "Environment or \\macro "
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
547 (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
548 (string ""))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
549 (character :tag "Typekey character " ?a)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
550 (choice :tag "Label prefix string "
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
551 (const :tag "Default" nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
552 (string :tag "String" "lab:"))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
553 (choice :tag "Label reference format"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
554 (const :tag "Default" nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
555 (string :tag "String" "~\\ref{%s}"))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
556 (choice :tag "Context"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
557 (choice
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
558 :tag "1 method"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
559 ,@reftex-tmp)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
560 (cons :tag "Split methods"
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 " Display context "
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 (choice
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
565 :tag " Derive label context"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
566 ,@reftex-tmp)))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
567 (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
568 (choice
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
569 :tag "Package"
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
570 :value AMSTeX
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
571 ,@(mapcar
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
572 (function
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
573 (lambda (x)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
574 (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
575 (nth 0 x))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
576 reftex-label-alist-builtin)))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
577
20177
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
578 ;; 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
579 (defcustom reftex-section-levels
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
580 '(
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
581 ("part" . 0)
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
582 ("chapter" . 1)
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
583 ("section" . 2)
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
584 ("subsection" . 3)
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
585 ("subsubsection" . 4)
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
586 ("paragraph" . 5)
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
587 ("subparagraph" . 6)
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
588 ("subsubparagraph" . 7)
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
589 )
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
590 "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
591 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
592 number indicating its level."
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
593 :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
594 :set 'reftex-set-dirty
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
595 :type '(repeat
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
596 (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
597 (number :tag "level " 0))))
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
598
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
599 (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
600 '((caption . "\\\\\\(rot\\)?caption\\*?[[{]")
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
601 (item . "\\\\item\\(\\[[^]]*\\]\\)?")
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
602 (eqnarray-like . "\\\\begin{%s}\\|\\\\\\\\")
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
603 (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
604 "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
605 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
606 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
607 or macro."
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
608 :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
609 :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
610
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
611 (defcustom reftex-use-text-after-label-as-context nil
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
612 "*t means, grab context from directly after the \\label{..} macro.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
613 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
614 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
615 precedence over the individual settings in `reftex-label-alist'.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
616 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
617 indicating the label types for which it should be true."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
618 :group 'reftex-defining-label-environments
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
619 :set 'reftex-set-dirty
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
620 :type '(choice
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
621 (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
622 (string :tag "Selected label types")))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
623
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
624 ;; Label insertion
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
625
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
626 (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
627 "Options on how to create new labels."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
628 :group 'reftex-label-support)
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 (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
631 "Flags governing label insertion. First flag DERIVE, second flag PROMPT.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
632
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
633 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
634 A section label for example will be derived from the section heading.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
635 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
636 specifications given in `reftex-derive-label-parameters'.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
637 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
638 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
639 unique number, like `eq:23'.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
640
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
641 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
642 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
643 context. When PROMPT is nil, the default label will be inserted without
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
644 query.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
645
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
646 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
647 table describing all four possibilities:
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
648
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
649 DERIVE PROMPT ACTION
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
650 -------------------------------------------------------------------------
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
651 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
652 nil t Prompt for label.
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
653 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
654 t t Derive a label from context and prompt for confirmation.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
655
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
656 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
657 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
658 like character classes.
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
659 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
660 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
661 (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
662 without confirmation for everything else.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
663 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
664 e (equation), n (footnote), plus any definitions in `reftex-label-alist'."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
665 :group 'reftex-making-and-inserting-labels
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
666 :type '(list (choice :tag "Derive label from context"
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
667 (const :tag "always" t)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
668 (const :tag "never" nil)
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
669 (string :tag "selected label types" ""))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
670 (choice :tag "Prompt for label string "
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
671 :entry-format " %b %v"
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
672 (const :tag "always" t)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
673 (const :tag "never" nil)
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
674 (string :tag "selected label types" ""))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
675
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
676 (defcustom reftex-derive-label-parameters '(3 20 t 1 "-"
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
677 ("the" "on" "in" "off" "a" "for" "by" "of" "and" "is"))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
678 "Parameters for converting a string into a label.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
679 NWORDS Number of words to use.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
680 MAXCHAR Maximum number of characters in a label string.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
681 ILLEGAL nil: Throw away any words containing characters illegal in labels.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
682 t: Throw away only the illegal characters, not the whole word.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
683 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
684 t: Always abbreviate words (see `reftex-abbrev-parameters').
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
685 not t and not nil: Abbreviate words if necessary to shorten
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
686 label string below MAXCHAR.
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
687 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
688 IGNOREWORDS List of words which should not be part of labels."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
689 :group 'reftex-making-and-inserting-labels
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
690 :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
691 (integer :tag "Maximum label length " 20)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
692 (choice :tag "Illegal characters in words"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
693 (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
694 (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
695 (choice :tag "Abbreviate words "
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
696 (const :tag "never" nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
697 (const :tag "always" t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
698 (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
699 (string :tag "Separator between words " "-")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
700 (repeat :tag "Ignore words"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
701 :entry-format " %i %d %v"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
702 (string :tag ""))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
703
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
704 (defcustom reftex-label-illegal-re "[\000-\040\177-\377\\\\#$%&~^_{}]"
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
705 "Regexp matching characters not legal in labels.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
706 For historic reasons, this character class comes *with* the [] brackets."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
707 :group 'reftex-making-and-inserting-labels
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
708 :type '(regexp :tag "Character class"))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
709
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
710 (defcustom reftex-abbrev-parameters '(4 2 "^saeiou" "aeiou")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
711 "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
712 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
713 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
714 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
715 AFTER Character class after abbrev point in word."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
716 :group 'reftex-making-and-inserting-labels
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
717 :type '(list
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
718 (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
719 (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
720 (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
721 (string :tag "cut after char class " "aeiou")))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
722
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
723 (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
724 "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
725 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
726 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
727 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
728 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
729 :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
730 :type 'function)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
731
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
732 ;; Label referencing
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
733
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
734 (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
735 "Options on how to reference labels."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
736 :group 'reftex-label-support)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
737
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
738 (eval-and-compile
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
739 (defconst reftex-tmp
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
740 '((const :tag "on" t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
741 (const :tag "off" nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
742 (string :tag "Selected label types"))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
743
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
744 (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
745 "List of flags governing the label menu makeup.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
746 The flags are:
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
747
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
748 TABLE-OF-CONTENTS Show the labels embedded in a table of context.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
749 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
750 COUNTERS Show counters. This just numbers the labels in the menu.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
751 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
752 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
753 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
754 MATCH-IN-TOC Searches in label menu will also match in toc lines.
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
755 SHOW FILES Show Begin and end of included files.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
756
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
757 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
758 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
759 like character classes in regular expressions. Thus, setting one of the
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
760 flags to \"sf\" makes the flag true for section and figure labels, nil
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
761 for everything else. Setting it to \"^ft\" 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
762 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
763 e (equation), n (footnote), plus any definitions in `reftex-label-alist'.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
764
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
765 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
766 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
767 get one interactively during selection from the label menu."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
768 :group 'reftex-referencing-labels
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
769 :type
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
770 `(list
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
771 (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
772 (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
773 (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
774 (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
775 (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
776 (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
777 (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
778 (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
779
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
780 (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
781 "*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
782 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
783 `\\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
784 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
785 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
786 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
787 :group 'reftex-referencing-labels
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
788 :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
789
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
790 (defcustom reftex-level-indent 2
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
791 "*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
792 :group 'reftex-referencing-labels
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
793 :type '(integer))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
794
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
795 (defcustom reftex-refontify-context 1
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
796 "*Non-nil means, re-fontify the context in the label menu with font-lock.
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
797 This slightly slows down the creation of the label menu. It is only necessary
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
798 when you definitely want the context fontified.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
799
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
800 This option may have 3 different values:
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
801 nil Never refontify.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
802 t Always refontify.
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
803 1 Refontify when absolutely necessary, e.g. when with the x-symbol package.
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
804 The option is ignored when `reftex-use-fonts' is nil."
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
805 :group 'reftex-referencing-labels
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
806 :type '(choice
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
807 (const :tag "Never" nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
808 (const :tag "Always" t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
809 (const :tag "When necessary" 1)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
810
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
811 (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
812 "*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
813 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
814 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
815 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
816 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
817 :group 'reftex-referencing-labels
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
818 :type '(boolean))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
819
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
820 (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
821 "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
822 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
823 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
824 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
825 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
826 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
827 :group 'reftex-referencing-labels
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
828 :type 'function)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
829
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
830 ;; BibteX citation configuration ----------------------------------------
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
831
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
832 (defgroup reftex-citation-support nil
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
833 "Support for referencing bibliographic data with BibTeX."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
834 :group 'reftex)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
835
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
836 (defcustom reftex-bibpath-environment-variables '("BIBINPUTS" "TEXBIB")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
837 "*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
838 :group 'reftex-citation-support
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
839 :set 'reftex-set-dirty
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
840 :type '(repeat (string :tag "Environment variable")))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
841
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
842 (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
843 "*List of files in \\bibliography{..} RefTeX should *not* parse.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
844 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
845 macro - i.e. without the `.bib' extension.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
846 Intended for files which contain only `@string' macro definitions and the
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
847 like, which are ignored by RefTeX anyway."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
848 :group 'reftex-citation-support
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
849 :set 'reftex-set-dirty
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
850 :type '(repeat (string :tag "File name")))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
851
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
852 (defcustom reftex-default-bibliography nil
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
853 "*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
854 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
855 `\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
856 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
857 `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
858 :group 'reftex-citation-support
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
859 :type '(repeat (file)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
860
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
861 (defcustom reftex-sort-bibtex-matches 'reverse-year
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
862 "*Sorting of the entries found in BibTeX databases by reftex-citation.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
863 Possible values:
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
864 nil Do not sort entries.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
865 'author Sort entries by author name.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
866 'year Sort entries by increasing year.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
867 'reverse-year Sort entries by decreasing year."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
868 :group 'reftex-citation-support
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
869 :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
870 (const :tag "by author" author)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
871 (const :tag "by year" year)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
872 (const :tag "by year, reversed" reverse-year)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
873
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
874 (defcustom reftex-cite-format 'default
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
875 "*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
876 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
877 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
878 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
879
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
880 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
881 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
882
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
883 %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
884 %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
885 %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
886 %A First author name only.
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
887 %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
888
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
889 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
890 %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
891 %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
892 %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
893 %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
894 %v volume %y year
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
895
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
896 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
897
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
898 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
899 citations are made from the \\bibitems in an explicit thebibliography
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
900 environment, only %l is available.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
901
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
902 If `reftex-cite-format' is an alist of characters and strings, the user
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
903 will be prompted for a character to select one of the possible format
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
904 strings.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
905 In order to configure this variable, you can either set
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
906 `reftex-cite-format' directly yourself or set it to the SYMBOL of one of
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
907 the predefined styles (see `reftex-cite-format-builtin'). E.g.:
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
908 (setq reftex-cite-format 'harvard)"
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
909 :group 'reftex-citation-support
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
910 :type
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
911 `(choice
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
912 :format "%{%t%}: \n%[Value Menu%] %v"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
913 (radio :tag "Symbolic Builtins"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
914 :indent 4
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
915 :value default
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
916 ,@(mapcar
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
917 (function
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
918 (lambda (x)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
919 (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
920 ": " (nth 1 x))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
921 (nth 0 x))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
922 reftex-cite-format-builtin))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
923 (string :tag "format string" "\\cite{%l}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
924 (repeat :tag "key-ed format strings"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
925 :value ((?\r . "\\cite{%l}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
926 (?t . "\\cite{%l}") (?p . "\\cite{%l}"))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
927 (cons (character :tag "Key character" ?\r)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
928 (string :tag "Format string" "")))))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
929
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
930 (defcustom reftex-comment-citations nil
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
931 "*Non-nil means add a comment for each citation describing the full entry.
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
932 The comment is formatted according to `reftex-cite-comment-format'."
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
933 :group 'reftex-citation-support
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
934 :type '(boolean))
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
935
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
936 (defcustom reftex-cite-comment-format
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
937 "%% %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
938 "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
939 :group 'reftex-citation-support
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
940 :type '(string))
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
941
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
942 (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
943 "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
944 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
945 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
946 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
947 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
948 :group 'reftex-citation-support
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
949 :type '(list
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
950 (string :tag "Separator for names ")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
951 (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
952 (string :tag "string used as et al. ")))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
953
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
954 (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
955 "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
956 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
957 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
958 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
959 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
960 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
961 :group 'reftex-citation-support
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
962 :type 'function)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
963 ;; Table of contents configuration --------------------------------------
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
964
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
965 (defgroup reftex-table-of-contents-browser nil
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
966 "A multifile table of contents browser."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
967 :group 'reftex)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
968
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
969 (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
970 "*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
971 The other window will show the corresponding part of the document.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
972 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
973 :group 'reftex-table-of-contents-browser
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
974 :type '(boolean))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
975
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
976 ;; Tuning the parser ----------------------------------------------------
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
977
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
978 (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
979 "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
980 :group 'reftex)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
981
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
982 (defcustom reftex-keep-temporary-buffers 1
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
983 "*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
984 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
985 We distinguish files visited for
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
986 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
987 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
988 to display label context, etc.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
989 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
990 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
991
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
992 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
993 t Keep everything.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
994 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
995 for lookup.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
996
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
997 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
998 slow but will happen only once).
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
999 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
1000 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
1001 :group 'reftex-miscellaneous-configurations
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1002 :type '(choice
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1003 (const :tag "Throw away everything" nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1004 (const :tag "Keep everything" t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1005 (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
1006
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1007 (defcustom reftex-initialize-temporary-buffers nil
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1008 "*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
1009 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
1010 visit a file.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1011 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
1012 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
1013 do a minimal initialization."
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1014 :group 'reftex-miscellaneous-configurations
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1015 :type '(choice
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1016 (const :tag "Read files literally" nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1017 (const :tag "Fully initialize buffers" t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1018 (repeat :tag "Hook functions" :value (nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1019 (function-item))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1020
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1021 (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
1022 "*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
1023 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
1024 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
1025 :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
1026 :type '(repeat (regexp)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1027
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1028 (defcustom reftex-enable-partial-scans nil
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1029 "*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
1030 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
1031 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
1032 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
1033 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
1034 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
1035 in menus."
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1036 :group 'reftex-optimizations-for-large-documents
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1037 :type 'boolean)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1038
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1039 (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
1040 "*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
1041 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
1042 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
1043 list."
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1044 :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
1045 :type 'boolean)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1046
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1047 (defcustom reftex-save-parse-info nil
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1048 "*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
1049 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
1050 information. When this variable is t,
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1051 - 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
1052 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
1053 - 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
1054 is written."
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1055 :group 'reftex-optimizations-for-large-documents
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1056 :type 'boolean)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1057
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1058 (defcustom reftex-use-multiple-selection-buffers nil
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1059 "*Non-nil means use a separate selection buffer for each label type.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1060 These buffers are kept from one selection to the next and need not to be
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1061 created for each use - so the menu generally comes up faster. The
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1062 selection buffers will be erased (and therefore updated) automatically
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1063 when new labels in its category are added. See the variable
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1064 `reftex-auto-update-selection-buffers'."
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1065 :group 'reftex-optimizations-for-large-documents
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
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1068 (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
1069 "*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
1070 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
1071 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
1072 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
1073 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
1074 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
1075 `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
1076 :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
1077 :type 'boolean)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1078
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1079 ;; Miscellaneous configurations -----------------------------------------
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1080
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1081 (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
1082 "Collection of further configurations."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1083 :group 'reftex)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1084
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1085 (defcustom reftex-extra-bindings nil
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1086 "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
1087 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
1088 :group 'reftex-miscellaneous-configurations
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1089 :type '(boolean))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1090
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1091 (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
1092 "*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
1093 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
1094 means:
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1095
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1096 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
1097 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
1098 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
1099 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
1100
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1101 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
1102 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
1103 \\<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
1104 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
1105 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
1106 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
1107 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
1108 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
1109 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
1110 :group 'reftex-miscellaneous-configurations
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1111 :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
1112 (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
1113 (list
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1114 :tag "Individual choice"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1115 :value (nil nil nil nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1116 (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
1117 (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
1118 (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
1119 (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
1120 )))
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1121
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1122 (defcustom reftex-use-fonts t
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1123 "*Non-nil means, use fonts in label menu and on-the-fly help.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1124 Font-lock must be loaded as well to actually get fontified display."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1125 :group 'reftex-miscellaneous-configurations
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1126 :type '(boolean))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1127
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1128 (defcustom reftex-auto-show-entry 'copy
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1129 "*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
1130 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
1131 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
1132 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
1133 context to a temporary buffer (value 'copy)."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1134 :group 'reftex-miscellaneous-configurations
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1135 :type '(radio :value copy
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1136 :indent 4
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1137 (const :tag "Do nothing" nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1138 (const :tag "Unhide section permanently" t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1139 (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
1140
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1141 (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
1142 "*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
1143 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
1144 :group 'reftex-miscellaneous-configurations
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1145 :type '(boolean))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1146
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1147 (defcustom reftex-load-hook nil
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1148 "Hook which is being run when loading reftex.el."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1149 :group 'reftex-miscellaneous-configurations
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1150 :type 'hook)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1151
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1152 (defcustom reftex-mode-hook nil
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1153 "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
1154 :group 'reftex-miscellaneous-configurations
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1155 :type 'hook)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1156
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1157 ;;; End of Configuration Section ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1158
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 ;;;
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1161 ;;; Define the formal stuff for a minor mode named RefTeX.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1162 ;;;
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1163
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1164 ;; This file corresponds to RefTeX version 3.17
20177
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
1165
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1166 (defvar reftex-mode nil
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1167 "Determines if RefTeX minor mode is active.")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1168 (make-variable-buffer-local 'reftex-mode)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1169
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1170 (defvar reftex-mode-map (make-sparse-keymap)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1171 "Keymap for RefTeX minor mode.")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1172
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1173 (defvar reftex-mode-menu nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1174
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1175 ;;;###autoload
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1176 (defun turn-on-reftex ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1177 "Turn on RefTeX minor mode."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1178 (reftex-mode t))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1179
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1180 ;;;###autoload
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1181 (defun reftex-mode (&optional arg)
18123
7831ac89a334 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18050
diff changeset
1182 "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
1183
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1184 Labels can be created with `\\[reftex-label]' and referenced with `\\[reftex-reference]'.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1185 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
1186 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
1187 \\ref macro.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1188
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1189 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
1190 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
1191 database. The selected citation is inserted as a \\cite macro.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1192
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1193 A Table of Contents of the entire (multifile) document with browsing
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1194 capabilities is available with `\\[reftex-toc]'.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1195
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1196 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
1197 pressing `?' to any prompt mentioning this feature.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1198
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1199 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
1200 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
1201
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1202 \\{reftex-mode-map}
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1203 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
1204 on the menu bar.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1205
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1206 ------------------------------------------------------------------------------"
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1207
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1208 (interactive "P")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1209 (setq reftex-mode (not (or (and (null arg) reftex-mode)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1210 (<= (prefix-numeric-value arg) 0))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1211
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1212 ; Add or remove the menu, and run the hook
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1213 (if reftex-mode
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1214 (progn
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1215 (easy-menu-add reftex-mode-menu)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1216 (reftex-plug-into-AUCTeX)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1217 (run-hooks 'reftex-mode-hook))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1218 (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
1219
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1220 (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
1221 (push '(reftex-mode " Ref") minor-mode-alist))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1222
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1223 (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
1224 (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
1225
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1226 ;;; ===========================================================================
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1227 ;;;
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1228 ;;; 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
1229 (defvar TeX-master)
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1230 (defvar LaTeX-label-function)
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1231 (defvar tex-main-file)
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1232 (defvar outline-minor-mode)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1233 (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
1234 (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
1235
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1236 ;;; ===========================================================================
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1237 ;;;
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1238 ;;; Interfaces for other packages
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1239 ;;; -----------------------------
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1240 ;;;
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1241 ;;; AUCTeX
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
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1244 (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
1245 "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
1246 This function is intended for AUCTeX macro support."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1247 (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
1248 (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
1249 (LaTeX-add-labels label))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1250 (TeX-argument-insert label optional optional)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1251
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1252 (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
1253 "Use `reftex-reference' to select label. Insert with `TeX-argument-insert'.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1254 This function is intended for AUCTeX macro support."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1255 (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
1256 (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
1257 (LaTeX-add-labels label))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1258 (TeX-argument-insert label optional optional)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1259
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1260 (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
1261 "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
1262 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
1263 (let ((key (reftex-citation t)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1264 (TeX-argument-insert (or key "") optional optional)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1265
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1266 (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
1267 ;; 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
1268 ;; 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
1269 ;; `reftex-plug-into-AUCTeX'.
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1270 (let ((flags
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1271 (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
1272 ((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
1273 (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
1274
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1275 (and (nth 0 flags)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1276 (boundp 'LaTeX-label-function)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1277 (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
1278
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1279 (and (nth 1 flags)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1280 (fboundp 'TeX-arg-label)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1281 (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
1282
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1283 (and (nth 2 flags)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1284 (fboundp 'TeX-arg-ref)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1285 (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
1286
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1287 (and (nth 3 flags)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1288 (fboundp 'TeX-arg-cite)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1289 (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
1290
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1291
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1292 (defvar reftex-label-alist-external-add-ons nil
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1293 "List of label alist entries added with reftex-add-to-label-alist.")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1294
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1295 (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
1296 "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
1297 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
1298 for details.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1299 This function makes it possible to support RefTeX from AUCTeX style files.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1300 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
1301 `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
1302 `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
1303 `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
1304 mode reset is done on the next occasion."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1305 (let (entry)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1306 (while entry-list
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1307 (setq entry (car entry-list)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1308 entry-list (cdr entry-list))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1309 (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
1310 (setq reftex-tables-dirty t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1311 (push entry reftex-label-alist-external-add-ons)))))
18050
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 ;;;
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1315 ;;; Multifile support
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1316 ;;;
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1317 ;;; Technical notes: Multifile works as follows: We keep just one list
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1318 ;;; 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
1319 ;;; `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
1320 ;;; 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
1321 ;;; document. Each buffer has local variables which point to these symbols.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1322
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1323 ;; List of variables which handle the multifile stuff.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1324 ;; This list is used to tie, untie, and reset these symbols.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1325 (defconst reftex-multifile-symbols
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1326 '(reftex-docstruct-symbol))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1327
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1328 ;; Alist connecting master file names with the corresponding lisp symbols.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1329 (defvar reftex-master-index-list nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1330
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1331 ;; Last index used for a master file.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1332 (defvar reftex-multifile-index 0)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1333
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1334 ;; 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
1335 (defvar reftex-docstruct-symbol nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1336 (make-variable-buffer-local 'reftex-docstruct-symbol)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1337
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1338 (defun reftex-next-multifile-index ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1339 ;; 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
1340 (incf reftex-multifile-index))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1341
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1342 (defun reftex-tie-multifile-symbols ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1343 ;; Tie the buffer-local symbols to globals connected with the master file.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1344 ;; 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
1345
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1346 (let* ((master (file-truename (reftex-TeX-master-file)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1347 (index (assoc master reftex-master-index-list))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1348 (symlist reftex-multifile-symbols)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1349 (symbol nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1350 (symname nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1351 (newflag nil))
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1352 ;; Find the correct index.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1353 (if index
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1354 ;; symbols do exist
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1355 (setq index (cdr index))
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1356 ;; Get a new index and add info to the alist.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1357 (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
1358 newflag t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1359 (push (cons master index) reftex-master-index-list))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1360
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1361 ;; Get/create symbols and tie them.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1362 (while symlist
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1363 (setq symbol (car symlist)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1364 symlist (cdr symlist)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1365 symname (symbol-name symbol))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1366 (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
1367 (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
1368 ;; Initialize if new symbols.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1369 (if newflag (set (symbol-value symbol) nil)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1370
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1371 ;; 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
1372 (not newflag)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1373
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1374 (defun reftex-untie-multifile-symbols ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1375 ;; Remove ties from multifile symbols, so that next use makes new ones.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1376 (let ((symlist reftex-multifile-symbols)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1377 (symbol nil))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1378 (while symlist
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1379 (setq symbol (car symlist)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1380 symlist (cdr symlist))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1381 (set symbol nil))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1382
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1383 (defun reftex-TeX-master-file ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1384 ;; Return the name of the master file associated with the current buffer.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1385 ;; 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
1386 ;; 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
1387 ;; variable tex-main-file.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1388 (let
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1389 ((master
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1390 (cond
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1391 ((fboundp 'TeX-master-file) ; AUCTeX is loaded. Use its mechanism.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1392 (TeX-master-file t))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1393 ((boundp 'TeX-master) ; The variable is defined - lets use it.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1394 (cond
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1395 ((eq TeX-master t)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1396 (buffer-file-name))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1397 ((eq TeX-master 'shared)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1398 (setq TeX-master (read-file-name "Master file: "
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1399 nil nil t nil)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1400 (TeX-master)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1401 (t
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1402 (setq TeX-master (read-file-name "Master file: "
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1403 nil nil t nil)))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1404 ((boundp 'tex-main-file)
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1405 ;; This is the variable from the default TeX modes.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1406 (cond
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1407 ((stringp tex-main-file)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1408 ;; ok, this must be it
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1409 tex-main-file)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1410 (t
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1411 ;; In this case, the buffer is its own master.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1412 (buffer-file-name))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1413 (t
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1414 ;; Know nothing about master file. Assume this is a master file.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1415 (buffer-file-name)))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1416 (cond
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1417 ((null master)
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1418 (error "Need a filename for this buffer. Please save it first."))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1419 ((or (file-exists-p master)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1420 (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
1421 ;; 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
1422 )
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1423 ((or (file-exists-p (concat master ".tex"))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1424 (reftex-get-buffer-visiting (concat master ".tex")))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1425 ;; Ahh, an extra .tex was missing...
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1426 (setq master (concat master ".tex")))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1427 (t
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1428 ;; 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
1429 (buffer-file-name)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1430 ; (error "No such master file %s" master)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1431 (expand-file-name master)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1432
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1433 (defun reftex-parse-one ()
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1434 "Re-parse this file."
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1435 (interactive)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1436 (let ((reftex-enable-partial-scans t))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1437 (reftex-access-scan-info '(4))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1438
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1439 (defun reftex-parse-all ()
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1440 "Re-parse entire document."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1441 (interactive)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1442 (reftex-access-scan-info '(16)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1443
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1444 (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
1445 ;; 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
1446 ;; 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
1447 ;; of master file.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1448 (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
1449 (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
1450 (re (concat "\\`" (regexp-quote master-dir)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1451 file-list tmp file)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1452 (while (setq tmp (assoc 'bof all))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1453 (setq file (nth 1 tmp)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1454 all (cdr (memq tmp all)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1455 (and relative
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1456 (string-match re file)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1457 (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
1458 (push file file-list))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1459 (nreverse file-list)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1460
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1461 (defun reftex-create-tags-file ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1462 "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
1463 The TAGS file is also immediately visited with `visit-tags-table'."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1464 (interactive)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1465 (reftex-access-scan-info current-prefix-arg)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1466 (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
1467 (files (reftex-all-document-files))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1468 (cmd (format "etags %s" (mapconcat 'identity files " "))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1469 (save-excursion
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1470 (set-buffer (reftex-get-buffer-visiting master))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1471 (message "Running etags to create TAGS file...")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1472 (shell-command cmd)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1473 (visit-tags-table "TAGS"))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1474
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1475 ;; History of grep commands.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1476 (defvar reftex-grep-history nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1477 (defvar reftex-grep-command "grep -n "
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1478 "Last grep command used in \\[reftex-grep-document]; default for next grep.")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1479
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1480 (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
1481 "Run grep query through all files related to this document.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1482 With prefix arg, force to rescan document.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1483 This works also without an active TAGS table."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1484
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1485 (interactive
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1486 (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
1487 reftex-grep-command nil nil
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1488 'reftex-grep-history)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1489 (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
1490 (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
1491 (cmd (format
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1492 "%s %s" grep-cmd
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1493 (mapconcat 'identity files " "))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1494 (grep cmd)))
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 (defun reftex-search-document (&optional regexp)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1497 "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
1498 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
1499 To continue searching for next match, use command \\[tags-loop-continue].
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1500 This works also without an active TAGS table."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1501 (interactive)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1502 (let ((default (reftex-this-word)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1503 (unless regexp
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1504 (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
1505 default))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1506 (if (string= regexp "") (setq regexp (regexp-quote default)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1507
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1508 (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
1509 (tags-search regexp (list 'reftex-all-document-files))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1510
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1511 (defun reftex-query-replace-document (&optional from to delimited)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1512 "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
1513 Third arg DELIMITED (prefix arg) means replace only word-delimited matches.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1514 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
1515 with the command \\[tags-loop-continue].
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1516 This works also without an active TAGS table."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1517 (interactive)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1518 (let ((default (reftex-this-word)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1519 (unless from
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1520 (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
1521 default)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1522 (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
1523 (unless to
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1524 (setq to (read-string (format "Replace regexp %s with: " from))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1525 (reftex-access-scan-info current-prefix-arg)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1526 (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
1527 (list 'reftex-all-document-files))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1528
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1529 (defun reftex-change-label (&optional from to)
18123
7831ac89a334 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18050
diff changeset
1530 "Query replace FROM with TO in all \\label and \\ref commands.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1531 Works on the entire multifile document.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1532 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
1533 with the command \\[tags-loop-continue].
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1534 This works also without an active TAGS table."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1535 (interactive)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1536 (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
1537 (unless from
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1538 (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
1539 default))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1540 (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
1541 (unless to
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1542 (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
1543 from))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1544 (reftex-query-replace-document
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1545 (concat "\\\\\\(label\\|[a-z]*ref\\){" (regexp-quote from) "}")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1546 (format "\\\\\\1{%s}" to))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1547
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1548 (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
1549 "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
1550 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
1551 labels."
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1552 (interactive)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1553 (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
1554 file buffer)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1555 (save-excursion
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1556 (while (setq file (pop files))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1557 (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
1558 (when buffer
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1559 (set-buffer buffer)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1560 (save-buffer))))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1561
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1562 ;;; ===========================================================================
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1563 ;;;
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1564 ;;; 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
1565
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1566 ;; 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
1567
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1568 ;; Prompt used for label type queries directed to the user.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1569 (defconst reftex-type-query-prompt nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1570
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1571 ;; Help string for label type queries.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1572 (defconst reftex-type-query-help nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1573
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1574 ;; Alist relating label type to reference format.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1575 (defconst reftex-typekey-to-format-alist nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1576
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1577 ;; Alist relating label type to label affix.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1578 (defconst reftex-typekey-to-prefix-alist nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1579
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1580 ;; Alist relating environments or macros to label type and context regexp.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1581 (defconst reftex-env-or-mac-alist nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1582
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1583 ;; List of macros carrying a label.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1584 (defconst reftex-label-mac-list nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1585
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1586 ;; List of environments carrying a label.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1587 (defconst reftex-label-env-list nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1588
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1589 ;; List of all typekey letters in use.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1590 (defconst reftex-typekey-list nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1591
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1592 ;; Alist relating magic words to a label type.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1593 (defconst reftex-words-to-typekey-alist nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1594
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1595 ;; The last list-of-labels entry used in a reference.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1596 (defvar reftex-last-used-reference (list nil nil nil nil))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1597
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1598 ;; The regular expression used to abbreviate words.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1599 (defconst reftex-abbrev-regexp
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1600 (concat
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1601 "\\`\\("
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1602 (make-string (nth 0 reftex-abbrev-parameters) ?.)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1603 "[" (nth 2 reftex-abbrev-parameters) "]*"
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1604 "\\)"
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1605 "[" (nth 3 reftex-abbrev-parameters) "]"
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1606 (make-string (1- (nth 1 reftex-abbrev-parameters)) ?.)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1607
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1608 ;; Global variables used for communication between functions.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1609 (defvar reftex-default-context-position nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1610 (defvar reftex-location-start nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1611 (defvar reftex-call-back-to-this-buffer nil)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1612 (defvar reftex-active-toc nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1613 (defvar reftex-tex-path nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1614 (defvar reftex-bib-path nil)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1615 (defvar reftex-prefix)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1616
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1617 ;; List of buffers created temporarily for lookup, which should be killed.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1618 (defvar reftex-buffers-to-kill nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1619
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
1620 ;; 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
1621 (defvar reftex-section-regexp nil)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1622 (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
1623 (defvar reftex-everything-regexp nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1624 (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
1625 (defvar reftex-find-label-regexp-format2 nil)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1626
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1627 ;; The parser functions ----------------------------------
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1628
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1629 (defvar reftex-memory nil
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1630 "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
1631
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1632 (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
1633 ;; 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
1634 ;; 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
1635 ;; 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
1636
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1637 ;; 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
1638 (when (or reftex-tables-dirty
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1639 (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
1640 (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
1641 (nth 1 reftex-memory)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1642 (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
1643 (nth 2 reftex-memory))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1644 (reftex-reset-mode))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1645
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1646 (if (eq reftex-docstruct-symbol nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1647 ;; 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
1648 (reftex-tie-multifile-symbols))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1649
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1650 (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
1651 (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
1652 ;; 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
1653 (save-excursion
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1654 (reftex-erase-all-selection-buffers)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1655
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1656 (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
1657 reftex-save-parse-info)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1658 ;; 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
1659 (reftex-access-parse-file 'read))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1660
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1661 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1662 ((not (symbol-value reftex-docstruct-symbol))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1663 (reftex-do-parse 1 file))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1664 ((member rescan '(t 1 (4) (16)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1665 (reftex-do-parse rescan file))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1666
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1667 (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
1668 ;; 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
1669
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1670 ;; Normalize the rescan argument
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1671 (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
1672 ((eq rescan 1) 1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1673 ((equal rescan '(4)) t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1674 ((equal rescan '(16)) 1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1675 (t 1)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1676
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1677 ;; Partial scans only when allowed
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1678 (unless reftex-enable-partial-scans
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1679 (setq rescan 1))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1680
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1681 ;; Do the scanning.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1682
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1683 (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
1684 (master (reftex-TeX-master-file))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1685 (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
1686 (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
1687 from-file appendix docstruct tmp)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1688
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1689 ;; 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
1690 (when (and (eq rescan t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1691 (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
1692 (member (list 'eof file) old-list))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1693 (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
1694 (setq rescan 1))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1695 (when (string= file master)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1696 (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
1697 (setq rescan 1))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1698
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1699 ;; From which file do we start?
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1700 (setq from-file
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1701 (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
1702 ((eq rescan 1) master)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1703 (t (error "horrible!!"))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1704
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1705 ;; 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
1706 (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
1707 '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
1708 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
1709 '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
1710
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1711 (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
1712
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1713 (if (eq rescan 1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1714 (message "Scanning entire document...")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1715 (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
1716
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1717 (save-window-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1718 (save-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1719 (unwind-protect
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1720 (setq docstruct
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1721 (reftex-parse-from-file
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1722 from-file docstruct master-dir))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1723 (reftex-kill-temporary-buffers))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1724
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1725 (message "Scanning document... done")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1726
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1727 ;; Turn the list around.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1728 (setq docstruct (nreverse docstruct))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1729
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1730 ;; Set or insert
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1731 (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
1732 old-list docstruct (eq rescan 1)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1733
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1734 ;; Add all missing information
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1735 (unless (assq 'label-numbers docstruct)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1736 (push (cons 'label-numbers nil) docstruct))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1737 (unless (assq 'master-dir docstruct)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1738 (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
1739 (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
1740 (bof2 (assq 'bof (cdr bof1)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1741 (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
1742 (entry (or (assq 'is-multi docstruct)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1743 (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
1744 (setcdr entry (cons is-multi nil)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1745 (unless (assq 'xr docstruct)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1746 (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
1747 (alist (mapcar
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1748 (function
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1749 (lambda (x)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1750 (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
1751 master-dir))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1752 (cons (nth 1 x) tmp)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1753 (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
1754 (nth 2 x))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1755 nil)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1756 allxr))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1757 (alist (delete nil alist))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1758 (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
1759 (regexp (if allprefix
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1760 (concat "\\`\\("
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1761 (mapconcat 'identity allprefix "\\|")
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1762 "\\)")
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1763 "\\\\\\\\\\\\"))) ; this will never match
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1764 (push (list 'xr alist regexp) docstruct)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1765
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1766 (set reftex-docstruct-symbol docstruct)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1767
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1768 ;; 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
1769 (if reftex-save-parse-info
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1770 (reftex-access-parse-file 'write))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1771
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1772 (defun reftex-is-multi ()
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1773 ;; 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
1774 (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
1775 (if entry
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1776 (nth 1 entry)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1777 t)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1778
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1779 (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
1780 ;; 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
1781 (let ((regexp reftex-everything-regexp)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1782 (bound 0)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1783 file-found tmp include-file
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1784 (level 1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1785 (highest-level 100)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1786 toc-entry next-buf)
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 (catch 'exit
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1789 (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
1790 (unless file-found
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1791 (push (list 'file-error file) docstruct)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1792 (throw 'exit nil))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1793
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1794 (save-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1795
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1796 (message "Scanning file %s" file)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1797 (set-buffer
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1798 (setq next-buf
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1799 (reftex-get-file-buffer-force
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1800 file-found
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1801 (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
1802
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1803 ;; Begin of file mark
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1804 (setq file (buffer-file-name))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1805 (push (list 'bof file) docstruct)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1806
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1807 (save-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1808 (save-restriction
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1809 (widen)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1810 (goto-char 1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1811
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1812 (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
1813
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1814 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1815
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1816 ((match-end 1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1817 ;; It is a label
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1818 (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
1819 docstruct))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1820
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1821 ((match-end 3)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1822 ;; It is a section
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1823 (setq bound (point))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1824
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1825 ;; Insert in List
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1826 (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
1827 (setq level (nth 5 toc-entry))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1828 (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
1829 (if (= level highest-level)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1830 (message
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1831 "Scanning %s %s ..."
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1832 (car (nth level reftex-section-levels))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1833 (nth 6 toc-entry)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1834
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1835 (push toc-entry docstruct)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1836 (setq reftex-active-toc toc-entry))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1837
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1838 ((match-end 7)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1839 ;; 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
1840 (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
1841 (if (delq nil (mapcar
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1842 (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
1843 reftex-no-include-regexps))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1844 (progn
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1845 ;; Ignore the file
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1846 (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
1847 (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
1848 ;; Parse it
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1849 (setq docstruct
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1850 (reftex-parse-from-file
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1851 include-file
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1852 docstruct master-dir))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1853
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1854 ((match-end 9)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1855 ;; Appendix starts here
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1856 (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
1857 (push (cons 'appendix t) docstruct))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1858
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1859 ((match-end 10)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1860 ;; A macro with label
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1861 (save-excursion
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1862 (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
1863 (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
1864 (save-match-data
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1865 (reftex-no-props
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1866 (reftex-nth-arg-wrapper
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1867 mac)))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1868 (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
1869 (reftex-label-info
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1870 label file bound mac))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1871 (push entry docstruct))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1872 (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
1873 )
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1874
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1875
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1876 ;; Find bibliography statement
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1877 (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
1878 (push (cons 'bib tmp) docstruct))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1879
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1880 (goto-char 1)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1881 (when (re-search-forward
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1882 "\\(\\`\\|[\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
1883 (push (cons 'thebib file) docstruct))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1884
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1885 ;; Find external document specifications
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1886 (goto-char 1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1887 (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
1888 (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
1889 (reftex-match-string 3))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1890 docstruct))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1891
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1892 ;; End of file mark
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1893 (push (list 'eof file) docstruct))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1894
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1895 ;; Kill the scanned buffer
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1896 (reftex-kill-temporary-buffers next-buf))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1897
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1898 ;; Return the list
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1899 docstruct))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1900
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1901 (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
1902 ;; 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
1903 (let (file-list)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1904 (save-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1905 (goto-char (point-min))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1906 (if (re-search-forward
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1907 "\\(\\`\\|[\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
1908 (setq file-list
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1909 (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
1910 (reftex-delete-list
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1911 reftex-bibfile-ignore-list
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1912 (split-string
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1913 (reftex-match-string 2)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1914 "[ \t\n\r]*,[ \t\n\r]*")))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1915 (delete nil
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1916 (mapcar
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1917 (function
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1918 (lambda (file)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1919 (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
1920 file-list)))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1921
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1922 (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
1923 ;; 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
1924 ;; 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
1925 ;; 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
1926 ;; On success, returns the association.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1927 (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
1928
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1929 (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
1930 (setq list (memq ass list))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1931 (memq elt list))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1932 (setq last-ass ass
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1933 list (cdr list)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1934 last-ass))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1935
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1936 (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
1937 ;; 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
1938 ;; 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
1939 ;; 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
1940 ;; 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
1941
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1942 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1943 (entirely
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1944 (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
1945 insert)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1946 (t (let* ((new old)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1947 (file (nth 1 (car insert)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1948 (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
1949 (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
1950 n)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1951 (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
1952 (error "Cannot splice")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1953 ;; Splice
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1954 (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
1955 (length eof-list)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1956 (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
1957 (setcdr (nthcdr n new) (cdr insert))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1958 (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
1959 new))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1960
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1961 (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
1962 ;; 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
1963 (while (and list (> (decf n) -1))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1964 (and (eq (car (car list)) 'toc)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1965 (markerp (nth 4 (car list)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1966 (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
1967 (pop list)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1968
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1969 (defun reftex-access-parse-file (action)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1970 (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
1971 (master (reftex-TeX-master-file))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1972 (enable-local-variables nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1973 (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
1974 (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
1975 (concat master ".rel"))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1976 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1977 ((eq action 'readable)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1978 (file-readable-p file))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1979 ((eq action 'restore)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1980 (if (eq reftex-docstruct-symbol nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1981 ;; 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
1982 (reftex-tie-multifile-symbols))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1983 (if (file-exists-p file)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1984 ;; 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
1985 (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
1986 ;; throw an exception
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1987 (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
1988 ((eq action 'read)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1989 (if (file-exists-p file)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1990 ;; 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
1991 (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
1992 ;; 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
1993 nil))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1994 (t
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1995 (save-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1996 (if (file-writable-p file)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1997 (progn
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1998 (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
1999 (find-file file)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2000 (erase-buffer)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2001 (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
2002 (insert (format ";; File: %s\n" master))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2003 (insert (format ";; Date: %s\n"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2004 (format-time-string "%D %T"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2005 (current-time))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2006 (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
2007 (user-login-name) (user-full-name)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2008 (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
2009 (let ((standard-output (current-buffer)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2010 (mapcar
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2011 (function
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2012 (lambda (x)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2013 (cond ((eq (car x) 'toc)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2014 ;; 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
2015 ;; 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
2016 (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
2017 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
2018 (or (and (markerp (nth 4 x))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2019 (marker-position (nth 4 x)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2020 (nth 8 x)))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2021 (t (print x)))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2022 list))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2023 (insert "))")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2024 (save-buffer 0)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2025 (kill-buffer (current-buffer)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2026 (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
2027 t))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2028
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2029 ;; Creating labels --------------
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2030
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2031 (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
2032 "Insert a unique label. Return the label.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2033 If ENVIRONMENT is given, don't bother to find out yourself.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2034 If NO-INSERT is non-nil, do not insert label into buffer.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2035 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
2036 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
2037 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
2038 A new label is also recorded into the label list.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2039 This function is controlled by the settings of reftex-insert-label-flags."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2040
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2041 (interactive)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2042
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
2043 ;; 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
2044 (reftex-access-scan-info current-prefix-arg)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2045
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
2046 ;; 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
2047 (if (or (not environment)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2048 (not (assoc environment reftex-env-or-mac-alist)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2049 (setq environment (reftex-label-location)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2050 (unless environment
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2051 (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
2052
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
2053 ;; Ok, go ahead.
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2054 (catch 'exit
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2055 (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
2056 (typekey (nth 1 entry))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2057 (format (nth 3 entry))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2058 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
2059 (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
2060 (nth 5 entry)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2061 (memq (preceding-char) '(?\[ ?\{)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2062 (setq format "%s"))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2063
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2064 (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
2065 (concat typekey "-")))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2066 ;; 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
2067 (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
2068
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2069 ;; Make a default label.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2070 (cond
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2071
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2072 ((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
2073 ;; Derive a label from context.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2074 (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
2075 '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
2076 (symbol-value reftex-docstruct-symbol)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2077 (setq default (reftex-no-props
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2078 (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
2079 ;; 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
2080 (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
2081 (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
2082 (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
2083 (string-match "HOOK ERROR" default)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2084 (string-match "^[ \t]*$" default))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2085 (setq default prefix
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2086 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
2087 (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
2088
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2089 ;; Make it unique.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2090 (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
2091
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2092 ((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
2093 ;; 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
2094 (setq default prefix))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2095
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2096 (t
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2097 ;; Make an automatic label.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2098 (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
2099
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2100 ;; Should we ask the user?
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2101 (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
2102 (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
2103 force-prompt)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2104
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2105 (while (not valid)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2106 ;; 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
2107
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2108 (setq label (read-string
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2109 (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
2110 default))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2111
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2112 ;; 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
2113 (cond
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2114
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2115 ((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
2116 "\\)?[ \t]*\\'")
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2117 label)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2118 ;; No label at all, please
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2119 (message "No label inserted.")
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2120 (throw 'exit nil))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2121
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2122 ;; 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
2123 ((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
2124 (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
2125 (ding)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2126 (sit-for 2))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2127
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2128 ;; 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
2129 ((setq entry (assoc label
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2130 (symbol-value reftex-docstruct-symbol)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2131 (ding)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2132 (if (y-or-n-p
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2133 (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
2134 (setq valid t)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2135
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2136 ;; Label is ok
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2137 (t
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2138 (setq valid t))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2139 (setq label default))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2140
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2141 ;; 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
2142 (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
2143 (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
2144 (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
2145 ""
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2146 "POSITION UNCERTAIN. RESCAN TO FIX."))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2147 (file (buffer-file-name))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2148 (text nil)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2149 (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
2150
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2151 (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
2152
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2153 (if tail
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2154 (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
2155 (cdr tail)))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2156
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2157 ;; 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
2158 (unless no-insert
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2159 (insert
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2160 (if reftex-format-label-function
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2161 (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
2162 (format format label))))
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 ;; 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
2165 (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
2166 (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
2167 (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
2168
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2169 (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
2170 (reftex-parse-one))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2171
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2172 ;; 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
2173 label)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2174
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2175 (defun reftex-string-to-label (string)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2176 ;; Convert a string (a sentence) to a label.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2177 ;;
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2178 ;; Uses reftex-derive-label-parameters and reftex-abbrev-parameters
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2179 ;;
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2180
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2181 (let* ((words0 (split-string string "[- \t\n\r]+"))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2182 (ignore-words (nth 5 reftex-derive-label-parameters))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2183 words word)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2184
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2185 ;; 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
2186 (while (setq word (pop words0))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2187 (cond
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2188 ((member (downcase word) ignore-words))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2189 ((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
2190 (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
2191 (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
2192 (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
2193 (push word words)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2194 (t
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2195 (push word words))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2196 (setq words (nreverse words))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2197
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2198 ;; restrict number of words
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2199 (if (> (length words) (nth 0 reftex-derive-label-parameters))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2200 (setcdr (nthcdr (1- (nth 0 reftex-derive-label-parameters)) words) nil))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2201
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2202 ;; 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
2203 (setq string (mapconcat 'identity words
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2204 (nth 4 reftex-derive-label-parameters)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2205
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2206 ;; Abbreviate words if enforced by user settings or string length
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2207 (if (or (eq t (nth 3 reftex-derive-label-parameters))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2208 (and (nth 3 reftex-derive-label-parameters)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2209 (> (length string) (nth 1 reftex-derive-label-parameters))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2210 (setq words
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2211 (mapcar
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2212 (function
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2213 (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
2214 (match-string 1 w)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2215 w)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2216 words)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2217 string (mapconcat 'identity words
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2218 (nth 4 reftex-derive-label-parameters))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2219
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2220 ;; Shorten if still to long
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2221 (setq string
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2222 (if (> (length string) (nth 1 reftex-derive-label-parameters))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2223 (substring string 0 (nth 1 reftex-derive-label-parameters))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2224 string))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2225
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2226 ;; 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
2227 (if (string-match "[^a-zA-Z0-9]+\\'" string)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2228 (setq string (replace-match "" nil nil string)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2229 string))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2230
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2231 (defun reftex-replace-prefix-escapes (prefix)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2232 ;; Replace %escapes in a label prefix
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2233 (save-match-data
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2234 (let (letter (num 0) replace)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2235 (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
2236 (setq letter (match-string 1 prefix))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2237 (setq replace
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2238 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2239 ((equal letter "f")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2240 (file-name-sans-extension
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2241 (file-name-nondirectory (buffer-file-name))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2242 ((equal letter "F")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2243 (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
2244 (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
2245 (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
2246 file)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2247 (substring file (length masterdir))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2248 file)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2249 ((equal letter "u")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2250 (or (user-login-name) ""))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2251 (t "")))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2252 (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
2253 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
2254 prefix)))
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2255
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2256 (defun reftex-label-location (&optional bound)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2257 ;; Return the environment or macro which determines the label type at point.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2258 ;; If optional BOUND is an integer, limit backward searches to that point.
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 (let* ((loc1 (reftex-what-macro reftex-label-mac-list bound))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2261 (loc2 (reftex-what-environment reftex-label-env-list bound))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2262 (p1 (or (cdr loc1) 0))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2263 (p2 (or (cdr loc2) 0)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2264
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2265 (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
2266 (if (>= p1 p2)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2267 (progn
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2268 (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
2269 (or (car loc1) "section"))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2270 (setq reftex-default-context-position (+ p2 8 (length (car loc2))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2271 (or (car loc2) "section"))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2272
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2273 (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
2274 ;; 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
2275 ;; 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
2276 ;; Optional SEPARATOR is a string to stick between label and number.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2277
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2278 ;; Ensure access to scanning info
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2279 (reftex-access-scan-info)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2280
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2281 (cond
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2282 ((and (not force)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2283 (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
2284 label)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2285 (t
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2286 (let* ((label-numbers (assq 'label-numbers
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2287 (symbol-value reftex-docstruct-symbol)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2288 (label-numbers-alist (cdr label-numbers))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2289 (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
2290 (car (setcdr label-numbers
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2291 (cons (cons label 0)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2292 label-numbers-alist)))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2293 (num (1+ (cdr cell)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2294 (sep (or separator "")))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2295 (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
2296 (symbol-value reftex-docstruct-symbol))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2297 (incf num))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2298 (setcdr cell num)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2299 (concat label sep (int-to-string num))))))
18050
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 ;; 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
2302 (defconst reftex-select-label-prompt
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2303 "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
2304
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2305 (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
2306 " 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
2307 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
2308 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
2309 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
2310 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
2311 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
2312 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
2313 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
2314 [#] 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
2315 SPC / f Show full context in other window / Toggle follow mode
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2316 v / e Toggle \\ref <-> \\vref / Recursive Edit into other window
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2317 TAB Enter a label with completion
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2318 q / RET Quit without accepting label / Accept current label")
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2319
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2320 (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
2321 "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
2322 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
2323 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
2324
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2325 (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
2326 "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
2327 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
2328 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
2329 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
2330 label selection menu.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2331 The function returns the selected label or nil.
18123
7831ac89a334 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18050
diff changeset
2332 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
2333 When called with 2 C-u prefix args, disable magic word recognition."
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 (interactive)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2336
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2337 ;; check for active recursive edits
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2338 (reftex-check-recursive-edit)
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 ;; 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
2341 (reftex-access-scan-info current-prefix-arg)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2342
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2343 (unless type
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2344 ;; guess type from context
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2345 (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
2346 (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
2347 (setq cut (cdr type)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2348 type (car type))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2349 (setq type (reftex-query-label-type))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2350
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2351 (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
2352 type reftex-vref-is-default)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2353 "\\vref" "\\ref"))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2354 (form "\\ref{%s}")
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2355 label pair)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2356
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2357 ;; Have the user select a label
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2358 (setq pair (save-excursion
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2359 (reftex-offer-label-menu type)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2360 (setq label (car pair)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2361 type (cdr pair)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2362 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
2363 form))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2364
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2365 (if (and label
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2366 (not no-insert))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2367 (progn
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2368 (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
2369
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2370 ;; 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
2371 (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
2372 (= ?\ (preceding-char)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2373 (setq form (substring form 1)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2374 ;; 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
2375 (when (string= varioref "\\vref")
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2376 (while (string-match "\\\\ref{" form)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2377 (setq form (replace-match "\\vref{" t t form))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2378 ;; ok, insert the reference
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2379 (insert
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2380 (if reftex-format-ref-function
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2381 (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
2382 (format form label label)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2383 (message ""))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2384 (message "Quit"))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2385 ;; return the label
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2386 label))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2387
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2388 (defun reftex-guess-label-type ()
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2389 (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
2390 (case-fold-search t)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2391 (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
2392 matched cell)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2393 (save-excursion
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2394 (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
2395 (not (setq matched
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2396 (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
2397 (if matched
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2398 (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
2399 nil)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2400
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2401 (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
2402 ;; Offer a menu with the appropriate labels. Return (label . typekey).
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2403 (let* ((buf (current-buffer))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2404 (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
2405 (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
2406 (xr-index 0)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2407 (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
2408 (here-I-am1 here-I-am)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2409 (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
2410 (files (reftex-typekey-check typekey reftex-label-menu-flags 7))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2411 (context (not (reftex-typekey-check
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2412 typekey reftex-label-menu-flags 3)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2413 (counter (reftex-typekey-check
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2414 typekey reftex-label-menu-flags 2))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2415 (follow (reftex-typekey-check
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2416 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
2417 (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
2418 (match-everywhere (reftex-typekey-check
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2419 typekey reftex-label-menu-flags 6))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2420 (prefix "")
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2421 selection-buffers
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2422 offset rtn key data last-data entry)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2423
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2424 (setq entry (cons nil nil))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2425
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2426 ;; The following unwind-protect kills temporary buffers after use
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2427 (unwind-protect
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2428 (catch 'exit
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2429 (while t
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2430 (save-window-excursion
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2431 (delete-other-windows)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2432 (setq reftex-call-back-to-this-buffer buf)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2433 (if reftex-use-multiple-selection-buffers
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2434 (switch-to-buffer-other-window
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2435 (save-excursion
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2436 (set-buffer buf)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2437 (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
2438 (switch-to-buffer-other-window "*RefTeX Select*")
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2439 (erase-buffer))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2440 (add-to-list 'selection-buffers (current-buffer))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2441 (setq truncate-lines t)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2442 (setq mode-line-format
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2443 (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
2444 " " 'varioref
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2445 " " (abbreviate-file-name
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2446 (buffer-file-name buf))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2447 " -%-"))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2448 (cond
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2449 ((= 0 (buffer-size))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2450 (setq offset (reftex-make-and-insert-label-list
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2451 typekey buf toc files context counter commented
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2452 (or here-I-am offset) prefix)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2453 (here-I-am
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2454 (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
2455 (t (setq offset t)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2456 (setq offset (or offset t))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2457
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2458 (setq here-I-am nil) ; turn off determination of offset
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2459 (setq rtn
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2460 (reftex-select-item
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2461 reftex-select-label-prompt
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2462 reftex-select-label-help
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2463 reftex-select-label-map
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2464 offset
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2465 'reftex-select-label-callback follow
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2466 match-everywhere))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2467 (setq key (car rtn)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2468 data (nth 1 rtn)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2469 last-data (nth 2 rtn)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2470 offset t)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2471 (unless key (throw 'exit nil))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2472 (cond
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2473 ((eq key ?g)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2474 ;; update buffer
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2475 (erase-buffer))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2476 ((or (eq key ?r)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2477 (eq key ?R))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2478 ;; rescan buffer
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2479 (erase-buffer)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2480 (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
2481 ((eq key ?c)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2482 ;; toggle context mode
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2483 (erase-buffer)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2484 (setq context (not context)))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2485 ((eq key ?s)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2486 ;; switch type
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2487 (setq here-I-am here-I-am1)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2488 (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
2489 ((eq key ?t)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2490 ;; toggle table of contents display
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2491 (erase-buffer)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2492 (setq toc (not toc)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2493 ((eq key ?i)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2494 ;; toggle display of included file borders
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2495 (erase-buffer)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2496 (setq files (not files)))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2497 ((eq key ?#)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2498 ;; toggle counter display
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2499 (erase-buffer)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2500 (setq counter (not counter)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2501 ((eq key ?%)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2502 ;; toggle display of commented labels
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2503 (erase-buffer)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2504 (setq commented (not commented)))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2505 ((eq key ?l)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2506 ;; reuse the last referenced label again
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2507 (setq entry reftex-last-used-reference)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2508 (throw 'exit t))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2509 ((eq key ?x)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2510 ;; select an external document
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2511 (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
2512 xr-alist xr-index))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2513 (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
2514 (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
2515 (error "Cannot switch document"))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2516 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
2517 (set-buffer buf)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2518 (reftex-access-scan-info))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2519 ((stringp key)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2520 (setq entry
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2521 (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
2522 (list key typekey)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2523 (throw 'exit t))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2524 (t
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2525 (set-buffer buf)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2526 (if data
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2527 (progn
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2528 (setq entry data)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2529 (setq reftex-last-used-reference entry))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2530 (setq entry nil))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2531 (throw 'exit t))))))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2532 (mapcar (function (lambda (buf)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2533 (and (buffer-live-p buf)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2534 (bury-buffer buf))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2535 selection-buffers)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2536 (reftex-kill-buffer "*RefTeX Context Copy*")
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2537 (reftex-kill-temporary-buffers))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2538 (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
2539 (nth 1 entry))))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2540
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2541 (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
2542 ;; 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
2543 (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
2544 (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
2545 key prefix)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2546 (cond
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2547 ((= len 1)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2548 (message "No external documents available")
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2549 (ding) 0)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2550 ((= len 2)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2551 (- 1 xr-index))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2552 (t
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2553 (save-excursion
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2554 (save-window-excursion
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2555 (let* ((length (apply 'max (mapcar
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2556 (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
2557 (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
2558 (n (1- ?0)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2559 (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
2560 (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
2561 (princ
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2562 (mapconcat
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2563 (function
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2564 (lambda (x)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2565 (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
2566 (abbreviate-file-name (cdr x)))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2567 xr-alist ""))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2568 (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
2569 (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
2570 (setq truncate-lines t)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2571 (catch 'exit
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2572 (while t
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2573 (princ prompt)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2574 (setq key (read-char-exclusive))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2575 (cond
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2576 ((= 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
2577 ((= 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
2578 ((and (>= key ?0) (<= key highest))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2579 (throw 'exit (- key ?0)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2580 ((= key ?\C-i)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2581 (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
2582 (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
2583 xr-alist)))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2584 (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
2585
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2586 (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
2587 ;; 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
2588 (format "*RefTeX[%s][%d]*"
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2589 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
2590
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2591 (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
2592 ;; 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
2593 (save-excursion
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2594 (set-buffer buf)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2595 (reftex-access-scan-info)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2596 (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
2597 entry)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2598 (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
2599 (not (and (stringp (car entry))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2600 (equal typekey (nth 1 entry))))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2601 entry)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2602
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2603 (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
2604 (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
2605 ;; 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
2606 ;; 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
2607 (let* ((font (reftex-use-fonts))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2608 (cnt 0)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2609 (index -1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2610 (toc-indent " ")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2611 (label-indent
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2612 (concat "> "
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2613 (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
2614 (context-indent
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2615 (concat ". "
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2616 (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
2617 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
2618 offset from to docstruct-symbol)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2619
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2620 (message "Creating Selection Buffer...")
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2621
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2622 ;; Pop to buffer buf to get the correct buffer-local variables
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2623 (save-excursion
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2624 (set-buffer buf)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2625
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2626 ;; Ensure access to scanning info
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2627 (reftex-access-scan-info)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2628
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2629 (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
2630 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
2631 reftex-active-toc nil
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2632 master-dir-re
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2633 (concat "\\`" (regexp-quote
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2634 (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
2635
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2636 (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
2637 (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
2638 (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
2639 (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
2640
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2641 ;; 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
2642 (while (setq cell (pop all))
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 (incf index)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2645 (setq from (point))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2646
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2647 (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
2648
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2649 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2650
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2651 ((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
2652 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
2653 ;; These are currently ignored
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2654
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2655 ((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
2656 ;; Beginning or end of a file
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2657 (when files
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2658 (insert
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2659 " 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
2660 (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
2661 (nth 1 cell))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2662 (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
2663 ((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
2664 ((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
2665 (when font
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2666 (put-text-property from (point)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2667 'face 'font-lock-function-name-face))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2668
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2669 ((eq (car cell) 'toc)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2670 ;; a table of contents entry
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2671 (when toc
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2672 (setq reftex-active-toc cell)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2673 (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
2674
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2675 ((stringp (car cell))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2676 ;; a label
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2677 (when (null (nth 2 cell))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2678 ;; 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
2679 (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
2680
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2681 (setq label (car cell)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2682 typekey (nth 1 cell)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2683 text (nth 2 cell)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2684 note (nth 4 cell)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2685 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
2686
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2687 (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
2688 (or show-commented (null comment)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2689
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2690 ;; Yes we want this one
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2691 (incf cnt)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2692 (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
2693
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2694 (setq label (concat xr-prefix label))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2695 (when comment (setq label (concat "% " label)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2696 (insert label-indent label)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2697 (when font
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2698 (put-text-property
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2699 (- (point) (length label)) (point)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2700 'face (if comment
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2701 'font-lock-comment-face
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2702 'font-lock-reference-face)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2703
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2704 (insert (if counter (format " (%d) " cnt) "")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2705 (if comment " LABEL IS COMMENTED OUT " "")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2706 (if note (concat " " note) "")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2707 "\n")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2708 (setq to (point))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2709
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2710 (when context
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2711 (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
2712 (setq to (point)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2713 (put-text-property from to ':data cell)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2714 (goto-char to)))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2715
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2716 (when (reftex-refontify)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2717 (reftex-fontify-select-label-buffer))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2718 offset))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2719
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2720 (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
2721 "Rescan the document."
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2722 (interactive)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2723 (save-window-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2724 (save-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2725 (if buffer
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2726 (if (not (bufferp buffer))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2727 (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
2728 (set-buffer buffer)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2729 (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
2730 (file (nth 3 data)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2731 (reftex-access-scan-info arg file)))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2732
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2733 (defun reftex-query-label-type ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2734 ;; Ask for label type
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2735 (message reftex-type-query-prompt)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2736 (let ((key (read-char)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2737 (when (eq key ?\?)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2738 (save-window-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2739 (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
2740 (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
2741 (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
2742 (setq key (read-char))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2743 (kill-buffer "*RefTeX Help*")))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2744 (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
2745 (error "No such label type: %s" (char-to-string key)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2746 (char-to-string key)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2747
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2748 ;; Variable holding the vector with section numbers
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2749 (defvar reftex-section-numbers [0 0 0 0 0 0 0 0])
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2750
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2751 (defun reftex-section-info (file)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2752 ;; 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
2753 ;; 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
2754 (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
2755 (macro (reftex-match-string 3))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2756 (star (= ?* (char-after (match-end 3))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2757 (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
2758 (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
2759 (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
2760 (literal (buffer-substring-no-properties
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2761 (1- (match-beginning 3))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2762 (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
2763 ;; 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
2764 (text (reftex-nicify-text text1)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2765
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2766 ;; Add section number and indentation
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2767 (setq text
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2768 (concat
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2769 (make-string (* reftex-level-indent level) ?\ )
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2770 (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
2771 (concat section-number " "))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2772 text))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2773 ;; Fontify
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2774 (if (reftex-use-fonts)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2775 (put-text-property 0 (length text)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2776 'face 'font-lock-comment-face text))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2777 (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
2778 literal (marker-position marker))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2779
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2780 (defun reftex-label-info-update (cell)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2781 ;; Update information about just one label in a different file.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2782 ;; CELL contains the old info list
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2783 (let* ((label (nth 0 cell))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2784 (typekey (nth 1 cell))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2785 ;; (text (nth 2 cell))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2786 (file (nth 3 cell))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2787 (note (nth 4 cell))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2788 (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
2789 file (not (eq t reftex-keep-temporary-buffers)))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2790 (if (not buf)
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
2791 (list label typekey "" file "LOST LABEL. RESCAN TO FIX.")
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2792 (save-excursion
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2793 (set-buffer buf)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2794 (save-restriction
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2795 (widen)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2796 (goto-char 1)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2797
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2798 (if (or (re-search-forward
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2799 (format reftex-find-label-regexp-format
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2800 (regexp-quote label)) nil t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2801 (re-search-forward
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2802 (format reftex-find-label-regexp-format2
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2803 (regexp-quote label)) nil t))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2804
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2805 (progn
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2806 (backward-char 1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2807 (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
2808 (list label typekey "" file "LOST LABEL. RESCAN TO FIX.")))))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2809
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2810 (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
2811 ;; 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
2812 (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
2813 (typekey (nth 1 (assoc env-or-mac reftex-env-or-mac-alist)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2814 (file (or file (buffer-file-name)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2815 (parse (if (reftex-typekey-check
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2816 typekey reftex-use-text-after-label-as-context)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2817 nil
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2818 (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
2819 (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
2820 derive)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2821 (if (reftex-in-comment)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2822 (put-text-property 0 1 'in-comment t text))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2823 (list label typekey text file)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2824
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2825 (defun reftex-in-comment ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2826 (save-excursion
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2827 (skip-chars-backward "^%\n\r")
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2828 (eq (preceding-char) ?%)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2829
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2830 (defun reftex-short-context (env parse &optional bound derive)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2831 ;; 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
2832
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2833 (if (consp parse)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2834 (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
2835
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2836 (reftex-nicify-text
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2837
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2838 (cond
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2839
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2840 ((null parse)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2841 (save-excursion
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2842 (reftex-context-substring)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2843
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2844 ((eq parse t)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2845 (if (string= env "section")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2846 ;; special treatment for section labels
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2847 (save-excursion
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2848 (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
2849 (point-min) t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2850 (match-end 2))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2851 (progn
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2852 (goto-char (match-end 0))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2853 (reftex-context-substring))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2854 (if reftex-active-toc
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2855 (progn
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2856 (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
2857 (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
2858 "SECTION HEADING NOT FOUND")))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2859 (save-excursion
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2860 (goto-char reftex-default-context-position)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2861 (unless (eq (string-to-char env) ?\\)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2862 (reftex-move-over-touching-args))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2863 (reftex-context-substring))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2864
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2865 ((stringp parse)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2866 (save-excursion
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2867 (if (re-search-backward parse bound t)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2868 (progn
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2869 (goto-char (match-end 0))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2870 (reftex-context-substring))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2871 "NO MATCH FOR CONTEXT REGEXP")))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2872
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2873 ((integerp parse)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2874 (or (save-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2875 (goto-char reftex-default-context-position)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2876 (reftex-nth-arg
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2877 parse
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2878 (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
2879 ""))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2880
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2881 ((fboundp parse)
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
2882 ;; A hook function. Call it.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2883 (save-excursion
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2884 (condition-case error-var
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2885 (funcall parse env)
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2886 (error (format "HOOK ERROR: %s" (cdr error-var))))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2887 (t
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2888 "ILLEGAL VALUE OF PARSE"))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2889
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2890 (defun reftex-where-am-I ()
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2891 ;; 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
2892 ;; 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
2893 ;; exact (t) or approximate (nil).
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2894
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2895 (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
2896 (cnt 0) rtn
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2897 found)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2898 (save-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2899 (while (not rtn)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2900 (incf cnt)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2901 (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
2902 (setq rtn
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2903 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2904 ((not found)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2905 ;; no match
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2906 (or
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2907 (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
2908 (not (setq cnt 2))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2909 (assq 'bof docstruct) ;; for safety reasons
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2910 'corrupted))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2911 ((match-end 1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2912 ;; Label
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2913 (assoc (reftex-match-string 1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2914 (symbol-value reftex-docstruct-symbol)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2915 ((match-end 3)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2916 ;; Section
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2917 (goto-char (1- (match-beginning 3)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2918 (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
2919 docstruct))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2920 (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
2921 list)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2922 rtn1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2923 (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
2924 (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
2925 (string= (buffer-file-name)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2926 (nth 3 (car list))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2927 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2928 ((equal (point)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2929 (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
2930 (marker-position (nth 4 (car list))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2931 (nth 8 (car list))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2932 ;; 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
2933 (setq rtn1 (car list) list nil))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2934 ((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
2935 (nth 7 (car list))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2936 ;; Same title
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2937 (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
2938 (pop list))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2939 rtn1))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2940 ((match-end 7)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2941 ;; Input or include...
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2942 (car
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2943 (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
2944 (reftex-match-string 7)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2945 (cdr (assq 'master-dir docstruct))))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2946 docstruct)))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2947 ((match-end 9)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2948 (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
2949 ((match-end 10)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2950 (save-excursion
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2951 (goto-char (match-end 10))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2952 (assoc (reftex-no-props
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2953 (reftex-nth-arg-wrapper
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2954 (reftex-match-string 10)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2955 (symbol-value reftex-docstruct-symbol))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2956 (t
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2957 (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
2958 (cons rtn (eq cnt 1))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2959
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2960 (defun reftex-parse-args (macro)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2961 ;; 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
2962 ;; optional argument indices.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2963 (if (string-match "[[{]\\*?[]}]" macro)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2964 (progn
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2965 (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
2966 (args (substring macro (match-beginning 0)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2967 opt-list nlabel (cnt 0))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2968 (while (string-match "\\`[[{]\\(\\*\\)?[]}]" args)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2969 (incf cnt)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2970 (when (eq ?\[ (string-to-char args))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2971 (push cnt opt-list))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2972 (when (and (match-end 1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2973 (not nlabel))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2974 (setq nlabel cnt))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2975 (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
2976 (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
2977 nil))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2978
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2979 (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
2980 ;; 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
2981 ;; 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
2982 ;; 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
2983 ;; in TeX.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2984 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2985 ;; Just to be quick:
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2986 ((memq (following-char) '(?\[ ?\{)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2987 ;; Do a search
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2988 ((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
2989 (goto-char (1- (match-end 0)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2990 t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2991 (t nil)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2992
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2993 (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
2994 ;; 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
2995 ;; 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
2996 ;; 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
2997 ;; in TeX.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2998 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2999 ;; Just to be quick:
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3000 ((memq (preceding-char) '(?\] ?\})))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3001 ;; Do a search
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3002 ((re-search-backward
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3003 "[]}][ \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
3004 (goto-char (1+ (match-beginning 0)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3005 t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3006 (t nil)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3007
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3008 (defun reftex-nth-arg-wrapper (key)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3009 (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
3010 (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
3011
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3012 (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
3013 ;; 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
3014 ;; 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
3015
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3016 ;; 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
3017 (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
3018
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3019 (if (= n 1000)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3020 ;; Special case: Skip all touching arguments
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3021 (progn
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3022 (reftex-move-over-touching-args)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3023 (reftex-context-substring))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3024
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3025 ;; Do the real thing.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3026 (let ((cnt 1))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3027
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3028 (when (reftex-move-to-next-arg)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3029
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3030 (while (< cnt n)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3031 (while (and (member cnt opt-args)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3032 (eq (following-char) ?\{))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3033 (incf cnt))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3034 (when (< cnt n)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3035 (unless (and (condition-case nil
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3036 (or (forward-list 1) t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3037 (error nil))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3038 (reftex-move-to-next-arg)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3039 (incf cnt))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3040 (setq cnt 1000))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3041
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3042 (while (and (memq cnt opt-args)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3043 (eq (following-char) ?\{))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3044 (incf cnt)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3045 (if (and (= n cnt)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3046 (> (skip-chars-forward "{\\[") 0))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3047 (reftex-context-substring)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3048 nil))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3049
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3050 (defun reftex-move-over-touching-args ()
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3051 (condition-case nil
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3052 (while (memq (following-char) '(?\[ ?\{))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3053 (forward-list 1))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3054 (error nil)))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3055
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3056 (defun reftex-context-substring ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3057 ;; Return up to 100 chars from point
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3058 ;; When point is just after a { or [, limit string to matching parenthesis
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3059 (cond
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3060 ((or (= (preceding-char) ?\{)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3061 (= (preceding-char) ?\[))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3062 ;; 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
3063 (buffer-substring-no-properties
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3064 (point)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3065 (min (reftex-fp 150)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3066 (point-max)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3067 (condition-case nil
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3068 (progn
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3069 (up-list 1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3070 (1- (point)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3071 (error (point-max))))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3072 (t
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3073 ;; 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
3074 (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
3075
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3076 (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
3077 ;; 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
3078 ;; in the toc entry.
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3079 (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
3080 (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
3081 (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
3082 (i depth) number-string)
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3083 (while (>= i 0)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3084 (if (> i level)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3085 (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
3086 (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
3087 (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
3088 (aset reftex-section-numbers i
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3089 (- (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
3090 (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
3091 (pop numbers))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3092 (decf i)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3093 (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
3094
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3095 (defun reftex-section-number (&optional level star)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3096 ;; Return a string with the current section number.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3097 ;; 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
3098 (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
3099 (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
3100 (when level
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3101 (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
3102 (aset reftex-section-numbers
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3103 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
3104 (setq idx (1+ level))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3105 (while (<= idx depth)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3106 (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
3107 (incf idx)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3108 (setq idx 0)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3109 (while (<= idx depth)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3110 (setq n (aref reftex-section-numbers idx))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3111 (setq string (concat string (if (not (string= string "")) "." "")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3112 (int-to-string n)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3113 (incf idx))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3114 (save-match-data
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3115 (if (string-match "\\`\\([@0]\\.\\)+" string)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3116 (setq string (replace-match "" nil nil string)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3117 (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
3118 (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
3119 (if (and appendix
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3120 (string-match "\\`[0-9]+" string))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3121 (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
3122
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3123 (if star
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3124 (concat (make-string (1- (length string)) ?\ ) "*")
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3125 string)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3126
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3127 (defun reftex-select-label-callback (data forward no-revisit)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3128 ;; Callback function called from the label selection in order to
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3129 ;; show context in another window
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3130 (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
3131 label file buffer re found)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3132 ;; pop to original buffer in order to get correct variables
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3133 (catch 'exit
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3134 (setq label (nth 0 data)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3135 file (nth 3 data))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3136
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3137 ;; 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
3138 (setq buffer
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3139 (if no-revisit
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3140 (get-file-buffer file)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3141 (reftex-get-file-buffer-force
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3142 file (not reftex-keep-temporary-buffers))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3143 (if buffer
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3144 ;; good - the file is available
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3145 (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
3146 ;; we have got a problem here. The file does not exist.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3147 ;; 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
3148 ;; (ding)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3149 (throw 'exit nil))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3150
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3151 ;; search for that label
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3152 (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
3153 (setq found
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3154 (if forward
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3155 (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
3156 (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
3157 (unless found
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3158 (goto-char (point-min))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3159 (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
3160 ;; 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
3161 (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
3162 (regexp-quote label)) nil t)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3163 (when (match-end 3)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3164 (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
3165 (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
3166 (- (point) (match-end 3)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3167 (recenter (/ (window-height) 2)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3168 (select-window this-window))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3169
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3170 (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
3171 ;; Find LABEL in any file in FILE-LIST in another window.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3172 ;; If mark-to-kill is non-nil, mark new buffer for killing.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3173 ;; 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
3174 (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
3175 (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
3176 (re-list (list re1 re2)) re
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3177 (file-list-1 file-list)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3178 file buf)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3179 (catch 'exit
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3180 (while (setq re (pop re-list))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3181 (setq file-list file-list-1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3182 (while (setq file (pop file-list))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3183 (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
3184 (error "No such file %s" file))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3185 (set-buffer buf)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3186 (widen)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3187 (goto-char (point-min))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3188 (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
3189 (switch-to-buffer-other-window buf)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3190 (goto-char (match-beginning 0))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3191 (recenter (/ (window-height) 2))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3192 (if highlight
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3193 (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
3194 (throw 'exit (selected-window)))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3195 (error "Label %s not found" label))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3196
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3197 (defun reftex-find-duplicate-labels ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3198 "Produce a list of all duplicate labels in the document."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3199
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3200 (interactive)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3201
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3202 ;; Rescan the document to make sure
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3203 (reftex-access-scan-info t)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3204
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3205 (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
3206 (cnt 0)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3207 (dlist
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3208 (mapcar
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3209 (function
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3210 (lambda (x)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3211 (let (x1)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3212 (cond
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3213 ((memq (car x)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3214 '(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
3215 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
3216 nil)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3217 (t
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3218 (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
3219 (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
3220 (if (< 1 (length x1))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3221 (append (list (car x))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3222 (mapcar (function
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3223 (lambda(x)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3224 (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
3225 x1))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3226 (list nil)))))))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3227 (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
3228
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3229 (setq dlist (reftex-uniquify dlist))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3230 (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
3231 (switch-to-buffer-other-window "*Duplicate Labels*")
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3232 (make-local-variable 'TeX-master)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3233 (setq TeX-master master)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3234 (erase-buffer)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3235 (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
3236 (insert
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
3237 " 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
3238 " and its references. Type `q' to exit this buffer.\n\n")
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3239 (insert " LABEL FILE\n")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3240 (insert " -------------------------------------------------------------\n")
20177
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
3241 (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
3242 (local-set-key [?q] (function
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3243 (lambda () (interactive)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3244 (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
3245 (local-set-key [?r] 'reftex-change-label)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3246 (while dlist
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3247 (when (and (car (car dlist))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3248 (cdr (car dlist)))
20177
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
3249 (incf cnt)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3250 (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
3251 (pop dlist))
20177
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
3252 (goto-char (point-min))
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
3253 (when (= cnt 0)
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
3254 (kill-buffer (current-buffer))
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
3255 (delete-window)
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
3256 (message "Document does not contain duplicate labels."))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3257
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3258 (defun reftex-all-assq (key list)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3259 ;; 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
3260 (let (rtn)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3261 (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
3262 (push (car list) rtn)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3263 (pop list))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3264 (nreverse rtn)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3265
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3266 (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
3267 ;; 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
3268 (let (rtn)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3269 (while list
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3270 (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
3271 (push (car list) rtn))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3272 (pop list))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3273 (nreverse rtn)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3274
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3275 (defun reftex-kill-temporary-buffers (&optional buffer)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3276 ;; 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
3277 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3278 (buffer
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3279 (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
3280 (kill-buffer buffer)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3281 (setq reftex-buffers-to-kill
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3282 (delete buffer reftex-buffers-to-kill))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3283 (t
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3284 (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
3285 (when (bufferp buffer)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3286 (and (buffer-modified-p buffer)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3287 (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
3288 (buffer-file-name buffer)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3289 (save-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3290 (set-buffer buffer)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3291 (save-buffer)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3292 (kill-buffer buffer))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3293 (pop reftex-buffers-to-kill)))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3294
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3295 (defun reftex-show-entry (beg-hlt end-hlt)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3296 ;; 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
3297 (let* ((pos (point))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3298 (n (/ (window-height) 2))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3299 (beg (save-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3300 (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
3301 (end (save-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3302 (re-search-forward "[\n\r]" nil 1 n) (point))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3303 (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
3304 (string-match
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3305 "\r" (buffer-substring beg end)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3306 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3307 ((eq t reftex-auto-show-entry)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3308 (subst-char-in-region
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3309 (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
3310 (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
3311 ?\r ?\n t))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3312 ((eq reftex-auto-show-entry 'copy)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3313 (let ((string (buffer-substring beg end)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3314 (switch-to-buffer "*RefTeX Context Copy*")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3315 (setq buffer-read-only nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3316 (erase-buffer)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3317 (insert string)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3318 (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
3319 (goto-char (- pos beg))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3320 (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
3321 (1+ (- (point) end-hlt)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3322 (when (reftex-refontify)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3323 (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
3324 (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
3325 (font-lock-mode 1)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3326 (setq buffer-read-only t)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3327 ))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3328
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3329 (defun reftex-nicify-text (text)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3330 ;; 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
3331 ;; 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
3332 (while (string-match "[\n\r\t]\\|[ \t][ \t]+" text)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3333 (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
3334 ;; 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
3335 (if (string-match "\\(\\\\end{\\|\\\\item\\|\\\\\\\\\\).*" text)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3336 (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
3337 ;; kill the embedded label
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3338 (if (string-match "\\\\label{[^}]*}" text)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3339 (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
3340 ;; remove leading garbage
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3341 (if (string-match "\\`[ }]+" text)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3342 (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
3343 ;; limit length
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3344 (cond
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3345 ((> (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
3346 ((= (length text) 0) " ")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3347 (t text)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3348
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3349 (defun reftex-typekey-check (typekey conf-variable &optional n)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3350 ;; Check if CONF-VARIABLE is true or contains TYPEKEY
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3351 (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
3352 (or (eq conf-variable t)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3353 (and (stringp conf-variable)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3354 (string-match (concat "[" conf-variable "]") typekey))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3355
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3356 ;;; ===========================================================================
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3357 ;;;
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3358 ;;; Table of contents
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3359
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3360 ;; 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
3361
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3362 (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
3363 "Keymap used for *toc* buffer.")
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3364
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3365 (defvar reftex-last-toc-master nil
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3366 "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
3367
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3368 (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
3369 "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
3370
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3371 (defvar reftex-last-window-height nil)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3372
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3373 (defvar reftex-toc-return-marker (make-marker)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3374 "Marker which makes it possible to return from toc to old position.")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3375
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3376 (defconst reftex-toc-help
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3377 " AVAILABLE KEYS IN TOC BUFFER
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3378 ============================
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3379 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
3380 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
3381 TAB Goto the section.
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3382 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
3383 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
3384 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
3385 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
3386 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
3387
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3388 (defun reftex-toc ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3389 "Show the table of contents for the current document.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3390 When called with a raw C-u prefix, rescan the document first."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3391
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3392 (interactive)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3393
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3394 (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
3395 current-prefix-arg)
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3396 (reftex-empty-toc-buffer))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3397
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3398 (setq reftex-last-toc-file (buffer-file-name))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3399 (setq reftex-last-toc-master (reftex-TeX-master-file))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3400
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3401 (set-marker reftex-toc-return-marker (point))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3402
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3403 ;; If follow mode is active, arrange to delay it one command
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3404 (if reftex-toc-follow-mode
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3405 (setq reftex-toc-follow-mode 1))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3406
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3407 ;; 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
3408 (reftex-access-scan-info current-prefix-arg)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3409
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3410 (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
3411 (xr-data (assq 'xr all))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3412 (xr-alist (cons (cons "" (buffer-file-name)) (nth 1 xr-data)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3413 (where (reftex-nearest-section))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3414 toc1 cell startpos)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3415
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3416 (if (get-buffer-window "*toc*")
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3417 (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
3418 (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
3419 (delete-other-windows))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3420 (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
3421 (split-window)
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3422 (switch-to-buffer (get-buffer-create "*toc*")))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3423
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3424 (cond
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3425 ;; buffer is empty - fill it with the table of contents
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3426 ((= (buffer-size) 0)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3427 (message "Building *toc* buffer...")
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
3428 (make-local-variable 'revert-buffer-function)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3429 (setq revert-buffer-function 'reftex-toc-revert)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3430 (setq truncate-lines t)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3431 (make-local-hook 'post-command-hook)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3432 (make-local-hook 'pre-command-hook)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3433 (setq post-command-hook '(reftex-toc-post-command-hook))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3434 (setq pre-command-hook '(reftex-toc-pre-command-hook))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3435 (use-local-map reftex-toc-map)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3436
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3437 (insert (format
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3438 "TABLE-OF-CONTENTS on %s
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3439 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
3440 -------------------------------------------------------------------------------
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3441 " (abbreviate-file-name reftex-last-toc-master)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3442 (setq startpos (point))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3443
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3444 (if (reftex-use-fonts)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3445 (put-text-property 1 (point) 'face 'font-lock-keyword-face))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3446 (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
3447 (put-text-property 1 2 'xr-alist xr-alist)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3448
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3449 (while all
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3450 (setq cell (car all)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3451 all (cdr all))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3452 (when (eq (car cell) 'toc)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3453 (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
3454 (put-text-property 0 (length toc1) 'toc cell toc1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3455 (insert toc1)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3456
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3457 (backward-delete-char 1)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3458
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3459 (message "Building *toc* buffer...done.")
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3460 (setq buffer-read-only t))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3461 (t
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3462 (goto-line 3)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3463 (beginning-of-line)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3464 (setq startpos (point))))
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 ;; Find the correct section
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3467 (goto-char (point-max))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3468 (beginning-of-line)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3469 (while (and (> (point) startpos)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3470 (not (eq (get-text-property (point) 'toc) where)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3471 (beginning-of-line 0))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3472
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3473 (defun reftex-nearest-section ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3474 ;; 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
3475 (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
3476 (reftex-last-assoc-before-elt
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3477 'toc here-I-am (symbol-value reftex-docstruct-symbol))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3478
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3479 (defun reftex-toc-pre-command-hook ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3480 ;; used as pre command hook in *toc* buffer
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3481 (reftex-unhighlight 0)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3482 (reftex-unhighlight 1))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3483
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3484 (defun reftex-toc-post-command-hook ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3485 ;; used in the post-command-hook for the *toc* buffer
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3486 (and (> (point) 1)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3487 (save-excursion
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3488 (reftex-highlight 1
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3489 (progn (beginning-of-line) (point))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3490 (progn (end-of-line) (point)))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3491 (cond
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3492 ((integerp reftex-toc-follow-mode)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3493 ;; remove delayed action
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3494 (setq reftex-toc-follow-mode t))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3495 (reftex-toc-follow-mode
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3496 ;; show context in other window
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3497 (condition-case nil
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3498 (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
3499 (error t)))))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3500
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3501 (defun reftex-empty-toc-buffer ()
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3502 (if (get-buffer "*toc*")
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3503 (save-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3504 (set-buffer "*toc*")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3505 (setq buffer-read-only nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3506 (erase-buffer))))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3507
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3508 (defun reftex-re-enlarge ()
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3509 (enlarge-window
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3510 (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
3511 (window-height)))))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3512
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3513 (defun reftex-toc-show-help ()
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3514 (interactive)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3515 (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
3516 (princ reftex-toc-help))
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3517 ;; 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
3518 (if reftex-toc-follow-mode
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3519 (setq reftex-toc-follow-mode 1)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3520
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3521 (defun reftex-toc-toggle-follow ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3522 "Toggle toc-follow mode.
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
3523 (It is not really a mode, just a flag)."
18050
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 (setq reftex-toc-follow-mode (not reftex-toc-follow-mode)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3526 (defun reftex-toc-view-line ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3527 "View document location in other window."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3528 (interactive)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3529 (reftex-toc-visit-line))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3530 (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
3531 "Go to document location in other window. Hide the *toc* window."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3532 (interactive)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3533 (reftex-toc-visit-line 'hide))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3534 (defun reftex-toc-goto-line ()
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3535 "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
3536 (interactive)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3537 (reftex-toc-visit-line t))
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3538 (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
3539 "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
3540 (interactive "e")
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3541 (mouse-set-point ev)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3542 (reftex-toc-visit-line 'hide))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3543 (defun reftex-toc-quit ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3544 "Hide the *toc* window and do not move point."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3545 (interactive)
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3546 (or (one-window-p) (delete-window))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3547 (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
3548 (reftex-re-enlarge)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3549 (goto-char (or (marker-position reftex-toc-return-marker) (point))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3550 (defun reftex-toc-quit-and-kill ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3551 "Kill the *toc* buffer."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3552 (interactive)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3553 (kill-buffer "*toc*")
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3554 (or (one-window-p) (delete-window))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3555 (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
3556 (reftex-re-enlarge)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3557 (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
3558 (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
3559 "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
3560 (interactive)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3561 (if reftex-enable-partial-scans
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3562 (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
3563 (if (not file)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3564 (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
3565 (switch-to-buffer-other-window
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3566 (reftex-get-file-buffer-force file))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3567 (setq current-prefix-arg '(4))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3568 (reftex-toc)))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3569 (reftex-toc-Rescan))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3570 (reftex-kill-temporary-buffers))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3571 (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
3572 "Regenerate the *toc* buffer by reparsing the entire document."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3573 (interactive)
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3574 (switch-to-buffer-other-window
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3575 (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
3576 (setq current-prefix-arg '(16))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3577 (reftex-toc))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3578 (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
3579 "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
3580 (interactive)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3581 (switch-to-buffer-other-window
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3582 (reftex-get-file-buffer-force reftex-last-toc-file))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3583 (reftex-empty-toc-buffer)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3584 (setq current-prefix-arg nil)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3585 (reftex-toc))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3586 (defun reftex-toc-external (&rest ignore)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3587 "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
3588 (interactive)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3589 (let* ((old-buf (current-buffer))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3590 (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
3591 (xr-index (reftex-select-external-document
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3592 xr-alist 0)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3593 (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
3594 (cdr (nth xr-index xr-alist)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3595 (error "Cannot switch document")))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3596 (reftex-toc)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3597 (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
3598 (message "")
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3599 (message "Switched document"))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3600
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3601 (defun reftex-toc-visit-line (&optional final no-revisit)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3602 ;; 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
3603 ;; If FINAL is t, stay there
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3604 ;; 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
3605 ;; 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
3606 ;; 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
3607 ;; 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
3608 ;; have been active.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3609
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3610 (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
3611 (file (nth 3 toc))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3612 (marker (nth 4 toc))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3613 (level (nth 5 toc))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3614 (literal (nth 7 toc))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3615 (emergency-point (nth 8 toc))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3616 (toc-window (selected-window))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3617 show-window show-buffer match)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3618
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3619 (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
3620
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3621 (setq match
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3622 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3623 ((and (markerp marker) (marker-buffer marker))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3624 ;; 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
3625 (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
3626 (goto-char (marker-position marker))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3627 (or (looking-at (regexp-quote literal))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3628 (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
3629 (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
3630 (looking-at (concat "\\\\"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3631 (regexp-quote
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3632 (car (rassq level reftex-section-levels)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3633 "[[{]"))))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3634 ((or (not no-revisit)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3635 (get-file-buffer file))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3636 ;; 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
3637 (switch-to-buffer-other-window
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3638 (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
3639 (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
3640 (or (looking-at (regexp-quote literal))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3641 (let ((pos (point)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3642 (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
3643 (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
3644 (reftex-nearest-match
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3645 (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
3646 (reftex-nearest-match
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3647 (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
3648 ))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3649
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3650 (setq show-window (selected-window)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3651 show-buffer (current-buffer))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3652
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3653 (unless match
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3654 (select-window toc-window)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3655 (error "Cannot find line"))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3656
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3657 (goto-char (match-beginning 0))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3658 (recenter 1)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3659 (reftex-highlight 0 (match-beginning 0) (match-end 0) (current-buffer))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3660
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3661 (select-window toc-window)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3662
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3663 ;; use the `final' parameter to decide what to do next
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3664 (cond
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3665 ((eq final t)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3666 (reftex-unhighlight 0)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3667 (select-window show-window))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3668 ((eq final 'hide)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3669 (reftex-unhighlight 0)
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3670 (or (one-window-p) (delete-window))
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3671 (switch-to-buffer show-buffer)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3672 (reftex-re-enlarge))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3673 (t nil))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3674
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3675 ;;; ===========================================================================
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3676 ;;;
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3677 ;;; BibTeX citations.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3678
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3679 ;; Variables and constants
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3680
18219
aaeaae005e98 Updated documentation at several points in the file.
Richard M. Stallman <rms@gnu.org>
parents: 18123
diff changeset
3681 ;; 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
3682 (defvar reftex-cite-format-builtin)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3683
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3684 ;; The history list of regular expressions used for citations
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3685 (defvar reftex-cite-regexp-hist nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3686
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3687 ;; 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
3688 (defconst reftex-citation-prompt
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3689 "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
3690
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3691 (defconst reftex-citation-help
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3692 " 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
3693 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
3694 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
3695 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
3696 f Toggle follow mode: Other window will follow with full db entry.
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3697 q Quit without inserting \\cite macro into buffer.
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3698 e Recursive edit into other window.
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3699 TAB Enter citation key with completion.
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3700 RET / a Accept current entry / Accept all entries.")
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3701
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3702 (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
3703 "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
3704 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
3705 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
3706
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3707 ;; Find bibtex files
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3708
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3709 (defun reftex-get-bibfile-list ()
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3710 ;; 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
3711 ;; 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
3712 ;; 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
3713 ;; 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
3714 ;; Then this function will return the applicable database files.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3715
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3716 ;; Ensure access to scanning info
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3717 (reftex-access-scan-info)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3718 (or
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3719 ;; 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
3720 (cdr (reftex-last-assoc-before-elt
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3721 'bib (list 'eof (buffer-file-name))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3722 (member (list 'bof (buffer-file-name))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3723 (symbol-value reftex-docstruct-symbol))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3724 ;; 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
3725 (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
3726 (symbol-value reftex-docstruct-symbol))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3727 ;; Anywhere in the entire document
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3728 (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
3729 (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
3730
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3731 (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
3732 ;; 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
3733 ;; 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
3734 (cond
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3735 ((file-name-absolute-p file)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3736 (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
3737 (t
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3738 (reftex-access-search-path "tex")
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3739 (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
3740 file1)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3741 (setq file1
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3742 (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
3743 (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
3744 (unless file1
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3745 (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
3746 (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
3747 (setq file1
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3748 (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
3749 (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
3750 (cond (file1 file1)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3751 (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
3752 (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
3753
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3754 (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
3755 ;; 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
3756 (reftex-access-search-path "bib")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3757 (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
3758 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
3759 (unless file1
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3760 (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
3761 (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
3762 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
3763 (cond (file1 file1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3764 (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
3765 (t (message "No such file: %s (ignored)" file) nil))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3766
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3767 ;; Find a certain reference in any of the BibTeX files.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3768
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3769 (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
3770 &optional mark-to-kill highlight item)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3771 ;; 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
3772 ;; 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
3773 ;; 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
3774 ;; 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
3775
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3776 (let* ((re
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3777 (if item
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3778 (concat "\\\\bibitem\\(\\[[^]]*\\]\\)?{" (regexp-quote key) "}")
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3779 (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
3780 (window-conf (current-window-configuration))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3781 file buf)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3782
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3783 (catch 'exit
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3784 (switch-to-buffer-other-window (current-buffer))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3785 (while file-list
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3786 (setq file (car file-list)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3787 file-list (cdr file-list))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3788 (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
3789 (error "No such file %s" file))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3790 (switch-to-buffer buf)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3791 (widen)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3792 (goto-char (point-min))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3793 (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
3794 (goto-char (match-beginning 0))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3795 (recenter 0)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3796 (if highlight
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3797 (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
3798 (throw 'exit (selected-window))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3799 (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
3800 (if item
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3801 (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
3802 (message "No BibTeX entry with citation key %s" key)))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3803
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3804 ;; Parse bibtex buffers
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3805
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3806 (defun reftex-extract-bib-entries (buffers &optional get-word)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3807 ;; Extract bib entries which match regexps from BUFFERS.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3808 ;; BUFFERS is a list of buffers or file names.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3809 ;; Return list with entries."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3810 (let* (re-list first-re rest-re
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3811 (buffer-list (if (listp buffers) buffers (list buffers)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3812 found-list entry buffer1 buffer alist
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3813 key-point start-point end-point)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3814
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3815 (setq re-list (split-string
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3816 (read-string "RegExp [ && RegExp...]: "
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3817 nil 'reftex-cite-regexp-hist)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3818 "[ \t]*&&[ \t]*"))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3819
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3820 (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
3821 rest-re (cdr re-list)) ; the others to narrow down.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3822 (if (string-match "\\`[ \t]*\\'" first-re)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3823 (error "Empty regular expression"))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3824
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3825 (save-excursion
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3826 (save-window-excursion
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3827
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3828 ;; Walk through all bibtex files
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3829 (while buffer-list
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3830 (setq buffer (car buffer-list)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3831 buffer-list (cdr buffer-list))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3832 (if (and (bufferp buffer)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3833 (buffer-live-p buffer))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3834 (setq buffer1 buffer)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3835 (setq buffer1 (reftex-get-file-buffer-force
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3836 buffer (not reftex-keep-temporary-buffers))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3837 (if (not buffer1)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3838 (error "Cannot find BibTeX file %s" buffer)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3839 (message "Scanning bibliography database %s" buffer1))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3840
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3841 (set-buffer buffer1)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3842 (save-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3843 (goto-char (point-min))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3844 (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
3845 (catch 'search-again
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3846 (setq key-point (point))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3847 (unless (re-search-backward
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3848 "\\(\\`\\|[\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
3849 (throw 'search-again nil))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3850 (setq start-point (point))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3851 (goto-char (match-end 0))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3852 (condition-case nil
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3853 (up-list 1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3854 (error (goto-char key-point)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3855 (throw 'search-again nil)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3856 (setq end-point (point))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3857
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3858 ;; 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
3859 ;; outside entries
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3860 (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
3861 (string= (downcase (match-string 2)) "comment")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3862 (string= (downcase (match-string 2)) "c")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3863 (< (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
3864 (goto-char key-point)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3865 (throw 'search-again nil))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3866
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3867 ;; Well, we have got a match
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3868 (setq entry (concat
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3869 (buffer-substring start-point (point)) "\n"))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3870
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3871 ;; 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
3872 (setq re-list rest-re)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3873 (while re-list
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3874 (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
3875 ;; nope - move on
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3876 (throw 'search-again nil))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3877 (pop re-list))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3878
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3879 (setq alist (reftex-parse-bibtex-entry
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3880 nil start-point end-point))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3881 (push (cons "&entry" entry) alist)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3882
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3883 ;; check for crossref entries
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3884 (if (assoc "crossref" alist)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3885 (setq alist
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3886 (append
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3887 alist (reftex-get-crossref-alist alist))))
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 ;; format the entry
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3890 (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
3891 alist)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3892
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3893 ;; add it to the list
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3894 (push alist found-list))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3895 (reftex-kill-temporary-buffers))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3896 (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
3897
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3898 ;; Sorting
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3899 (cond
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3900 ((eq 'author reftex-sort-bibtex-matches)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3901 (sort found-list 'reftex-bib-sort-author))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3902 ((eq 'year reftex-sort-bibtex-matches)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3903 (sort found-list 'reftex-bib-sort-year))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3904 ((eq 'reverse-year reftex-sort-bibtex-matches)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3905 (sort found-list 'reftex-bib-sort-year-reverse))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3906 (t found-list))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3907
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3908 (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
3909 (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
3910 (al2 (reftex-get-bib-names "author" e2)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3911 (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
3912 (pop al1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3913 (pop al2))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3914 (if (and (stringp (car al1))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3915 (stringp (car al2)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3916 (string< (car al1) (car al2))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3917 (not (stringp (car al1))))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3918
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3919 (defun reftex-bib-sort-year (e1 e2)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3920 (< (string-to-int (cdr (assoc "year" e1)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3921 (string-to-int (cdr (assoc "year" e2)))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3922
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3923 (defun reftex-bib-sort-year-reverse (e1 e2)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3924 (> (string-to-int (or (cdr (assoc "year" e1)) "0"))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3925 (string-to-int (or (cdr (assoc "year" e2)) "0"))))
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-get-crossref-alist (entry)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3928 ;; return the alist from a crossref entry
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3929 (let ((crkey (cdr (assoc "crossref" entry)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3930 start)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3931 (save-excursion
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3932 (save-restriction
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3933 (widen)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3934 (if (re-search-forward
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3935 (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
3936 "[ \t\n\r]*,") nil t)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3937 (progn
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3938 (setq start (match-beginning 0))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3939 (condition-case nil
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3940 (up-list 1)
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3941 (error nil))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3942 (reftex-parse-bibtex-entry nil start (point)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3943 nil)))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3944
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3945 ;; Parse the thebibliography environment
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3946 (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
3947 ;; 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
3948 ;; 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
3949 ;; 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
3950
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3951 (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
3952 (unless file
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3953 (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
3954 (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
3955 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
3956 (unless buf
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3957 (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
3958 (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
3959
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3960 (save-excursion
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3961 (set-buffer buf)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3962 (save-restriction
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3963 (widen)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3964 (goto-char (point-min))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3965 (if (re-search-forward
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3966 "\\(\\`\\|[\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
3967 (progn
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3968 (beginning-of-line 2)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3969 (setq start (point))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3970 (if (re-search-forward
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3971 "\\(\\`\\|[\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
3972 (progn
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3973 (beginning-of-line 1)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3974 (setq end (point))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3975 (when (and start (point))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3976 (setq entries
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3977 (mapcar 'reftex-parse-bibitem
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3978 (delete ""
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3979 (split-string
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3980 (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
3981 "[ \t\n\r]*\\\\bibitem\\(\\[[^]]*]\\)*")))))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3982 (unless entries
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3983 (error "No bibitems found"))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3984
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3985 (setq re-list (split-string
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3986 (read-string "RegExp [ && RegExp...]: "
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3987 nil 'reftex-cite-regexp-hist)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3988 "[ \t]*&&[ \t]*"))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3989 (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
3990 (error "Empty regular expression"))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3991
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3992 (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
3993 (setq entries
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3994 (delete nil (mapcar
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3995 (function
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3996 (lambda (x)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3997 (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
3998 x nil)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3999 entries))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4000
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4001 (setq entries
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4002 (mapcar
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4003 (function
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4004 (lambda (x)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4005 (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
4006 entries))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4007
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4008 entries))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4009
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4010 ;; Parse and format individual entries
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4011
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4012 (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
4013 ;; 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
4014 (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
4015 (if (equal "" names)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4016 (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
4017 (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
4018 (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
4019 (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
4020 (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
4021 (while (string-match "^[ \t]+\\|[ \t]+$" names)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4022 (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
4023 (while (string-match "[ \t][ \t]+" names)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4024 (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
4025 (split-string names "\n")))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4026
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4027 (defun reftex-parse-bibtex-entry (entry &optional from to)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4028 (let (alist key start field)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4029 (save-excursion
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4030 (save-restriction
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4031 (if entry
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4032 (progn
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4033 (switch-to-buffer "*RefTeX-scratch*")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4034 (fundamental-mode)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4035 (erase-buffer)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4036 (insert entry))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4037 (widen)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4038 (narrow-to-region from to))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4039 (goto-char (point-min))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4040
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4041 (if (re-search-forward
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
4042 "@\\(\\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
4043 (setq alist
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4044 (list
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4045 (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
4046 (cons "&key" (reftex-match-string 2)))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4047 (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
4048 (setq key (downcase (reftex-match-string 1)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4049 (cond
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4050 ((= (following-char) ?{)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4051 (forward-char 1)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4052 (setq start (point))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4053 (condition-case nil
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4054 (up-list 1)
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4055 (error nil)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4056 ((= (following-char) ?\")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4057 (forward-char 1)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4058 (setq start (point))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4059 (while (and (search-forward "\"" nil t)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4060 (= ?\\ (char-after (- (point) 2))))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4061 (t
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4062 (setq start (point))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4063 (re-search-forward "[ \t\n\r,}]" nil 1)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4064 (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
4065 ;; remove extra whitespace
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4066 (while (string-match "[\n\t\r]\\|[ \t][ \t]+" field)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4067 (setq field (replace-match " " nil t field)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4068 ;; remove leading garbage
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4069 (if (string-match "^[ \t{]+" field)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4070 (setq field (replace-match "" nil t field)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4071 ;; remove trailing garbage
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4072 (if (string-match "[ \t}]+$" field)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4073 (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
4074 (push (cons key field) alist))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4075 alist))
18050
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-get-bib-field (fieldname entry)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4078 ;; Extract the field FIELDNAME from an ENTRY
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4079 (or (cdr (assoc fieldname entry))
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
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4082 (defun reftex-format-bib-entry (entry)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4083 ;; Format a BibTeX ENTRY so that it is nice to look at
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4084 (let*
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4085 ((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
4086 (authors (mapconcat 'identity auth-list ", "))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4087 (year (reftex-get-bib-field "year" entry))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4088 (title (reftex-get-bib-field "title" entry))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4089 (type (reftex-get-bib-field "&type" entry))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4090 (key (reftex-get-bib-field "&key" entry))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4091 (extra
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4092 (cond
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4093 ((equal type "article")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4094 (concat (reftex-get-bib-field "journal" entry) " "
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4095 (reftex-get-bib-field "volume" entry) ", "
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4096 (reftex-get-bib-field "pages" entry)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4097 ((equal type "book")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4098 (concat "book (" (reftex-get-bib-field "publisher" entry) ")"))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4099 ((equal type "phdthesis")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4100 (concat "PhD: " (reftex-get-bib-field "school" entry)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4101 ((equal type "mastersthesis")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4102 (concat "Master: " (reftex-get-bib-field "school" entry)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4103 ((equal type "inbook")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4104 (concat "Chap: " (reftex-get-bib-field "chapter" entry)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4105 ", pp. " (reftex-get-bib-field "pages" entry)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4106 ((or (equal type "conference")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4107 (equal type "incollection")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4108 (equal type "inproceedings"))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4109 (concat "in: " (reftex-get-bib-field "booktitle" entry)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4110 (t ""))))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4111 (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
4112 (when (reftex-use-fonts)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4113 (put-text-property 0 (length authors) 'face 'font-lock-keyword-face
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4114 authors)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4115 (put-text-property 0 (length title) 'face 'font-lock-comment-face
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4116 title)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4117 (put-text-property 0 (length extra) 'face 'font-lock-reference-face
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4118 extra))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4119 (concat key "\n " authors " " year " " extra "\n " title "\n\n")))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4120
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4121 (defun reftex-parse-bibitem (item)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4122 ;; Parse a \bibitem entry
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4123 (let ((key "") (text ""))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4124 (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
4125 (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
4126 text (match-string 2 item)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4127 ;; 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
4128 (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
4129 (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
4130 (if (string-match "\\`[ \t]+" text)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4131 (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
4132 (list
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4133 (cons "&key" key)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4134 (cons "&text" text)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4135 (cons "&entry" (concat key " " text)))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4136
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4137 (defun reftex-format-bibitem (item)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4138 ;; 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
4139 (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
4140 (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
4141 (lines nil))
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 ;; 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
4144 (while (and (> (length text) 70)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4145 (string-match " " (substring text 60)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4146 (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
4147 (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
4148 (push text lines)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4149 (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
4150
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4151 (when (reftex-use-fonts)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4152 (put-text-property 0 (length text) 'face 'font-lock-comment-face text))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4153 (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
4154
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4155 ;; Make a citation
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4156
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4157 (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
4158 "Make a citation using BibTeX database files.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4159 After asking for a Regular Expression, it scans the buffers with
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4160 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
4161 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
4162 to `reftex-cite-format' and inserted into the buffer.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4163 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
4164 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
4165 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
4166 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
4167 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
4168 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
4169 put into the same \\cite command.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4170 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
4171 bibliography statement (e.g. if it was changed)."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4172
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4173 (interactive)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4174
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4175 ;; check for recursive edit
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4176 (reftex-check-recursive-edit)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4177
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4178 ;; 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
4179 (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
4180
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4181 ;; Call reftex-do-citation, but protected
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4182 (unwind-protect
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4183 (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
4184 (reftex-kill-temporary-buffers)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4185
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4186 (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
4187 ;; 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
4188
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4189 ;; 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
4190 ;; 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
4191 (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
4192 (if (and (stringp macro)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4193 (string-match "\\`\\\\cite\\|cite\\'" macro))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4194 (progn
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4195 (cond
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4196 ((or (not arg)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4197 (not (listp arg)))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4198 (setq format
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4199 (concat
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4200 (if (not (or (= (preceding-char) ?{)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4201 (= (preceding-char) ?,)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4202 ","
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4203 "")
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4204 "%l"
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4205 (if (not (or (= (following-char) ?})
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4206 (= (following-char) ?,)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4207 ","
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4208 ""))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4209 (t
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4210 (setq format "%l"))))
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4211 ;; else: figure out the correct format
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4212 (setq format
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4213 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4214 ((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
4215 ((and (symbolp reftex-cite-format)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4216 (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
4217 (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
4218 (t reftex-cite-format)))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4219 (if (listp format)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4220 (save-window-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4221 (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
4222 (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
4223 (princ
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4224 (mapconcat
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4225 (function (lambda (x)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4226 (format "[%c] %s %s" (car x)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4227 (if (> (car x) 31) " " "")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4228 (cdr x))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4229 format "\n")))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4230 (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
4231 (setq key (read-char))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4232 (if (assq key format)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4233 (setq format (cdr (assq key format)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4234 (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
4235
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4236 (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
4237
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4238 ;; Scan bibtex files
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4239 (setq found-list
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4240 (cond
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4241 ((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
4242 ;; using BibTeX database files.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4243 (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
4244 ((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
4245 ;; using thebibliography environment.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4246 (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
4247 (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
4248 (reftex-default-bibliography
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4249 (message "Using default bibliography")
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4250 (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
4251 (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
4252
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4253 (unless found-list
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4254 (error "Sorry, no matches found"))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4255
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4256 ;; remember where we came from
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4257 (setq reftex-call-back-to-this-buffer (current-buffer))
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4258
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4259 ;; offer selection
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4260 (save-window-excursion
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4261 (delete-other-windows)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4262 (switch-to-buffer-other-window "*RefTeX Select*")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4263 (erase-buffer)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4264 (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
4265 (if (= 0 (buffer-size))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4266 (error "Sorry, no matches found"))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4267 (setq truncate-lines t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4268 (goto-char 1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4269 (if (catch 'exit
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4270 (while t
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4271 (setq rtn
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4272 (reftex-select-item
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4273 reftex-citation-prompt
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4274 reftex-citation-help
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4275 reftex-select-bib-map
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4276 nil
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4277 'reftex-bibtex-selection-callback nil))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4278 (setq key (car rtn)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4279 data (nth 1 rtn))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4280 (unless key (throw 'exit nil))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4281 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4282 ((eq key ?g)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4283 (setq found-list
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4284 (save-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4285 (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
4286 (reftex-extract-bib-entries
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4287 (reftex-get-bibfile-list))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4288 (erase-buffer)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4289 (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
4290 (if (= 0 (buffer-size))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4291 (error "Sorry, no matches found"))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4292 (goto-char 1))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4293
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4294 ((eq key ?r)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4295 ;; restrict with new regular expression
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4296 (setq re-list
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4297 (split-string (read-string
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4298 "RegExp [ && RegExp...]: "
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4299 nil 'reftex-cite-regexp-hist)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4300 "[ \t]*&&[ \t]*"))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4301 (while re-list
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4302 (setq re (car re-list)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4303 re-list (cdr re-list))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4304 (setq found-list-r
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4305 (delete ""
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4306 (mapcar
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4307 (function
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4308 (lambda (x)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4309 (if (string-match
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4310 re (cdr (assoc "&entry" x)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4311 x
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4312 "")))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4313 found-list))))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4314 (if found-list-r
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4315 (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
4316 (ding))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4317 (erase-buffer)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4318 (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
4319 (goto-char 1))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4320 ((eq key ?a)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4321 (setq entry 'all)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4322 (throw 'exit t))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4323 ((or (eq key ?\C-m)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4324 (eq key 'return))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4325 (if data
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4326 (setq entry data)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4327 (setq entry nil))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4328 (throw 'exit t))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4329 ((stringp key)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4330 (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
4331 (throw 'exit t))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4332 (t
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4333 (ding)))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4334 (progn
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4335 ;; format the entry
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4336 (if (eq entry 'all)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4337 (setq ins-string
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4338 (mapconcat
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4339 (function
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4340 (lambda (entry)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4341 (if reftex-format-cite-function
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4342 (funcall reftex-format-cite-function
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4343 (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
4344 format)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4345 (reftex-format-citation entry format))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4346 found-list "\n"))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4347 (setq ins-string
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4348 (if reftex-format-cite-function
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4349 (funcall reftex-format-cite-function
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4350 (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
4351 format)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4352 (reftex-format-citation entry format)))))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4353 (setq ins-string "")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4354 (message "Quit")))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4355 (kill-buffer "*RefTeX Select*")
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4356
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4357 (unless no-insert
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4358 (insert ins-string)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4359 (when (string-match "\\?" ins-string)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4360 (search-backward "?")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4361 (delete-char 1)))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4362 (message "")
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4363
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4364 ;; 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
4365 (when (and (integerp arg)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4366 (> arg 1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4367 (re-search-backward
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4368 "\\\\\\([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
4369 (goto-char (match-end 0))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4370 (decf arg)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4371 (reftex-do-citation arg))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4372
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4373 ;; Return the citation key
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4374 (or (eq entry 'all)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4375 (reftex-get-bib-field "&key" entry)))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4376
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4377 (defun reftex-insert-bib-matches (list)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4378 ;; Insert the bib matches and number them correctly
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4379 (let (tmp)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4380 (mapcar
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4381 (function
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4382 (lambda (x)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4383 (setq tmp (cdr (assoc "&formatted" x)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4384 (put-text-property 0 (length tmp) ':data x tmp)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4385 (insert tmp)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4386 list)))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4387
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4388 (defun reftex-format-names (namelist n)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4389 (let (last (len (length namelist)))
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4390 (cond
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4391 ((= 1 len) (car namelist))
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4392 ((> 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
4393 (t
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4394 (setq n (min len n)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4395 last (nth (1- n) namelist))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4396 (setcdr (nthcdr (- n 2) namelist) nil)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4397 (concat
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4398 (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
4399 (nth 1 reftex-cite-punctuation)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4400 last)))))
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4401
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4402 (defun reftex-format-citation (entry format)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4403 ;; 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
4404
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4405 (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
4406
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4407 (if (and reftex-comment-citations
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4408 (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
4409 (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
4410
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4411 (while (string-match
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4412 "\\(\\`\\|[^%]\\)\\(\\(%\\([0-9]*\\)\\([a-zA-Z]\\)\\)[.,;: ]*\\)"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4413 format)
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4414 (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
4415 (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
4416 rpl b e)
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4417 (save-match-data
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4418 (setq rpl
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4419 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4420 ((= l ?l) (concat
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4421 (reftex-get-bib-field "&key" entry)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4422 (if reftex-comment-citations
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4423 reftex-cite-comment-format
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4424 "")))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4425 ((= l ?a) (reftex-format-names
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4426 (reftex-get-bib-names "author" entry)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4427 (or n 2)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4428 ((= 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
4429 ((= 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
4430 ((= 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
4431 ((= 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
4432 ((= l ?e) (reftex-format-names
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4433 (reftex-get-bib-names "editor" entry)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4434 (or n 2)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4435 ((= 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
4436 ((= 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
4437 ((= 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
4438 ((= 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
4439 ((= 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
4440 ((= 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
4441 ((= 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
4442 ((= 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
4443 ((= 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
4444 ((= l ?P) (car (split-string
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4445 (reftex-get-bib-field "pages" entry)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4446 "[- .]+")))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4447 ((= 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
4448 ((= 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
4449 ((= 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
4450 ((= 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
4451 ((= 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
4452 ((= 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
4453
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4454 (if (string= rpl "")
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4455 (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
4456 (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
4457 (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
4458 (while (string-match "%%" format)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4459 (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
4460 (while (string-match "[ ,.;:]*%<" format)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4461 (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
4462 format)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4463
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4464 (defun reftex-bibtex-selection-callback (data ignore no-revisit)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4465 ;; 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
4466 ;; 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
4467 ;; recommended for follow mode. It works OK for individual lookups.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4468 (let ((win (selected-window))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4469 (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
4470 bibfile-list item tmp)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4471
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4472 (catch 'exit
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4473 (save-excursion
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4474 (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
4475 (cond
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4476 ((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
4477 (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
4478 ((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
4479 (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
4480 item t))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4481 (reftex-default-bibliography
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4482 (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
4483 (t (ding) (throw 'exit))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4484
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4485 (when no-revisit
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4486 (setq bibfile-list
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4487 (delq nil (mapcar (lambda (x)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4488 (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
4489 bibfile-list))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4490
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4491 (reftex-pop-to-bibtex-entry
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4492 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
4493
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4494 (select-window win)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4495
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4496 ;;; ===========================================================================
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4497 ;;;
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4498 ;;; Here is the routine used for selection
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4499
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4500 ;; Marker for return point from recursive edit
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4501 (defvar reftex-recursive-edit-marker (make-marker))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4502
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4503 (defvar reftex-last-data nil)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4504 (defvar reftex-last-line nil)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4505
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4506 (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
4507 ;; 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
4508 ;; message if so.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4509 (if (marker-position reftex-recursive-edit-marker)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4510 (error
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4511 (substitute-command-keys
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4512 "In unfinished recursive edit. Finish (\\[exit-recursive-edit]) or abort (\\[abort-recursive-edit])."))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4513
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4514 (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
4515 &optional offset
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4516 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
4517 ;; 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
4518 ;; 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
4519 ;; selected.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4520 ;; 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
4521 ;; selection commands.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4522 ;; 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
4523 ;; 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
4524 ;; 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
4525 ;; 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
4526 ;; of the element.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4527 ;; 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
4528 ;; 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
4529 ;; places.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4530
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4531 (let* (key-sq b e ev data last-data cmd skip-callback
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4532 (orig-buffer (current-buffer))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4533 (search-str "") last-cmd callback-fwd)
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4534
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4535 (setq ev
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4536 (catch 'exit
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4537 (save-window-excursion
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4538 (setq truncate-lines t)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4539
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4540 ;; Find a good starting point
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4541 (cond
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4542 (offset
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4543 (goto-char
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4544 (or (and (listp offset)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4545 (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
4546 ':data offset))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4547 (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
4548 (boundp 'reftex-last-data)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4549 (listp reftex-last-data)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4550 (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
4551 ':data reftex-last-data))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4552 (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
4553 (boundp 'reftex-last-line)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4554 (integerp reftex-last-line)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4555 (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
4556 (point-min))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4557 (t (goto-char (point-min))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4558 (beginning-of-line 1)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4559
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4560 (unwind-protect
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4561 (progn
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4562 (use-local-map keymap)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4563 (while t
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4564 (setq data (get-text-property (point) ':data))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4565 (setq last-data (or data last-data))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4566
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4567 (if (and data cb-flag call-back (not skip-callback))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4568 (funcall call-back data callback-fwd
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4569 (not reftex-revisit-to-follow)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4570 (setq skip-callback nil)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4571 (if data
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4572 (setq b (or (previous-single-property-change
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4573 (1+ (point)) ':data)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4574 (point-min))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4575 e (or (next-single-property-change
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4576 (point) ':data)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4577 (point-max)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4578 (setq b (point) e (point)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4579 (reftex-highlight 1 b e)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4580 (if (or (not (pos-visible-in-window-p b))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4581 (not (pos-visible-in-window-p e)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4582 (recenter (/ (window-height) 2)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4583
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4584 (setq last-cmd cmd
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4585 cmd nil)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4586
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4587 (setq key-sq (read-key-sequence prompt))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4588 (setq cmd (lookup-key keymap key-sq))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4589
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4590 (reftex-unhighlight 2)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4591 (reftex-unhighlight 1)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4592 (reftex-unhighlight 0)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4593
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4594 (if cmd
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4595 (condition-case nil
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4596 (progn
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4597 (command-execute cmd)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4598 ;FIXME: (run-hooks 'post-command-hook)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4599 )
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4600 (error (ding)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4601 (ding))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4602
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4603 (unless (equal (current-buffer) orig-buffer)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4604 (error "Selection commands must return to *RefTeX Select* buffer."))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4605 (use-local-map nil)))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4606
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4607 (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
4608 (+ (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
4609 (set (make-local-variable 'reftex-last-data) last-data)
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4610 (and (get-buffer "*RefTeX Help*") (kill-buffer "*RefTeX Help*"))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4611 (message "")
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4612 (list ev data last-data)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4613
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4614 ;; 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
4615 ;; 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
4616
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4617 (defvar last-cmd)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4618 (defvar found-list)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4619 (defvar cb-flag)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4620 (defvar data)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4621 (defvar call-back)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4622 (defvar help-string)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4623 (defvar skip-callback)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4624 (defvar search-str)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4625 (defvar match-everywhere)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4626 (defvar forward)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4627 (defvar keymap)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4628 (defvar callback-fwd)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4629 (defvar varioref)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4630 (defconst reftex-select-search-minibuffer-map
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4631 (let ((map (copy-keymap minibuffer-local-map)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4632 (define-key map "\C-s"
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4633 (function (lambda() (interactive) (setq forward t) (exit-minibuffer))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4634 (define-key map "\C-r"
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4635 (function (lambda() (interactive) (setq forward nil) (exit-minibuffer))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4636 (define-key map "\C-m" 'exit-minibuffer)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4637 map))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4638
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4639 ;; The selection commands
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4640
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4641 (defun reftex-select-next ()
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4642 (interactive)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4643 (setq callback-fwd t)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4644 (or (eobp) (forward-char 1))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4645 (re-search-forward "^[^. \t\n\r]" nil t 1)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4646 (beginning-of-line 1))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4647 (defun reftex-select-previous ()
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4648 (interactive)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4649 (setq callback-fwd nil)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4650 (re-search-backward "^[^. \t\n\r]" nil t))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4651 (defun reftex-select-scroll-up ()
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4652 (interactive)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4653 (setq callback-fwd t)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4654 (while (and (pos-visible-in-window-p)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4655 (re-search-forward "^[^. \t\n\r]" nil t)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4656 (beginning-of-line 1)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4657 (recenter 1))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4658 (defun reftex-select-scroll-down ()
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4659 (interactive)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4660 (setq callback-fwd nil)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4661 (while (and (pos-visible-in-window-p)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4662 (re-search-backward "^[^. \t\n\r]" nil t)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4663 (recenter (- (window-height) 4)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4664 (defun reftex-select-next-heading ()
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4665 (interactive)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4666 (end-of-line)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4667 (re-search-forward "^ " nil t)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4668 (beginning-of-line))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4669 (defun reftex-select-previous-heading ()
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4670 (interactive)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4671 (re-search-backward "^ " nil t))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4672 (defun reftex-select-scroll-other-window ()
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4673 (interactive)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4674 (setq skip-callback t)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4675 (scroll-other-window))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4676 (defun reftex-select-scroll-other-window-down ()
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4677 (interactive)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4678 (setq skip-callback t)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4679 (scroll-other-window-down nil))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4680 (defun reftex-select-quit ()
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4681 (interactive)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4682 (throw 'exit nil))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4683 (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
4684 (interactive)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4685 (let (pos)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4686 (cond
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4687 ((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
4688 reftex-last-data
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4689 (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
4690 ':data reftex-last-data)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4691 (goto-char pos))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4692 ((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
4693 (integerp reftex-last-line))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4694 (goto-line reftex-last-line))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4695 (t (ding)))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4696 (defun reftex-select-toggle-follow ()
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4697 (interactive)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4698 (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
4699 (defun reftex-select-toggle-varioref ()
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4700 (interactive)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4701 (if (string= varioref "\\ref")
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4702 (setq varioref "\\vref")
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4703 (setq varioref "\\ref"))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4704 (force-mode-line-update))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4705 (defun reftex-select-callback ()
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4706 (interactive)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4707 (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
4708 (defun reftex-select-accept ()
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4709 (interactive)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4710 (throw 'exit 'return))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4711 (defun reftex-select-read-label ()
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4712 (interactive)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4713 (let ((label (completing-read
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4714 "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
4715 nil nil reftex-prefix)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4716 (unless (or (equal label "") (equal label reftex-prefix))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4717 (throw 'exit label))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4718 (defun reftex-select-read-cite ()
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4719 (interactive)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4720 (let* ((list (mapcar (lambda (x)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4721 (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
4722 found-list))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4723 (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
4724 (unless (equal key "")
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4725 (throw 'exit key))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4726 (defun reftex-select-help ()
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4727 (interactive)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4728 (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
4729 (princ help-string))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4730 (reftex-enlarge-to-fit "*RefTeX Help*" t)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4731 (setq skip-callback t))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4732 (defun reftex-select-recursive-edit ()
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4733 (interactive)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4734 (set-marker reftex-recursive-edit-marker (point))
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 (save-window-excursion
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4738 (save-excursion
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4739 (other-window 1)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4740 (message
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4741 (substitute-command-keys
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4742 "Recursive edit. Return to selection with \\[exit-recursive-edit]"))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4743 (recursive-edit)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4744 (unless (equal (marker-buffer
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4745 reftex-recursive-edit-marker)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4746 (current-buffer))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4747 (error "Cannot continue RefTeX from this buffer."))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4748 (goto-char reftex-recursive-edit-marker))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4749 (set-marker reftex-recursive-edit-marker nil)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4750
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4751 (defun reftex-select-search-forward ()
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4752 (interactive)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4753 (reftex-select-search t))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4754 (defun reftex-select-search-backward ()
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4755 (interactive)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4756 (reftex-select-search nil))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4757 (defun reftex-select-search (forward)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4758 (let (tmp search-start matched)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4759 (if (or (and (not (eq last-cmd 'reftex-select-search-forward))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4760 (not (eq last-cmd 'reftex-select-search-backward)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4761 (string= search-str ""))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4762 (setq tmp ; get a new string
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4763 (read-from-minibuffer
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4764 (if (string= search-str "")
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4765 "Search: "
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4766 (format "Search [%s]:" search-str))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4767 nil reftex-select-search-minibuffer-map)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4768 search-str (if (string= tmp "")
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4769 search-str tmp)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4770 (setq search-start (point))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4771 (and (not (string= search-str ""))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4772 (progn
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4773 (while
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4774 (and (setq matched
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4775 (if forward
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4776 (search-forward search-str nil 1)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4777 (search-backward search-str nil 1)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4778 (or (>= (save-excursion
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4779 (goto-char (match-beginning 0))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4780 (current-column))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4781 (window-width))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4782 (not (or (get-text-property (point) ':data)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4783 match-everywhere)))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4784 (if matched
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4785 (reftex-highlight 2 (match-beginning 0)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4786 (match-end 0))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4787 (ding)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4788 (goto-char search-start))))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4789
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4790 ;;; ===========================================================================
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4791 ;;;
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4792 ;;; View cross references
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4793
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4794 (defun reftex-view-crossref (&optional arg)
18123
7831ac89a334 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18050
diff changeset
4795 "View cross reference of \\ref or \\cite macro at point.
7831ac89a334 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18050
diff changeset
4796 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
4797 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
4798 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
4799 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
4800 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
4801 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
4802 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
4803 contain cross references.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4804 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
4805 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
4806 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
4807 argument.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4808 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
4809 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
4810
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4811 (interactive "P")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4812
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4813 ;; See where we are.
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4814 (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
4815 (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
4816 (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
4817 (my-window (selected-window))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4818 pop-window cmd args point)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4819
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4820 (if (and macro
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4821 (string-match "\\`\\\\cite\\|\\`\\\\ref\\|cite\\'\\|ref\\'"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4822 macro))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4823 (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
4824 (string-match "\\`\\\\" macro)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4825 (setq macro (substring macro 1)))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4826 (setq macro nil))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4827
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4828 (if (and macro
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4829 (eq last-command this-command)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4830 (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
4831 (if (string= macro "cite")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4832 (progn
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4833 (skip-chars-forward "^},%")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4834 (while (and (eq (following-char) ?%)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4835 (or (beginning-of-line 2) t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4836 (skip-chars-forward " \t\n\r")))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4837 (skip-chars-forward ",")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4838 (if (eq (following-char) ?})
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4839 (setq macro nil)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4840 (setq macro nil)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4841
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4842 (if (and (not macro)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4843 (or (not (string-match "\\`\\\\" this-word))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4844 (eq (following-char) ?\\)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4845 (search-backward "\\" nil t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4846 t))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4847 (if (interactive-p)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4848 ;; 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
4849 (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
4850 (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
4851 ;; 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
4852 (and (looking-at re)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4853 (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
4854 (goto-char (match-end 0)))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4855
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4856
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4857 (unless macro
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4858 (error "No cross reference to display"))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4859
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4860 ;; 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
4861 (reftex-access-scan-info current-prefix-arg)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4862
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4863 (cond
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4864 ((string= macro "cite")
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4865 (cond
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4866 ((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
4867 (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
4868 args (list
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4869 (reftex-this-word "^{},%\n\r")
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4870 (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
4871 ((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
4872 (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
4873 args (list
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4874 (reftex-this-word "^{},%\n\r")
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4875 (list (cdr (assq 'thebib
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4876 (symbol-value reftex-docstruct-symbol))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4877 nil t t)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4878 (t (error "Cannot display crossref\n"))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4879 ((string= macro "ref")
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4880 (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
4881 (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
4882 (xr-re (nth 2 xr-data))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4883 (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
4884
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4885 (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
4886 ;; Label is defined in external document
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4887 (save-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4888 (save-match-data
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4889 (set-buffer
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4890 (or (reftex-get-file-buffer-force
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4891 (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
4892 (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
4893 (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
4894 (reftex-access-scan-info)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4895 (setq entry
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4896 (assoc label (symbol-value reftex-docstruct-symbol)))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4897 (if entry
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4898 (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
4899 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
4900 (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
4901 (t (error "This should not happen (reftex-view-crossref)")))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4902 (setq point (point))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4903 (apply cmd args)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4904 (setq pop-window (selected-window))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4905 (add-hook 'pre-command-hook 'reftex-highlight-shall-die)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4906 (select-window my-window)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4907 (goto-char point)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4908 (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
4909 (select-window pop-window))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4910
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4911 (defun reftex-mouse-view-crossref (ev)
18123
7831ac89a334 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18050
diff changeset
4912 "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
4913 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
4914 If it is a \\cite, show the BibTeX database entry.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4915 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
4916 With argument, actually select the window showing the cross reference."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4917 (interactive "e")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4918 (mouse-set-point ev)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4919 (reftex-view-crossref current-prefix-arg))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4920
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4921 ;;; ===========================================================================
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4922 ;;;
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4923 ;;; Functions that check out the surroundings
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4924
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4925 (defun reftex-what-macro (which &optional bound)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4926 ;; 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
4927 ;; 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
4928
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4929 ;; If WHICH is nil, immediately return nil.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4930 ;; If WHICH is t, return list of all macros enclosing point.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4931 ;; 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
4932 ;; name of the first macro in this list found to enclose point.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4933 ;; 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
4934 ;; 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
4935 ;; like statement.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4936
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4937 ;; 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
4938 ;; 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
4939 ;; 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
4940 ;; considered an argument of macro \macro.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4941
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4942 (catch 'exit
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4943 (if (null which) (throw 'exit nil))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4944 (let ((bound (or bound (save-excursion (re-search-backward
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4945 reftex-section-regexp nil 1)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4946 (point))))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4947 pos cmd-list cmd cnt cnt-opt entry)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4948 (save-restriction
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4949 (save-excursion
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4950 (narrow-to-region (max 1 bound) (point-max))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4951 ;; move back out of the current parenthesis
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4952 (while (condition-case nil
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4953 (progn (up-list -1) t)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4954 (error nil))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4955 (setq cnt 1 cnt-opt 0)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4956 ;; 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
4957 (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
4958 (condition-case nil
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4959 (progn (backward-sexp) t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4960 (error nil)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4961 (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
4962 (incf cnt))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4963 (setq pos (point))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4964 (when (and (or (= (following-char) ?\[)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4965 (= (following-char) ?\{))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4966 (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
4967 (setq cmd (reftex-match-string 0))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4968 (when (looking-at "\\\\begin{[^}]*}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4969 (setq cmd (reftex-match-string 0)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4970 cnt (1- cnt)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4971 ;; 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
4972 (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
4973 (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
4974 (setq cmd nil)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4975 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4976 ((null cmd))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4977 ((eq t which)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4978 (push (cons cmd (point)) cmd-list))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4979 ((member cmd which)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4980 (throw 'exit (cons cmd (point))))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4981 (goto-char pos)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4982 (nreverse cmd-list)))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4983
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4984 (defun reftex-what-environment (which &optional bound)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4985 ;; 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
4986 ;; 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
4987 ;; them.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4988
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4989 ;; If WHICH is nil, immediately return nil.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4990 ;; If WHICH is t, return list of all environments enclosing point.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4991 ;; 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
4992 ;; 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
4993 ;; point.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4994
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4995 ;; 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
4996 ;; 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
4997
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4998 (catch 'exit
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4999 (save-excursion
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5000 (if (null which) (throw 'exit nil))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5001 (let ((bound (or bound (save-excursion (re-search-backward
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5002 reftex-section-regexp nil 1)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5003 (point))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5004 env-list end-list env)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5005 (while (re-search-backward "\\\\\\(begin\\|end\\){\\([^}]+\\)}"
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5006 bound t)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5007 (setq env (buffer-substring-no-properties
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5008 (match-beginning 2) (match-end 2)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5009 (cond
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5010 ((string= (match-string 1) "end")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5011 (add-to-list 'end-list env))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5012 ((member env end-list)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5013 (setq end-list (delete env end-list)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5014 ((eq t which)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5015 (push (cons env (point)) env-list))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5016 ((member env which)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5017 (throw 'exit (cons env (point))))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5018 (nreverse env-list)))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5019
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5020 ;; ============================================================================
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5021 ;;
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5022 ;; Some generally useful functions
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5023
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5024 (defun reftex-no-props (string)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5025 ;; Return STRING with all text properties removed
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5026 (and (stringp string)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5027 (set-text-properties 0 (length string) nil string))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5028 string)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5029
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5030 (defun reftex-match-string (n)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5031 ;; Match string without properties
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5032 (when (match-beginning n)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5033 (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
5034
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5035 (defun reftex-kill-buffer (buffer)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5036 ;; Kill buffer if it exists.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5037 (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
5038 (kill-buffer buffer)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5039
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5040 (defun reftex-erase-buffer (buffer)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5041 ;; Erase buffer if it exists.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5042 (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
5043 (save-excursion
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5044 (set-buffer buffer)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5045 (erase-buffer))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5046
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5047 (defun reftex-this-word (&optional class)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5048 ;; Grab the word around point.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5049 (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
5050 (save-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5051 (buffer-substring-no-properties
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5052 (progn (skip-chars-backward class) (point))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5053 (progn (skip-chars-forward class) (point)))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5054
20177
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
5055 (defvar enable-multibyte-characters)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5056 (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
5057 ;; Truncate a string to NCHAR characters.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5058 ;; 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
5059 ;; 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
5060 (setq string
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5061 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5062 ((and (boundp 'enable-multibyte-characters)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5063 enable-multibyte-characters)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5064 (if (<= (string-width string) ncols)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5065 string
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5066 (if ellipses
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5067 (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
5068 (truncate-string-to-width string ncols))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5069 (t
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5070 (if (<= (length string) ncols)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5071 string
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5072 (if ellipses
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5073 (concat (substring string 0 (- ncols 3)) "...")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5074 (substring string 0 ncols))))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5075 (if padding
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5076 (format (format "%%-%ds" ncols) string)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5077 string))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5078
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5079 (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
5080 ;; 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
5081 ;; 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
5082 ;; 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
5083 (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
5084 (goto-char start)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5085 (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
5086 (setq match1 (match-data)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5087 (goto-char start)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5088 (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
5089 (setq match2 (match-data)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5090 (goto-char start)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5091 (setq match
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5092 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5093 ((not match1) match2)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5094 ((not match2) match1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5095 ((< (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
5096 (t match2)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5097 (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
5098
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5099 (defun reftex-auto-mode-alist ()
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5100 ;; 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
5101 ;; Stolen from gnus nnheader.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5102 (let ((alist auto-mode-alist)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5103 out)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5104 (while alist
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5105 (when (listp (cdr (car alist)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5106 (push (car alist) out))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5107 (pop alist))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5108 (nreverse out)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5109
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5110 (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
5111 ;; 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
5112 ;; 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
5113 (let* ((win1 (selected-window))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5114 (buf1 (current-buffer))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5115 (win2 (get-buffer-window buf2)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5116 (when win2
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5117 (select-window win2)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5118 (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
5119 (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
5120 (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
5121 (window-height))))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5122 (cond
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5123 ((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
5124 (keep-current
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5125 ;; 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
5126 (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
5127 (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
5128
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5129 (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
5130 ;; 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
5131 ;; 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
5132 ;; FILE is just for the message.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5133 (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
5134 (status (get pathvar 'status)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5135 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5136 ((eq status 'recursed))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5137 ((and status (null recurse)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5138 ((null status)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5139 (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
5140 reftex-bibpath-environment-variables)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5141 (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
5142 (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
5143 env-vars path-separator))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5144 (put pathvar 'status 'split))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5145 ((and (eq 'split status) recurse)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5146 (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
5147 (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
5148 (put pathvar 'status 'recursed)))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5149
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5150 (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
5151 ;; 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
5152 (catch 'exit
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5153 (when (file-name-absolute-p file)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5154 (if (file-exists-p file)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5155 (throw 'exit file)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5156 (throw 'exit nil)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5157 (let* ((thepath path) file1 dir
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5158 (doubleslash (concat "/" "/")))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5159 (while (setq dir (pop thepath))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5160 (when (string= (substring dir -2) doubleslash)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5161 (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
5162 (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
5163 (if (file-exists-p file1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5164 (throw 'exit file1)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5165 ;; No such file
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5166 nil)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5167
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5168 (defun reftex-parse-colon-path (path)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5169 ;; 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
5170 (mapcar 'file-name-as-directory
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5171 (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
5172
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5173 (defun reftex-expand-path (path)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5174 ;; 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
5175 (let (path1 dir dirs (doubleslash (concat "/" "/")))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5176 (while (setq dir (pop path))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5177 (if (string= (substring dir -2) doubleslash)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5178 (progn
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5179 (setq dir (substring dir 0 -1))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5180 (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
5181 (setq path1 (append dirs path1)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5182 (push dir path1)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5183 (nreverse path1)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5184
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5185 (defun reftex-recursive-directory-list (dir)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5186 (let ((path (list dir)) dirs path1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5187 (while (setq dir (pop path))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5188 (setq dirs
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5189 (delete nil
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5190 (mapcar
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5191 (function
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5192 (lambda (x)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5193 (if (and (file-directory-p x)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5194 (not (string-match "/\\.+\\'" x)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5195 (file-name-as-directory x)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5196 nil)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5197 (directory-files dir t))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5198 (setq path (append dirs path))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5199 (push dir path1))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5200 path1))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5201
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5202 (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
5203 ;; 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
5204 (let ((start -2))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5205 (setq string (regexp-quote string))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5206 (while (setq start (string-match "[\n\r]" string (+ 3 start)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5207 (setq string (replace-match "[\n\r]" nil t string)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5208 string))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5209
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5210 (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
5211 ;; 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
5212 ;; 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
5213 (let* ((n (1+ (string-match "[[{]" old)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5214 (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
5215 (old (substring old n)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5216 (while (string-match
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5217 "\\([\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
5218 old)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5219 (if (match-beginning 1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5220 (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
5221 (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
5222 (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
5223 new))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5224
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5225 (defun reftex-delete-list (elt-list list)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5226 ;; like delete, but with a list of things to delete
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5227 ;; (original code from Rory Molinari)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5228 (while elt-list
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5229 (setq list (delete (car elt-list) list)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5230 elt-list (cdr elt-list)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5231 list)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5232
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5233 (defun reftex-get-buffer-visiting (file)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5234 ;; return a buffer visiting FILE
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5235 (cond
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5236 ((boundp 'find-file-compare-truenames) ; XEmacs
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5237 (let ((find-file-compare-truenames t))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5238 (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
5239 ((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
5240 (find-buffer-visiting file))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5241 (t (error "This should not happen (reftex-get-buffer-visiting)"))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5242
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5243 (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
5244 ;; 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
5245 ;; 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
5246 ;; 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
5247 ;; 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
5248 ;; and mark the buffer to be killed after use.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5249
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5250 (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
5251
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5252 (cond (buf
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5253 ;; 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
5254 buf)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5255
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5256 ((file-readable-p file)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5257 ;; 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
5258
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5259 (if (or (not mark-to-kill)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5260 (eq t reftex-initialize-temporary-buffers))
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 ;; Visit the file with full magic
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5263 (setq buf (find-file-noselect file))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5264
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5265 ;; 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
5266 ;; with limited Magic
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5267
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5268 ;; The magic goes away
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5269 (let ((format-alist nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5270 (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
5271 (default-major-mode 'fundamental-mode)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5272 (after-insert-file-functions nil))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5273 (setq buf (find-file-noselect file)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5274
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5275 ;; Is there a hook to run?
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5276 (when (listp reftex-initialize-temporary-buffers)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5277 (save-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5278 (set-buffer buf)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5279 (run-hooks 'reftex-initialize-temporary-buffers))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5280
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5281 ;; 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
5282 (and mark-to-kill
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5283 (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
5284
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5285 ;; Return the new buffer
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5286 buf)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5287
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5288 ;; 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
5289 (t nil))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5290
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5291 (defun reftex-splice-symbols-into-list (list alist)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5292 ;; 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
5293 ;; Return new list.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5294 (let (rtn tmp)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5295 (while list
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5296 (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
5297 (symbolp (car list)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5298 (setq tmp (car list))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5299 (cond
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5300 ((assoc tmp alist)
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
5301 (setq list (append (nth 2 (assoc tmp alist)) (cdr list))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5302 (t
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5303 (error "Cannot treat symbol %s in reftex-label-alist"
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5304 (symbol-name tmp)))))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5305 (push (pop list) rtn))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5306 (nreverse rtn)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5307
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5308 (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
5309 ;; 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
5310 ;; Elements of KEEP-LIST are not removed even if duplicate.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5311 (let (new elm)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5312 (while alist
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5313 (setq elm (pop alist))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5314 (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
5315 (not (assoc (car elm) new)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5316 (push elm new)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5317 (nreverse new)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5318
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5319 (defun reftex-use-fonts ()
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
5320 ;; Return t if we can and want to use fonts.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5321 (and window-system
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5322 reftex-use-fonts
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5323 (featurep 'font-lock)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5324
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5325 (defun reftex-refontify ()
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5326 ;; 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
5327 (and (reftex-use-fonts)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5328 (or (eq t reftex-refontify-context)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5329 (and (eq 1 reftex-refontify-context)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5330 (or (featurep 'x-symbol))))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5331
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5332 (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
5333 ;; Fontify the `*RefTeX Select*' buffer
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5334 (cond
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5335 ((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
5336 ;; 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
5337 (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
5338 '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
5339 (let ((major-mode 'latex-mode))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5340 (font-lock-mode 1)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5341 ((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
5342 ;; 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
5343 ;; 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
5344 (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
5345 (let ((major-mode 'latex-mode)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5346 (font-lock-defaults-computed nil))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5347 (font-lock-set-defaults-1)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5348 (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
5349 (t
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5350 ;; Oops?
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5351 (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
5352
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5353 (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
5354 ;; 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
5355 (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
5356 'font-lock-default-fontify-region
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5357 'font-lock-fontify-region))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5358 beg1 end1)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5359 (goto-char beg)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5360 (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
5361 (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
5362 (funcall func beg1 end1 nil)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5363 (goto-char end1))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5364
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
5365 ;; 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
5366 ;; the overlay library, available in version 19.15
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5367 (and (not (fboundp 'make-overlay))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5368 (condition-case nil
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5369 (require 'overlay)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5370 (error
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5371 (error "RefTeX needs overlay emulation (available in XEmacs 19.15)"))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5372
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5373 ;; We keep a vector with several different overlays to do our highlighting.
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
5374 (defvar reftex-highlight-overlays [nil nil nil])
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5375
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5376 ;; Initialize the overlays
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5377 (aset reftex-highlight-overlays 0 (make-overlay 1 1))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5378 (overlay-put (aref reftex-highlight-overlays 0) 'face 'highlight)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5379 (aset reftex-highlight-overlays 1 (make-overlay 1 1))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5380 (overlay-put (aref reftex-highlight-overlays 1) 'face 'highlight)
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
5381 (aset reftex-highlight-overlays 2 (make-overlay 1 1))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5382 (overlay-put (aref reftex-highlight-overlays 2) 'face
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5383 (if (string-match "XEmacs" emacs-version) 'zmacs-region 'region))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5384
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5385 ;; Two functions for activating and deactivation highlight overlays
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5386 (defun reftex-highlight (index begin end &optional buffer)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5387 "Highlight a region with overlay INDEX."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5388 (move-overlay (aref reftex-highlight-overlays index)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5389 begin end (or buffer (current-buffer))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5390 (defun reftex-unhighlight (index)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5391 "Detach overlay INDEX."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5392 (delete-overlay (aref reftex-highlight-overlays index)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5393
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5394 (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
5395 ;; Function used in pre-command-hook to remove highlights.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5396 (remove-hook 'pre-command-hook 'reftex-highlight-shall-die)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5397 (reftex-unhighlight 0))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5398
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5399 ;;; ---------------------------------------------------------------------------
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5400 ;;;
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5401 ;;; Functions to compile the tables, reset the mode etc.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5402
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5403 (defun reftex-reset-mode ()
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
5404 "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
5405 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
5406 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
5407 these variables."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5408 (interactive)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5409
18219
aaeaae005e98 Updated documentation at several points in the file.
Richard M. Stallman <rms@gnu.org>
parents: 18123
diff changeset
5410 ;; Record that we have done this
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5411 (setq reftex-tables-dirty nil)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5412 (setq reftex-memory
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5413 (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
5414 reftex-default-label-alist-entries))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5415
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5416 ;; Reset the file search path variables
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5417 (put 'reftex-tex-path 'status nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5418 (put 'reftex-bib-path 'status nil)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5419
18219
aaeaae005e98 Updated documentation at several points in the file.
Richard M. Stallman <rms@gnu.org>
parents: 18123
diff changeset
5420 ;; 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
5421 ;; 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
5422 (save-excursion
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5423 (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
5424 "*Duplicate Labels*" "*toc*" "*RefTeX-scratch*"))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5425 buf)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5426 (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
5427 (if (get-buffer buf)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5428 (kill-buffer buf))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5429 (reftex-erase-all-selection-buffers))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5430
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5431 ;; 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
5432 (reftex-reset-scanning-information)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
5433
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5434 ;; 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
5435 (reftex-plug-into-AUCTeX)
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
5436
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5437 (message "updating internal tables...")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5438 (reftex-compute-ref-cite-tables)
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
5439 (message "updating internal tables... done"))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5440
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5441 (defun reftex-reset-scanning-information ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5442 "Reset the symbols containing information from buffer scanning.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5443 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
5444 (if (string= reftex-last-toc-master (reftex-TeX-master-file))
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
5445 (reftex-empty-toc-buffer))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5446 (let ((symlist reftex-multifile-symbols)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5447 symbol)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5448 (while symlist
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5449 (setq symbol (car symlist)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5450 symlist (cdr symlist))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5451 (if (and (symbolp (symbol-value symbol))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5452 (not (null (symbol-value symbol))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5453 (set (symbol-value symbol) nil)))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5454
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5455 (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
5456 ;; 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
5457 (mapcar (function
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5458 (lambda (type)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5459 (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
5460 reftex-typekey-list))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5461
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5462 (defun reftex-compute-ref-cite-tables ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5463 ;; Update ref and cite tables
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5464
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5465 ;; Update AUCTeX style information
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5466 (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
5467 (condition-case nil (TeX-update-style) (error nil)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5468
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5469 ;; Compile information in reftex-label-alist
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5470 (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
5471 (append
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5472 reftex-label-alist
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5473 reftex-label-alist-external-add-ons
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5474 reftex-default-label-alist-entries)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5475 reftex-label-alist-builtin)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5476 '(nil)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5477 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
5478 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
5479 nargs nlabel opt-args cell sum i words-are-re)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5480
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5481 (setq reftex-words-to-typekey-alist nil
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5482 reftex-typekey-list nil
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5483 reftex-typekey-to-format-alist nil
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5484 reftex-typekey-to-prefix-alist nil
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5485 reftex-env-or-mac-alist nil
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5486 reftex-label-env-list nil
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5487 reftex-label-mac-list nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5488 (while tmp
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5489 (catch 'next-entry
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5490 (setq entry (car tmp)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5491 env-or-mac (car entry)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5492 entry (cdr entry)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5493 tmp (cdr tmp))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5494 (if (null env-or-mac)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5495 (setq env-or-mac ""))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5496 (if (stringp (car entry))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5497 ;; 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
5498 ;; 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
5499 (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
5500 (cons (concat (car entry) ":")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5501 (cdr entry)))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5502 (setq typekeychar (nth 0 entry)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5503 typekey (char-to-string typekeychar)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5504 prefix (nth 1 entry)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5505 fmt (nth 2 entry)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5506 context (nth 3 entry)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5507 wordlist (nth 4 entry))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5508 (if (stringp wordlist)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5509 ;; 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
5510 (setq wordlist (nthcdr 4 entry)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5511
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5512 (if (and (stringp fmt)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5513 (string-match "@" fmt))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5514 ;; 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
5515 (setq fmt (split-string fmt "@+"))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5516 (setq fmt (list "\\label{%s}" fmt)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5517 (setq labelfmt (car fmt)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5518 reffmt (nth 1 fmt))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5519 (if typekey
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5520 (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
5521 (if (and typekey prefix
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5522 (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
5523 (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
5524 (cons typekey prefix)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5525 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5526 ((string-match "\\`\\\\" env-or-mac)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5527 ;; It's a macro
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5528 (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
5529 (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
5530 nargs (second result)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5531 nlabel (third result)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5532 opt-args (fourth result))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5533 (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
5534 (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
5535 (t
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5536 (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
5537 (cond ((string= env-or-mac "any"))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5538 ((string= env-or-mac ""))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5539 ((string= env-or-mac "section"))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5540 (t
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5541 (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
5542 ;; Translate some special context cases
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5543 (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
5544 (setq context
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5545 (format
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5546 (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
5547 (regexp-quote env-or-mac))))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5548 (and reffmt
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5549 (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
5550 (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
5551 (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
5552 (not (string= env-or-mac ""))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5553 (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
5554 (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
5555 nargs nlabel opt-args)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5556 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
5557 (if (eq (car wordlist) 'regexp)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5558 (setq wordlist (cdr wordlist)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5559 words-are-re t)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5560 (setq words-are-re nil))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5561 (while (and (setq word (pop wordlist))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5562 (stringp word))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5563 (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
5564 (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
5565 (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
5566 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5567 ((string= "" env-or-mac) nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5568 ((setq cell (assoc typekey qh-list))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5569 (push env-or-mac (cdr cell)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5570 (t
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5571 (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
5572
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5573 (setq qh-list
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5574 (sort qh-list (function
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5575 (lambda (x1 x2) (string< (car x1) (car x2))))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5576 (setq reftex-typekey-to-prefix-alist
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5577 (nreverse reftex-typekey-to-prefix-alist))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5578 (setq reftex-type-query-prompt
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5579 (concat "Label type: "
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5580 (mapconcat (function (lambda(x) (format "[%s]" (car x))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5581 qh-list " ")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5582 " (?=Help)"))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5583 (setq reftex-type-query-help
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5584 (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
5585 (mapconcat
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5586 (function
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5587 (lambda(x)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5588 (setq sum 0)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5589 (format " [%s] %s"
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5590 (car x)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5591 (mapconcat
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5592 (lambda(x)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5593 (setq sum (+ sum (length x)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5594 (if (< sum 60)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5595 x
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5596 (setq sum 0)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5597 (concat "\n " x)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5598 (cdr x) " "))))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5599 qh-list "\n")))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5600
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5601 ;; 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
5602 (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
5603 (mapcar
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5604 (lambda (x)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5605 (setq word (car x)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5606 typekey (cdr x)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5607 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
5608 (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
5609 (setq i 0)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5610 (while (and (< i 10)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5611 (< i (length fmt))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5612 (not (member (aref fmt i) '(?%))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5613 (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
5614 (substring fmt 0 (1+ i)))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5615 (incf i))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5616 (cons (concat word "\\)\\=") typekey))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5617 (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
5618
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5619 ;; Calculate the regular expressions
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5620 (let ((label-re "\\\\label{\\([^}]*\\)}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5621 (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
5622 (section-re
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5623 (concat "\\(\\`\\|[\n\r]\\)[ \t]*\\\\\\("
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5624 (mapconcat 'car reftex-section-levels "\\|")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5625 "\\)\\*?\\(\\[[^]]*\\]\\)?{"))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5626 (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
5627 (macro-re
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5628 (if macros-with-labels
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5629 (concat "\\("
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5630 (mapconcat 'regexp-quote macros-with-labels "\\|")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5631 "\\)[[{]")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5632 ""))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5633 (find-label-re-format
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5634 (concat "\\("
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5635 (mapconcat 'regexp-quote (append '("\\label")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5636 macros-with-labels) "\\|")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5637 "\\)\\([[{][^]}]*[]}]\\)*[[{]\\(%s\\)[]}]")))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5638 (setq reftex-section-regexp section-re
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5639 reftex-section-or-include-regexp
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5640 (concat section-re "\\|" include-re)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5641 reftex-everything-regexp
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5642 (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
5643 "\\|" appendix-re
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5644 (if macros-with-labels "\\|" "") macro-re)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5645 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
5646 reftex-find-label-regexp-format2
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5647 "\\([]} \t\n\r]\\)\\([[{]\\)\\(%s\\)[]}]"))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5648
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5649 ;;; Keybindings --------------------------------------------------------------
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5650
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5651 (define-key reftex-mode-map "\C-c=" 'reftex-toc)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5652 (define-key reftex-mode-map "\C-c(" 'reftex-label)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5653 (define-key reftex-mode-map "\C-c)" 'reftex-reference)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5654 (define-key reftex-mode-map "\C-c[" 'reftex-citation)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5655 (define-key reftex-mode-map "\C-c&" 'reftex-view-crossref)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5656
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5657 ;; If the user requests so, she can have a few more bindings:
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5658 (cond
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5659 (reftex-extra-bindings
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5660 (define-key reftex-mode-map "\C-ct" 'reftex-toc)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5661 (define-key reftex-mode-map "\C-cl" 'reftex-label)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5662 (define-key reftex-mode-map "\C-cr" 'reftex-reference)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5663 (define-key reftex-mode-map "\C-cc" 'reftex-citation)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5664 (define-key reftex-mode-map "\C-cv" 'reftex-view-crossref)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5665 (define-key reftex-mode-map "\C-cg" 'reftex-grep-document)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5666 (define-key reftex-mode-map "\C-cs" 'reftex-search-document)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5667
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5668 ;; Selection Keymaps
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5669 (let ((map (make-sparse-keymap)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5670 ; First, the common stuff
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5671 (substitute-key-definition
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5672 '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
5673 (substitute-key-definition
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5674 '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
5675 (substitute-key-definition
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5676 'scroll-up 'reftex-select-scroll-up map global-map)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5677 (substitute-key-definition
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5678 'scroll-down 'reftex-select-scroll-down map global-map)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5679 (substitute-key-definition
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5680 'scroll-other-window 'reftex-select-scroll-other-window map global-map)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5681 (substitute-key-definition
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5682 'scroll-other-window-down 'reftex-select-scroll-other-window-down map global-map)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5683 (substitute-key-definition
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5684 'beginning-of-buffer 'beginning-of-buffer map global-map)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5685 (substitute-key-definition
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5686 'end-of-buffer 'end-of-buffer map global-map)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5687 (substitute-key-definition
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5688 'keyboard-quit 'keyboard-quit map global-map)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5689 (substitute-key-definition
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5690 '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
5691 (substitute-key-definition
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5692 'delete-other-windows 'delete-other-windows map global-map)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5693 (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
5694 (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
5695 (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
5696 (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
5697 (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
5698 (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
5699 (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
5700 (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
5701 (define-key map "\C-s" 'reftex-select-search-forward)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5702 (define-key map "\C-r" 'reftex-select-search-backward)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5703 (define-key map "e" 'reftex-select-recursive-edit)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5704 (define-key map "q" 'reftex-select-quit)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5705 (define-key map "?" 'reftex-select-help)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5706
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5707 (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
5708 (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
5709
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5710 ;; Now the rest
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5711
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5712 (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
5713 (define-key reftex-select-label-map (vector (list key))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5714 (list 'lambda '() '(interactive) (list 'throw '(quote exit) key))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5715 (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
5716 (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
5717 (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
5718 (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
5719 (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
5720 (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
5721
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5722 (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
5723 (define-key reftex-select-bib-map (vector (list key))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5724 (list 'lambda '() '(interactive) (list 'throw '(quote exit) key))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5725 (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
5726 (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
5727
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5728 ;; Table of Contents map
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5729 (let ((map reftex-toc-map))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5730 (define-key map [(mouse-2)] 'reftex-toc-mouse-goto-line-and-hide); Emacs
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5731 (define-key map [(button2)] 'reftex-toc-mouse-goto-line-and-hide); XEmacs
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5732 (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
5733 (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
5734 (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
5735 (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
5736 (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
5737 (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
5738 (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
5739 (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
5740 (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
5741 (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
5742 (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
5743 (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
5744 (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
5745 (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
5746 (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
5747 (define-key map "-" 'negative-argument))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5748
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5749 ;;; Menus --------------------------------------------------------------------
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5750
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5751 ;; 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
5752
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5753 (require 'easymenu)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5754
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5755 (easy-menu-define
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5756 reftex-mode-menu reftex-mode-map
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5757 "Menu used in RefTeX mode"
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5758 `("Ref"
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
5759 ["Table of Contents" reftex-toc t]
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5760 "----"
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
5761 ["\\label" reftex-label t]
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
5762 ["\\ref" reftex-reference t]
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
5763 ["\\cite" reftex-citation t]
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5764 ["View Crossref" reftex-view-crossref t]
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5765 "----"
20177
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
5766 ("Parse Document"
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
5767 ["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
5768 ["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
5769 ["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
5770 (> (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
5771 ["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
5772 "----"
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
5773 ["Enable Partial Scans"
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
5774 (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
5775 :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
5776 ["Auto-Save Parse Info"
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
5777 (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
5778 :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
5779 "---"
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
5780 ["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
5781 ("Global Actions"
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5782 ["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
5783 ["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
5784 ["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
5785 "----"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5786 ["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
5787 "----"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5788 ["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
5789 ["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
5790 ;;;["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
5791 "---"
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5792 ["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
5793 "---"
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5794 ("Reference Options"
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5795 "Varioref Setting"
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5796 ["Use `\\vref' by Default"
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5797 (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
5798 :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
5799 "---"
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5800 "Selection Buffers"
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5801 ["Use Multiple Buffers"
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5802 (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
5803 (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
5804 :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
5805 ["Auto Update Buffers"
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5806 (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
5807 (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
5808 :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
5809 ("Citation Options"
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
5810 "Citation Style"
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5811 ,@(mapcar
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5812 (function
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5813 (lambda (x)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5814 (vector
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5815 (capitalize (symbol-name (car x)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5816 (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
5817 ':style 'radio ':selected
20177
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
5818 (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
5819 reftex-cite-format-builtin)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5820 "----"
20177
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
5821 "Bibinfo in Comments"
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
5822 ["Attach Comments"
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
5823 (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
5824 :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
5825 "---"
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
5826 "Sort Database Matches"
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
5827 ["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
5828 :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
5829 ["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
5830 :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
5831 ["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
5832 :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
5833 ["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
5834 :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
5835 ("Customize"
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5836 ["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
5837 "---"
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5838 ["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
5839 (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
5840 "----"
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5841 ("Documentation"
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5842 ["Info" reftex-info t]
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5843 ["Commentary" reftex-show-commentary t])))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5844
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5845 ;;; Run Hook ------------------------------------------------------------------
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5846
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5847 (run-hooks 'reftex-load-hook)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5848
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5849 ;;; That's it! ----------------------------------------------------------------
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5850
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5851 (provide 'reftex)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5852
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5853 ; Make sure tables are compiled
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5854 (message "updating internal tables...")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5855 (reftex-compute-ref-cite-tables)
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
5856 (message "updating internal tables...done")
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5857 (setq reftex-tables-dirty nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5858
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5859 ;;;============================================================================
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5860
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
5861 ;;; reftex.el ends here
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5862