annotate lisp/textmodes/reftex-index.el @ 112402:a102f5772eaa

Merge from mainline.
author Paul Eggert <eggert@cs.ucla.edu>
date Fri, 21 Jan 2011 12:27:07 -0800
parents 6e613fbf73d7
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
38422
7a94f1c588c4 Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 37998
diff changeset
1 ;;; reftex-index.el --- index support with RefTeX
74509
f7702c5f335d Update copyright years.
Glenn Morris <rgm@gnu.org>
parents: 69228
diff changeset
2
f7702c5f335d Update copyright years.
Glenn Morris <rgm@gnu.org>
parents: 69228
diff changeset
3 ;; Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
112213
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
4 ;; 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
27035
083669ed376a Supply licensing info.
Richard M. Stallman <rms@gnu.org>
parents: 26910
diff changeset
5
46612
7522419c4db0 Updated to reftex 4.17
Carsten Dominik <dominik@science.uva.nl>
parents: 41784
diff changeset
6 ;; Author: Carsten Dominik <dominik@science.uva.nl>
76672
690423f53b08 * textmodes/reftex.el: Add maintainer address.
David Kastrup <dak@gnu.org>
parents: 75347
diff changeset
7 ;; Maintainer: auctex-devel@gnu.org
69094
bfd5c5e60410 Version number change only
Carsten Dominik <dominik@science.uva.nl>
parents: 68648
diff changeset
8 ;; Version: 4.31
110015
280c8ae2476d Add "Package:" file headers to denote built-in packages.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
9 ;; Package: reftex
27035
083669ed376a Supply licensing info.
Richard M. Stallman <rms@gnu.org>
parents: 26910
diff changeset
10
083669ed376a Supply licensing info.
Richard M. Stallman <rms@gnu.org>
parents: 26910
diff changeset
11 ;; This file is part of GNU Emacs.
083669ed376a Supply licensing info.
Richard M. Stallman <rms@gnu.org>
parents: 26910
diff changeset
12
94670
f4a69fedbd46 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
13 ;; GNU Emacs is free software: you can redistribute it and/or modify
27035
083669ed376a Supply licensing info.
Richard M. Stallman <rms@gnu.org>
parents: 26910
diff changeset
14 ;; it under the terms of the GNU General Public License as published by
94670
f4a69fedbd46 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
15 ;; the Free Software Foundation, either version 3 of the License, or
f4a69fedbd46 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
16 ;; (at your option) any later version.
27035
083669ed376a Supply licensing info.
Richard M. Stallman <rms@gnu.org>
parents: 26910
diff changeset
17
083669ed376a Supply licensing info.
Richard M. Stallman <rms@gnu.org>
parents: 26910
diff changeset
18 ;; GNU Emacs is distributed in the hope that it will be useful,
083669ed376a Supply licensing info.
Richard M. Stallman <rms@gnu.org>
parents: 26910
diff changeset
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
083669ed376a Supply licensing info.
Richard M. Stallman <rms@gnu.org>
parents: 26910
diff changeset
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
083669ed376a Supply licensing info.
Richard M. Stallman <rms@gnu.org>
parents: 26910
diff changeset
21 ;; GNU General Public License for more details.
083669ed376a Supply licensing info.
Richard M. Stallman <rms@gnu.org>
parents: 26910
diff changeset
22
083669ed376a Supply licensing info.
Richard M. Stallman <rms@gnu.org>
parents: 26910
diff changeset
23 ;; You should have received a copy of the GNU General Public License
94670
f4a69fedbd46 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
24 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
25
38422
7a94f1c588c4 Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 37998
diff changeset
26 ;;; Commentary:
7a94f1c588c4 Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 37998
diff changeset
27
7a94f1c588c4 Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 37998
diff changeset
28 ;;; Code:
7a94f1c588c4 Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 37998
diff changeset
29
26910
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
30 (eval-when-compile (require 'cl))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
31 (provide 'reftex-index)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
32 (require 'reftex)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
33 ;;;
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
34
47050
904fd28be439 Update to RefTeX 4.19
Carsten Dominik <dominik@science.uva.nl>
parents: 46683
diff changeset
35 ;; START remove for XEmacs release
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
36 (defvar mark-active)
25802
4c4fabd16782 Version number change
Carsten Dominik <dominik@science.uva.nl>
parents: 25280
diff changeset
37 (defvar transient-mark-mode)
65548
253cad16882d Little fixes to remove compiler warnings
Carsten Dominik <dominik@science.uva.nl>
parents: 65269
diff changeset
38 (defvar TeX-master)
47050
904fd28be439 Update to RefTeX 4.19
Carsten Dominik <dominik@science.uva.nl>
parents: 46683
diff changeset
39 ;; END remove for XEmacs release
86851
321f32eb4bf5 * erc.el (open-ssl-stream, open-tls-stream, erc-network-name):
Dan Nicolaescu <dann@ics.uci.edu>
parents: 85777
diff changeset
40
321f32eb4bf5 * erc.el (open-ssl-stream, open-tls-stream, erc-network-name):
Dan Nicolaescu <dann@ics.uci.edu>
parents: 85777
diff changeset
41 (declare-function texmathp "ext:texmathp" ())
321f32eb4bf5 * erc.el (open-ssl-stream, open-tls-stream, erc-network-name):
Dan Nicolaescu <dann@ics.uci.edu>
parents: 85777
diff changeset
42
26910
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
43 (defun reftex-index-selection-or-word (&optional arg phrase)
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
44 "Put selection or the word near point into the default index macro.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
45 This uses the information in `reftex-index-default-macro' to make an index
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
46 entry. The phrase indexed is the current selection or the word near point.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
47 When called with one `C-u' prefix, let the user have a chance to edit the
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
48 index entry. When called with 2 `C-u' as prefix, also ask for the index
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
49 macro and other stuff.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
50 When called inside TeX math mode as determined by the `texmathp.el' library
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
51 which is part of AUCTeX, the string is first processed with the
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
52 `reftex-index-math-format', which see."
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
53 (interactive "P")
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
54 (let* ((use-default (not (equal arg '(16)))) ; check for double prefix
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
55 ;; check if we have an active selection
85777
2ca0af23d79d * emulation/edt.el (edt-emacs19-p, edt-x-emacs19-p)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78225
diff changeset
56 (active (if (featurep 'xemacs)
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
57 (and zmacs-regions (region-exists-p)) ; XEmacs
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
58 (and transient-mark-mode mark-active))) ; Emacs
99383
a5f24b6e48ef * international/mule-cmds.el (toggle-enable-multibyte-characters)
Juanma Barranquero <lekktu@gmail.com>
parents: 94670
diff changeset
59 (beg (if active
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
60 (region-beginning)
99383
a5f24b6e48ef * international/mule-cmds.el (toggle-enable-multibyte-characters)
Juanma Barranquero <lekktu@gmail.com>
parents: 94670
diff changeset
61 (save-excursion
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
62 (skip-syntax-backward "w\\") (point))))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
63 (end (if active
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
64 (region-end)
99383
a5f24b6e48ef * international/mule-cmds.el (toggle-enable-multibyte-characters)
Juanma Barranquero <lekktu@gmail.com>
parents: 94670
diff changeset
65 (save-excursion
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
66 (skip-syntax-forward "w\\") (point))))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
67 (sel (buffer-substring beg end))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
68 (mathp (condition-case nil (texmathp) (error nil)))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
69 (current-prefix-arg nil) ; we want to call reftex-index without prefix.
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
70 key def-char def-tag full-entry)
26910
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
71
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
72 (if phrase
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
73 (progn
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
74 (reftex-index-visit-phrases-buffer)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
75 (reftex-index-new-phrase sel))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
76
26910
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
77 (if (equal sel "")
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
78 ;; Nothing selected, no word, so use full reftex-index command
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
79 (reftex-index)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
80 ;; OK, we have something to index here.
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
81 ;; Add the dollars when necessary
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
82 (setq key (if mathp
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
83 (format reftex-index-math-format sel)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
84 sel))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
85 ;; Get info from `reftex-index-default-macro'
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
86 (setq def-char (if use-default (car reftex-index-default-macro)))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
87 (setq def-tag (if use-default (nth 1 reftex-index-default-macro)))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
88 ;; Does the user want to edit the entry?
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
89 (setq full-entry (if arg
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
90 (reftex-index-complete-key
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
91 def-tag nil (cons key 0))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
92 key))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
93 ;; Delete what is in the buffer and make the index entry
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
94 (delete-region beg end)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
95 (reftex-index def-char full-entry def-tag sel)))))
99383
a5f24b6e48ef * international/mule-cmds.el (toggle-enable-multibyte-characters)
Juanma Barranquero <lekktu@gmail.com>
parents: 94670
diff changeset
96
26910
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
97 (defun reftex-index (&optional char key tag sel no-insert)
99383
a5f24b6e48ef * international/mule-cmds.el (toggle-enable-multibyte-characters)
Juanma Barranquero <lekktu@gmail.com>
parents: 94670
diff changeset
98 "Query for an index macro and insert it along with its arguments.
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
99 The index macros available are those defined in `reftex-index-macro' or
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
100 by a call to `reftex-add-index-macros', typically from an AUCTeX style file.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
101 RefteX provides completion for the index tag and the index key, and
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
102 will prompt for other arguments."
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
103
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
104 (interactive)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
105
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
106 ;; Ensure access to scanning info
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
107 (reftex-ensure-index-support t)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
108 (reftex-access-scan-info current-prefix-arg)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
109
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
110 ;; Find out which macro we are going to use
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
111 (let* ((char (or char
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
112 (reftex-select-with-char reftex-query-index-macro-prompt
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
113 reftex-query-index-macro-help)))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
114 (macro (nth 1 (assoc char reftex-key-to-index-macro-alist)))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
115 (entry (or (assoc macro reftex-index-macro-alist)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
116 (error "No index macro associated with %c" char)))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
117 (ntag (nth 1 entry))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
118 (tag (or tag (nth 1 entry)))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
119 (nargs (nth 4 entry))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
120 (nindex (nth 5 entry))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
121 (opt-args (nth 6 entry))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
122 (repeat (nth 7 entry))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
123 opt tag1 value)
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
124
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
125 ;; Get the supported arguments
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
126 (if (stringp tag)
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
127 (setq tag1 tag)
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
128 (setq tag1 (or (reftex-index-complete-tag tag opt-args) "")))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
129 (setq key (or key
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
130 (reftex-index-complete-key
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
131 (if (string= tag1 "") "idx" tag1)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
132 (member nindex opt-args))))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
133
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
134 ;; Insert the macro and ask for any additional args
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
135 (insert macro)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
136 (loop for i from 1 to nargs do
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
137 (setq opt (member i opt-args)
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
138 value (cond ((= nindex i) key)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
139 ((equal ntag i) tag1)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
140 (t (read-string (concat "Macro arg nr. "
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
141 (int-to-string i)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
142 (if opt " (optional)" "")
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
143 ": ")))))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
144 (unless (and opt (string= value ""))
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
145 (insert (if opt "[" "{") value (if opt "]" "}"))))
26910
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
146 (and repeat (stringp sel) (insert sel))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
147 (and key reftex-plug-into-AUCTeX (fboundp 'LaTeX-add-index-entries)
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
148 (LaTeX-add-index-entries key))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
149 (reftex-index-update-taglist tag1)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
150 (reftex-notice-new)))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
151
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
152 (defun reftex-default-index ()
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
153 (cond ((null reftex-index-default-tag) nil)
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
154 ((stringp reftex-index-default-tag) reftex-index-default-tag)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
155 (t (or (get reftex-docstruct-symbol 'default-index-tag)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
156 "idx"))))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
157
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
158 (defun reftex-update-default-index (tag &optional tag-list)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
159 (if (and (not (equal tag ""))
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
160 (stringp tag)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
161 (eq reftex-index-default-tag 'last)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
162 (or (null tag-list)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
163 (member tag tag-list)))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
164 (put reftex-docstruct-symbol 'default-index-tag tag)))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
165
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
166 (defun reftex-index-complete-tag (&optional itag opt-args)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
167 ;; Ask the user for a tag, completing on known tags.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
168 ;; ITAG is the argument number which contains the tag.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
169 ;; OPT-ARGS is a list of optional argument indices, as given by
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
170 ;; `reftex-parse-args'.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
171 (let* ((opt (and (integerp itag) (member itag opt-args)))
65680
ed770a0a7846 2005-09-24 Emilio C. Lopes <eclig@gmx.net>
Romain Francoise <romain@orebokech.com>
parents: 65638
diff changeset
172 (index-tags (cdr (assq 'index-tags
ed770a0a7846 2005-09-24 Emilio C. Lopes <eclig@gmx.net>
Romain Francoise <romain@orebokech.com>
parents: 65638
diff changeset
173 (symbol-value reftex-docstruct-symbol))))
ed770a0a7846 2005-09-24 Emilio C. Lopes <eclig@gmx.net>
Romain Francoise <romain@orebokech.com>
parents: 65638
diff changeset
174 (default (reftex-default-index))
ed770a0a7846 2005-09-24 Emilio C. Lopes <eclig@gmx.net>
Romain Francoise <romain@orebokech.com>
parents: 65638
diff changeset
175 (prompt (concat "Index tag"
ed770a0a7846 2005-09-24 Emilio C. Lopes <eclig@gmx.net>
Romain Francoise <romain@orebokech.com>
parents: 65638
diff changeset
176 (if (or opt default)
ed770a0a7846 2005-09-24 Emilio C. Lopes <eclig@gmx.net>
Romain Francoise <romain@orebokech.com>
parents: 65638
diff changeset
177 (format " (%s): "
ed770a0a7846 2005-09-24 Emilio C. Lopes <eclig@gmx.net>
Romain Francoise <romain@orebokech.com>
parents: 65638
diff changeset
178 (concat
ed770a0a7846 2005-09-24 Emilio C. Lopes <eclig@gmx.net>
Romain Francoise <romain@orebokech.com>
parents: 65638
diff changeset
179 (if opt "optional" "")
ed770a0a7846 2005-09-24 Emilio C. Lopes <eclig@gmx.net>
Romain Francoise <romain@orebokech.com>
parents: 65638
diff changeset
180 (if default
ed770a0a7846 2005-09-24 Emilio C. Lopes <eclig@gmx.net>
Romain Francoise <romain@orebokech.com>
parents: 65638
diff changeset
181 (concat (if opt ", " "")
ed770a0a7846 2005-09-24 Emilio C. Lopes <eclig@gmx.net>
Romain Francoise <romain@orebokech.com>
parents: 65638
diff changeset
182 (format "default %s" default))
ed770a0a7846 2005-09-24 Emilio C. Lopes <eclig@gmx.net>
Romain Francoise <romain@orebokech.com>
parents: 65638
diff changeset
183 "")))
ed770a0a7846 2005-09-24 Emilio C. Lopes <eclig@gmx.net>
Romain Francoise <romain@orebokech.com>
parents: 65638
diff changeset
184 ": ")))
ed770a0a7846 2005-09-24 Emilio C. Lopes <eclig@gmx.net>
Romain Francoise <romain@orebokech.com>
parents: 65638
diff changeset
185 (tag (completing-read prompt (mapcar 'list index-tags))))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
186 (if (and default (equal tag "")) (setq tag default))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
187 (reftex-update-default-index tag)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
188 tag))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
189
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
190 (defun reftex-index-select-tag ()
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
191 ;; Have the user select an index tag.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
192 ;; FIXME: should we cache tag-alist, prompt and help?
99383
a5f24b6e48ef * international/mule-cmds.el (toggle-enable-multibyte-characters)
Juanma Barranquero <lekktu@gmail.com>
parents: 94670
diff changeset
193 (let* ((index-tags (cdr (assoc 'index-tags
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
194 (symbol-value reftex-docstruct-symbol))))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
195 (default (reftex-default-index)))
99383
a5f24b6e48ef * international/mule-cmds.el (toggle-enable-multibyte-characters)
Juanma Barranquero <lekktu@gmail.com>
parents: 94670
diff changeset
196 (cond
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
197 ((null index-tags)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
198 (error "No index tags available"))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
199
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
200 ((= (length index-tags) 1)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
201 ;; Just one index, use it
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
202 (car index-tags))
99383
a5f24b6e48ef * international/mule-cmds.el (toggle-enable-multibyte-characters)
Juanma Barranquero <lekktu@gmail.com>
parents: 94670
diff changeset
203
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
204 ((> (length index-tags) 1)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
205 ;; Several indices, ask.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
206 (let* ((tags (copy-sequence index-tags))
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
207 (cnt 0)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
208 tag-alist i val len tag prompt help rpl)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
209 ;; Move idx and glo up in the list to ensure ?i and ?g shortcuts
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
210 (if (member "glo" tags)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
211 (setq tags (cons "glo" (delete "glo" tags))))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
212 (if (member "idx" tags)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
213 (setq tags (cons "idx" (delete "idx" tags))))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
214 ;; Find unique shortcuts for each index.
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
215 (while (setq tag (pop tags))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
216 (setq len (length tag)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
217 i -1
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
218 val nil)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
219 (catch 'exit
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
220 (while (and (< (incf i) len) (null val))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
221 (unless (assq (aref tag i) tag-alist)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
222 (push (list (aref tag i)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
223 tag
99383
a5f24b6e48ef * international/mule-cmds.el (toggle-enable-multibyte-characters)
Juanma Barranquero <lekktu@gmail.com>
parents: 94670
diff changeset
224 (concat (substring tag 0 i)
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
225 "[" (substring tag i (incf i)) "]"
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
226 (substring tag i)))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
227 tag-alist)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
228 (throw 'exit t)))
99383
a5f24b6e48ef * international/mule-cmds.el (toggle-enable-multibyte-characters)
Juanma Barranquero <lekktu@gmail.com>
parents: 94670
diff changeset
229 (push (list (+ ?0 (incf cnt)) tag
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
230 (concat "[" (int-to-string cnt) "]:" tag))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
231 tag-alist)))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
232 (setq tag-alist (nreverse tag-alist))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
233 ;; Compute Prompt and Help strings
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
234 (setq prompt
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
235 (concat
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
236 (format "Select Index%s: "
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
237 (if default (format " (Default <%s>)" default) ""))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
238 (mapconcat (lambda(x) (nth 2 x)) tag-alist " ")))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
239 (setq help
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
240 (concat "Select an Index\n===============\n"
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
241 (if default
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
242 (format "[^M] %s (the default)\n" default)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
243 "")
99383
a5f24b6e48ef * international/mule-cmds.el (toggle-enable-multibyte-characters)
Juanma Barranquero <lekktu@gmail.com>
parents: 94670
diff changeset
244 (mapconcat (lambda(x)
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
245 (apply 'format "[%c] %s" x))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
246 tag-alist "\n")))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
247 ;; Query the user for an index-tag
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
248 (setq rpl (reftex-select-with-char prompt help 3 t))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
249 (message "")
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
250 (if (and default (equal rpl ?\C-m))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
251 default
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
252 (if (assq rpl tag-alist)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
253 (progn
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
254 (reftex-update-default-index (nth 1 (assq rpl tag-alist)))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
255 (nth 1 (assq rpl tag-alist)))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
256 (error "No index tag associated with %c" rpl)))))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
257 (t (error "This should not happen (reftex-index-select-tag)")))))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
258
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
259 (defun reftex-index-complete-key (&optional tag optional initial)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
260 ;; Read an index key, with completion.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
261 ;; Restrict completion table on index tag TAG.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
262 ;; OPTIONAL indicates if the arg is optional.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
263 (let* ((table (reftex-sublist-nth
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
264 (symbol-value reftex-docstruct-symbol) 6
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
265 (lambda(x) (and (eq (car x) 'index)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
266 (string= (nth 1 x) (or tag ""))))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
267 t))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
268 (prompt (concat "Index key" (if optional " (optional)" "") ": "))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
269 (key (completing-read prompt table nil nil initial)))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
270 key))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
271
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
272 (defun reftex-index-update-taglist (newtag)
99383
a5f24b6e48ef * international/mule-cmds.el (toggle-enable-multibyte-characters)
Juanma Barranquero <lekktu@gmail.com>
parents: 94670
diff changeset
273 ;; add NEWTAG to the list of available index tags.
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
274 (let ((cell (assoc 'index-tags (symbol-value reftex-docstruct-symbol))))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
275 (and newtag (cdr cell) (not (member newtag (cdr cell)))
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
276 (push newtag (cdr cell)))))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
277
112213
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
278 (defvar reftex-index-mode-map
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
279 (let ((map (make-sparse-keymap)))
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
280 ;; Index map
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
281 (define-key map (if (featurep 'xemacs) [(button2)] [(mouse-2)])
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
282 'reftex-index-mouse-goto-line-and-hide)
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
283 (define-key map [follow-link] 'mouse-face)
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
284
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
285 (substitute-key-definition
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
286 'next-line 'reftex-index-next map global-map)
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
287 (substitute-key-definition
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
288 'previous-line 'reftex-index-previous map global-map)
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
289
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
290 (loop for x in
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
291 '(("n" . reftex-index-next)
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
292 ("p" . reftex-index-previous)
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
293 ("?" . reftex-index-show-help)
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
294 (" " . reftex-index-view-entry)
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
295 ("\C-m" . reftex-index-goto-entry-and-hide)
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
296 ("\C-i" . reftex-index-goto-entry)
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
297 ("\C-k" . reftex-index-kill)
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
298 ("r" . reftex-index-rescan)
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
299 ("R" . reftex-index-Rescan)
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
300 ("g" . revert-buffer)
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
301 ("q" . reftex-index-quit)
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
302 ("k" . reftex-index-quit-and-kill)
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
303 ("f" . reftex-index-toggle-follow)
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
304 ("s" . reftex-index-switch-index-tag)
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
305 ("e" . reftex-index-edit)
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
306 ("^" . reftex-index-level-up)
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
307 ("_" . reftex-index-level-down)
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
308 ("}" . reftex-index-restrict-to-section)
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
309 ("{" . reftex-index-widen)
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
310 (">" . reftex-index-restriction-forward)
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
311 ("<" . reftex-index-restriction-backward)
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
312 ("(" . reftex-index-toggle-range-beginning)
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
313 (")" . reftex-index-toggle-range-end)
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
314 ("|" . reftex-index-edit-attribute)
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
315 ("@" . reftex-index-edit-visual)
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
316 ("*" . reftex-index-edit-key)
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
317 ("\C-c=". reftex-index-goto-toc)
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
318 ("c" . reftex-index-toggle-context))
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
319 do (define-key map (car x) (cdr x)))
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
320
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
321 (loop for key across "0123456789" do
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
322 (define-key map (vector (list key)) 'digit-argument))
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
323 (define-key map "-" 'negative-argument)
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
324
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
325 ;; The capital letters and the exclamation mark
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
326 (loop for key across (concat "!" reftex-index-section-letters) do
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
327 (define-key map (vector (list key))
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
328 (list 'lambda '() '(interactive)
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
329 (list 'reftex-index-goto-letter key))))
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
330
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
331 (easy-menu-define reftex-index-menu map
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
332 "Menu for Index buffer"
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
333 '("Index"
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
334 ["Goto section A-Z"
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
335 (message "To go to a section, just press any of: !%s"
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
336 reftex-index-section-letters) t]
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
337 ["Show Entry" reftex-index-view-entry t]
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
338 ["Go To Entry" reftex-index-goto-entry t]
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
339 ["Exit & Go To Entry" reftex-index-goto-entry-and-hide t]
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
340 ["Table of Contents" reftex-index-goto-toc t]
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
341 ["Quit" reftex-index-quit t]
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
342 "--"
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
343 ("Update"
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
344 ["Rebuilt *Index* Buffer" revert-buffer t]
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
345 "--"
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
346 ["Rescan One File" reftex-index-rescan reftex-enable-partial-scans]
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
347 ["Rescan Entire Document" reftex-index-Rescan t])
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
348 ("Restrict"
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
349 ["Restrict to section" reftex-index-restrict-to-section t]
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
350 ["Widen" reftex-index-widen reftex-index-restriction-indicator]
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
351 ["Next Section" reftex-index-restriction-forward
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
352 reftex-index-restriction-indicator]
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
353 ["Previous Section" reftex-index-restriction-backward
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
354 reftex-index-restriction-indicator])
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
355 ("Edit"
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
356 ["Edit Entry" reftex-index-edit t]
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
357 ["Edit Key" reftex-index-edit-key t]
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
358 ["Edit Attribute" reftex-index-edit-attribute t]
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
359 ["Edit Visual" reftex-index-edit-visual t]
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
360 "--"
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
361 ["Add Parentkey" reftex-index-level-down t]
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
362 ["Remove Parentkey " reftex-index-level-up t]
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
363 "--"
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
364 ["Make Start-of-Range" reftex-index-toggle-range-beginning t]
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
365 ["Make End-of-Range" reftex-index-toggle-range-end t]
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
366 "--"
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
367 ["Kill Entry" reftex-index-kill nil]
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
368 "--"
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
369 ["Undo" reftex-index-undo nil])
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
370 ("Options"
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
371 ["Context" reftex-index-toggle-context :style toggle
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
372 :selected reftex-index-include-context]
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
373 "--"
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
374 ["Follow Mode" reftex-index-toggle-follow :style toggle
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
375 :selected reftex-index-follow-mode])
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
376 "--"
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
377 ["Help" reftex-index-show-help t]))
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
378
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
379 map)
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
380 "Keymap used for *Index* buffers.")
112213
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
381 (define-obsolete-variable-alias
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
382 'reftex-index-map 'reftex-index-mode-map "24.1")
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
383
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
384 (defvar reftex-index-menu)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
385
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
386 (defvar reftex-last-index-file nil
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
387 "Stores the file name from which `reftex-display-index' was called.")
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
388 (defvar reftex-index-tag nil
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
389 "Stores the tag of the index in an index buffer.")
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
390
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
391 (defvar reftex-index-return-marker (make-marker)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
392 "Marker which makes it possible to return from index to old position.")
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
393
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
394 (defvar reftex-index-restriction-indicator nil)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
395 (defvar reftex-index-restriction-data nil)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
396
112213
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
397 (define-derived-mode reftex-index-mode fundamental-mode "RefTeX Index"
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
398 "Major mode for managing Index buffers for LaTeX files.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
399 This buffer was created with RefTeX.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
400 Press `?' for a summary of important key bindings, or check the menu.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
401
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
402 Here are all local bindings.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
403
112213
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
404 \\{reftex-index-mode-map}"
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
405 (set (make-local-variable 'revert-buffer-function) 'reftex-index-revert)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
406 (set (make-local-variable 'reftex-index-restriction-data) nil)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
407 (set (make-local-variable 'reftex-index-restriction-indicator) nil)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
408 (setq mode-line-format
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
409 (list "---- " 'mode-line-buffer-identification
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
410 " " 'global-mode-string
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
411 " R<" 'reftex-index-restriction-indicator ">"
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
412 " -%-"))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
413 (setq truncate-lines t)
46683
060f433ebf11 Updated to RefTeX 4.18
Carsten Dominik <dominik@science.uva.nl>
parents: 46612
diff changeset
414 (when (featurep 'xemacs)
060f433ebf11 Updated to RefTeX 4.18
Carsten Dominik <dominik@science.uva.nl>
parents: 46612
diff changeset
415 ;; XEmacs needs the call to make-local-hook
060f433ebf11 Updated to RefTeX 4.18
Carsten Dominik <dominik@science.uva.nl>
parents: 46612
diff changeset
416 (make-local-hook 'post-command-hook)
060f433ebf11 Updated to RefTeX 4.18
Carsten Dominik <dominik@science.uva.nl>
parents: 46612
diff changeset
417 (make-local-hook 'pre-command-hook))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
418 (make-local-variable 'reftex-last-follow-point)
112213
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
419 (easy-menu-add reftex-index-menu reftex-index-mode-map)
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
420 (add-hook 'post-command-hook 'reftex-index-post-command-hook nil t)
112213
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
421 (add-hook 'pre-command-hook 'reftex-index-pre-command-hook nil t))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
422
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
423 (defconst reftex-index-help
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
424 " AVAILABLE KEYS IN INDEX BUFFER
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
425 ==============================
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
426 ! A..Z Goto the section of entries starting with this letter.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
427 n / p next-entry / previous-entry
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
428 SPC / TAB Show/Goto the corresponding entry in the LaTeX document.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
429 RET Goto the entry and hide the *Index* window (also on mouse-2).
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
430 q / k Hide/Kill *Index* buffer.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
431 C-c = Switch to the TOC buffer.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
432 f / c Toggle follow mode / Toggle display of [c]ontext.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
433 g Refresh *Index* buffer.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
434 r / C-u r Reparse the LaTeX document / Reparse entire LaTeX document.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
435 s Switch to a different index (for documents with multiple indices).
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
436 e / C-k Edit/Kill the entry.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
437 * | @ Edit specific part of entry: [*]key [|]attribute [@]visual
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
438 With prefix: kill that part.
41301
f13ec83c07b9 Doc fix.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38422
diff changeset
439 \( ) Toggle entry's beginning/end of page range property.
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
440 _ ^ Add/Remove parent key (to make this item a subitem).
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
441 } / { Restrict Index to a single document section / Widen.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
442 < / > When restricted, move restriction to previous/next section.")
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
443
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
444 (defun reftex-index-show-entry (data &optional no-revisit)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
445 ;; Find an index entry associated with DATA and display it highlighted
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
446 ;; in another window. NO-REVISIT means we are not allowed to visit
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
447 ;; files for this.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
448 ;; Note: This function just looks for the nearest match of the
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
449 ;; context string and may fail if the entry moved and an identical
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
450 ;; entry is close to the old position. Frequent rescans make this
99383
a5f24b6e48ef * international/mule-cmds.el (toggle-enable-multibyte-characters)
Juanma Barranquero <lekktu@gmail.com>
parents: 94670
diff changeset
451 ;; safer.
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
452 (let* ((file (nth 3 data))
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
453 (literal (nth 2 data))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
454 (pos (nth 4 data))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
455 (re (regexp-quote literal))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
456 (match
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
457 (cond
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
458 ((or (not no-revisit)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
459 (reftex-get-buffer-visiting file))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
460 (switch-to-buffer-other-window
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
461 (reftex-get-file-buffer-force file nil))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
462 (goto-char (or pos (point-min)))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
463 (or (looking-at re)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
464 (reftex-nearest-match re (length literal))))
87170
e50a2e215441 * erc-stamp.el (erc-echo-timestamp):
David Kastrup <dak@gnu.org>
parents: 86851
diff changeset
465 (t (message "%s" reftex-no-follow-message) nil))))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
466 (when match
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
467 (goto-char (match-beginning 0))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
468 (recenter '(4))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
469 (reftex-highlight 0 (match-beginning 0) (match-end 0) (current-buffer)))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
470 match))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
471
59534
9bad65481674 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 52401
diff changeset
472 (defun reftex-display-index (&optional tag overriding-restriction redo
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
473 &rest locations)
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
474 "Display a buffer with an index compiled from the current document.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
475 When the document has multiple indices, first prompts for the correct one.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
476 When index support is turned off, offer to turn it on.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
477 With one or two `C-u' prefixes, rescan document first.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
478 With prefix 2, restrict index to current document section.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
479 With prefix 3, restrict index to region."
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
480
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
481 (interactive)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
482
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
483 ;; Ensure access to scanning info and rescan buffer if prefix are is '(4).
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
484 (let ((current-prefix-arg current-prefix-arg))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
485 (reftex-ensure-index-support t)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
486 (reftex-access-scan-info current-prefix-arg))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
487
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
488 (set-marker reftex-index-return-marker (point))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
489 (setq reftex-last-follow-point 1)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
490
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
491 ;; Determine the correct index to process
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
492 (let* ((docstruct (symbol-value reftex-docstruct-symbol))
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
493 (docstruct-symbol reftex-docstruct-symbol)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
494 (index-tag (or tag (reftex-index-select-tag)))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
495 (master (reftex-TeX-master-file))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
496 (calling-file (buffer-file-name))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
497 (restriction
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
498 (or overriding-restriction
99383
a5f24b6e48ef * international/mule-cmds.el (toggle-enable-multibyte-characters)
Juanma Barranquero <lekktu@gmail.com>
parents: 94670
diff changeset
499 (and (not redo)
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
500 (reftex-get-restriction current-prefix-arg docstruct))))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
501 (locations
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
502 ;; See if we are on an index macro as initial position
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
503 (or locations
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
504 (let* ((what-macro (reftex-what-macro-safe 1))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
505 (macro (car what-macro))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
506 (here-I-am (when (member macro reftex-macros-with-index)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
507 (save-excursion
99383
a5f24b6e48ef * international/mule-cmds.el (toggle-enable-multibyte-characters)
Juanma Barranquero <lekktu@gmail.com>
parents: 94670
diff changeset
508 (goto-char (+ (cdr what-macro)
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
509 (length macro)))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
510 (reftex-move-over-touching-args)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
511 (reftex-where-am-I)))))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
512 (if (eq (car (car here-I-am)) 'index)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
513 (list (car here-I-am))))))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
514 buffer-name)
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
515
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
516 (setq buffer-name (reftex-make-index-buffer-name index-tag))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
517
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
518 ;; Goto the buffer and put it into the correct mode
99383
a5f24b6e48ef * international/mule-cmds.el (toggle-enable-multibyte-characters)
Juanma Barranquero <lekktu@gmail.com>
parents: 94670
diff changeset
519
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
520 (when (or restriction current-prefix-arg)
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
521 (reftex-kill-buffer buffer-name))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
522
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
523 (if (get-buffer-window buffer-name)
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
524 (select-window (get-buffer-window buffer-name))
104768
17d2ae0948e2 Remove unnecessary bindings of default-major-mode (all are followed by
Glenn Morris <rgm@gnu.org>
parents: 104543
diff changeset
525 (switch-to-buffer buffer-name))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
526
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
527 (or (eq major-mode 'reftex-index-mode) (reftex-index-mode))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
528
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
529 ;; If the buffer is currently restricted, empty it to force update.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
530 (when reftex-index-restriction-data
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
531 (reftex-erase-buffer))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
532 (set (make-local-variable 'reftex-last-index-file) calling-file)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
533 (set (make-local-variable 'reftex-index-tag) index-tag)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
534 (set (make-local-variable 'reftex-docstruct-symbol) docstruct-symbol)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
535 (if restriction
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
536 (setq reftex-index-restriction-indicator (car restriction)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
537 reftex-index-restriction-data (cdr restriction))
59534
9bad65481674 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 52401
diff changeset
538 (if (not redo)
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
539 (setq reftex-index-restriction-indicator nil
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
540 reftex-index-restriction-data nil)))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
541 (when (= (buffer-size) 0)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
542 ;; buffer is empty - fill it
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
543 (message "Building %s buffer..." buffer-name)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
544
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
545 (setq buffer-read-only nil)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
546 (insert (format
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
547 "INDEX <%s> on %s
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
548 Restriction: <%s>
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
549 SPC=view TAB=goto RET=goto+hide [e]dit [q]uit [r]escan [f]ollow [?]Help
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
550 ------------------------------------------------------------------------------
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
551 " index-tag (abbreviate-file-name master)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
552 (if (eq (car (car reftex-index-restriction-data)) 'toc)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
553 (nth 2 (car reftex-index-restriction-data))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
554 reftex-index-restriction-indicator)))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
555
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
556 (if (reftex-use-fonts)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
557 (put-text-property 1 (point) 'face reftex-index-header-face))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
558 (put-text-property 1 (point) 'intangible t)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
559
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
560 (reftex-insert-index docstruct index-tag)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
561 (goto-char (point-min))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
562 (run-hooks 'reftex-display-copied-context-hook)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
563 (message "Building %s buffer...done." buffer-name)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
564 (setq buffer-read-only t))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
565 (and locations (apply 'reftex-find-start-point (point) locations))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
566 (if reftex-index-restriction-indicator
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
567 (message "Index restricted: <%s>" reftex-index-restriction-indicator))))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
568
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
569 (defun reftex-insert-index (docstruct tag &optional update-one remark)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
570 ;; Insert an index into the current buffer. Entries are from the
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
571 ;; DOCSTRUCT.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
572 ;; TAG is the subindex to process.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
573 ;; UPDATE-ONE: When non-nil, delete the entry at point and replace
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
574 ;; it with whatever the DOCSTRUCT contains.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
575 ;; REMARK can be a note to add to the entry.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
576 (let* ((all docstruct)
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
577 (indent " ")
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
578 (context reftex-index-include-context)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
579 (context-indent (concat indent " "))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
580 (section-chars (mapcar 'identity reftex-index-section-letters))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
581 (this-section-char 0)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
582 (font (reftex-use-fonts))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
583 (bor (car reftex-index-restriction-data))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
584 (eor (nth 1 reftex-index-restriction-data))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
585 (mouse-face
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
586 (if (memq reftex-highlight-selection '(mouse both))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
587 reftex-mouse-selected-face
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
588 nil))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
589 (index-face (reftex-verified-face reftex-label-face
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
590 'font-lock-constant-face
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
591 'font-lock-reference-face))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
592 sublist cell from to first-char)
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
593
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
594 ;; Make the sublist and sort it
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
595 (when bor
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
596 (setq all (or (memq bor all) all)))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
597
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
598 (while (setq cell (pop all))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
599 (if (eq cell eor)
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
600 (setq all nil)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
601 (and (eq (car cell) 'index)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
602 (equal (nth 1 cell) tag)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
603 (push cell sublist))))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
604 (setq sublist (sort (nreverse sublist)
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
605 (lambda (a b) (string< (nth 8 a) (nth 8 b)))))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
606
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
607 (when update-one
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
608 ;; Delete the entry at place
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
609 (and (bolp) (forward-char 1))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
610 (delete-region (previous-single-property-change (1+ (point)) :data)
99383
a5f24b6e48ef * international/mule-cmds.el (toggle-enable-multibyte-characters)
Juanma Barranquero <lekktu@gmail.com>
parents: 94670
diff changeset
611 (or (next-single-property-change (point) :data)
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
612 (point-max))))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
613
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
614 ;; Walk through the list and insert all entries
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
615 (while (setq cell (pop sublist))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
616 (unless update-one
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
617 (setq first-char (upcase (string-to-char (nth 6 cell))))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
618 (when (and (not (equal first-char this-section-char))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
619 (member first-char section-chars))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
620 ;; There is a new initial letter, so start a new section
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
621 (reftex-index-insert-new-letter first-char font)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
622 (setq section-chars (delete first-char section-chars)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
623 this-section-char first-char))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
624 (when (= this-section-char 0)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
625 (setq this-section-char ?!)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
626 (reftex-index-insert-new-letter this-section-char font)))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
627
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
628 (setq from (point))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
629 (insert indent (nth 7 cell))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
630 (when font
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
631 (setq to (point))
99383
a5f24b6e48ef * international/mule-cmds.el (toggle-enable-multibyte-characters)
Juanma Barranquero <lekktu@gmail.com>
parents: 94670
diff changeset
632 (put-text-property
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
633 (- (point) (length (nth 7 cell))) to
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
634 'face index-face)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
635 (goto-char to))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
636
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
637 (when (or remark (nth 9 cell))
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
638 (and (< (current-column) 40)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
639 ;; FIXME: maybe this is too slow?
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
640 (insert (make-string (max (- 40 (current-column)) 0) ?\ )))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
641 (and (nth 9 cell) (insert " " (substring (nth 5 cell) (nth 9 cell))))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
642 (and remark (insert " " remark)))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
643
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
644 (insert "\n")
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
645 (setq to (point))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
646
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
647 (when context
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
648 (insert context-indent (nth 2 cell) "\n")
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
649 (setq to (point)))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
650 (put-text-property from to :data cell)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
651 (when mouse-face
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
652 (put-text-property from (1- to)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
653 'mouse-face mouse-face))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
654 (goto-char to))))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
655
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
656
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
657 (defun reftex-index-insert-new-letter (letter &optional font)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
658 ;; Start a new section in the index
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
659 (let ((from (point)))
99383
a5f24b6e48ef * international/mule-cmds.el (toggle-enable-multibyte-characters)
Juanma Barranquero <lekktu@gmail.com>
parents: 94670
diff changeset
660 (insert "\n" letter letter letter
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
661 "-----------------------------------------------------------------")
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
662 (when font
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
663 (put-text-property from (point) 'face reftex-index-section-face))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
664 (insert "\n")))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
665
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
666 (defun reftex-get-restriction (arg docstruct)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
667 ;; Interprete the prefix ARG and derive index restriction specs.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
668 (let* ((beg (min (point) (or (condition-case nil (mark) (error nil))
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
669 (point-max))))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
670 (end (max (point) (or (condition-case nil (mark) (error nil))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
671 (point-min))))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
672 bor eor label here-I-am)
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
673 (cond
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
674 ((eq arg 2)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
675 (setq here-I-am (car (reftex-where-am-I))
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
676 bor (if (eq (car here-I-am) 'toc)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
677 here-I-am
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
678 (reftex-last-assoc-before-elt
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
679 'toc here-I-am docstruct))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
680 eor (car (memq (assq 'toc (cdr (memq bor docstruct))) docstruct))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
681 label (nth 6 bor)))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
682 ((eq arg 3)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
683 (save-excursion
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
684 (setq label "region")
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
685 (goto-char beg)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
686 (setq bor (car (reftex-where-am-I)))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
687 (setq bor (nth 1 (memq bor docstruct)))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
688 (goto-char end)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
689 (setq eor (nth 1 (memq (car (reftex-where-am-I)) docstruct)))))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
690 (t nil))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
691 (if (and label (or bor eor))
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
692 (list label bor eor)
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
693 nil)))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
694
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
695 (defun reftex-index-pre-command-hook ()
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
696 ;; Used as pre command hook in *Index* buffer
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
697 (reftex-unhighlight 0)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
698 (reftex-unhighlight 1))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
699
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
700 (defun reftex-index-post-command-hook ()
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
701 ;; Used in the post-command-hook for the *Index* buffer
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
702 (when (get-text-property (point) :data)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
703 (and (> (point) 1)
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
704 (not (get-text-property (point) 'intangible))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
705 (memq reftex-highlight-selection '(cursor both))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
706 (reftex-highlight 1
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
707 (or (previous-single-property-change (1+ (point)) :data)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
708 (point-min))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
709 (or (next-single-property-change (point) :data)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
710 (point-max)))))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
711 (if (integerp reftex-index-follow-mode)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
712 ;; Remove delayed action
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
713 (setq reftex-index-follow-mode t)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
714 (and reftex-index-follow-mode
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
715 (not (equal reftex-last-follow-point (point)))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
716 ;; Show context in other window
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
717 (setq reftex-last-follow-point (point))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
718 (condition-case nil
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
719 (reftex-index-visit-location nil (not reftex-revisit-to-follow))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
720 (error t)))))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
721
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
722 (defun reftex-index-show-help ()
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
723 "Show a summary of special key bindings."
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
724 (interactive)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
725 (with-output-to-temp-buffer "*RefTeX Help*"
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
726 (princ reftex-index-help))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
727 (reftex-enlarge-to-fit "*RefTeX Help*" t)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
728 ;; If follow mode is active, arrange to delay it one command
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
729 (if reftex-index-follow-mode
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
730 (setq reftex-index-follow-mode 1)))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
731
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
732 (defun reftex-index-next (&optional arg)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
733 "Move to next selectable item."
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
734 (interactive "p")
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
735 (setq reftex-callback-fwd t)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
736 (or (eobp) (forward-char 1))
99383
a5f24b6e48ef * international/mule-cmds.el (toggle-enable-multibyte-characters)
Juanma Barranquero <lekktu@gmail.com>
parents: 94670
diff changeset
737 (goto-char (or (next-single-property-change (point) :data)
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
738 (point)))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
739 (unless (get-text-property (point) :data)
99383
a5f24b6e48ef * international/mule-cmds.el (toggle-enable-multibyte-characters)
Juanma Barranquero <lekktu@gmail.com>
parents: 94670
diff changeset
740 (goto-char (or (next-single-property-change (point) :data)
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
741 (point)))))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
742 (defun reftex-index-previous (&optional arg)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
743 "Move to previous selectable item."
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
744 (interactive "p")
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
745 (setq reftex-callback-fwd nil)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
746 (goto-char (or (previous-single-property-change (point) :data)
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
747 (point)))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
748 (unless (get-text-property (point) :data)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
749 (goto-char (or (previous-single-property-change (point) :data)
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
750 (point)))))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
751 (defun reftex-index-toggle-follow ()
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
752 "Toggle follow (other window follows with context)."
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
753 (interactive)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
754 (setq reftex-last-follow-point -1)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
755 (setq reftex-index-follow-mode (not reftex-index-follow-mode)))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
756 (defun reftex-index-toggle-context ()
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
757 "Toggle inclusion of label context in *Index* buffer.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
758 Label context is only displayed when the labels are there as well."
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
759 (interactive)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
760 (setq reftex-index-include-context (not reftex-index-include-context))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
761 (reftex-index-revert))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
762 (defun reftex-index-view-entry ()
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
763 "View document location in other window."
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
764 (interactive)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
765 (reftex-index-visit-location))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
766 (defun reftex-index-goto-entry-and-hide ()
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
767 "Go to document location in other window. Hide the *Index* window."
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
768 (interactive)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
769 (reftex-index-visit-location 'hide))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
770 (defun reftex-index-goto-entry ()
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
771 "Go to document location in other window. *Index* window stays."
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
772 (interactive)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
773 (reftex-index-visit-location t))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
774 (defun reftex-index-mouse-goto-line-and-hide (ev)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
775 "Go to document location in other window. Hide the *Index* window."
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
776 (interactive "e")
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
777 (mouse-set-point ev)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
778 (reftex-index-visit-location 'hide))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
779 (defun reftex-index-quit ()
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
780 "Hide the *Index* window and do not move point."
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
781 (interactive)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
782 (or (one-window-p) (delete-window))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
783 (switch-to-buffer (marker-buffer reftex-index-return-marker))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
784 (goto-char (or (marker-position reftex-index-return-marker) (point))))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
785 (defun reftex-index-quit-and-kill ()
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
786 "Kill the *Index* buffer."
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
787 (interactive)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
788 (kill-buffer (current-buffer))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
789 (or (one-window-p) (delete-window))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
790 (switch-to-buffer (marker-buffer reftex-index-return-marker))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
791 (goto-char (or (marker-position reftex-index-return-marker) (point))))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
792 (defun reftex-index-goto-toc (&rest ignore)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
793 "Switch to the table of contents of the current document.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
794 The function will go to the section where the entry at point was defined."
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
795 (interactive)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
796 (if (get-text-property (point) :data)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
797 (reftex-index-goto-entry)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
798 (switch-to-buffer (marker-buffer reftex-index-return-marker)))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
799 (delete-other-windows)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
800 (reftex-toc))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
801 (defun reftex-index-rescan (&rest ignore)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
802 "Regenerate the *Index* buffer after reparsing file of section at point."
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
803 (interactive)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
804 (let ((index-tag reftex-index-tag))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
805 (if (and reftex-enable-partial-scans
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
806 (null current-prefix-arg))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
807 (let* ((data (get-text-property (point) :data))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
808 (file (nth 3 data))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
809 (line (+ (count-lines (point-min) (point)) (if (bolp) 1 0))))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
810 (if (not file)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
811 (error "Don't know which file to rescan. Try `C-u r'")
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
812 (switch-to-buffer (reftex-get-file-buffer-force file))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
813 (setq current-prefix-arg '(4))
59534
9bad65481674 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 52401
diff changeset
814 (reftex-display-index index-tag nil 'redo line)))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
815 (reftex-index-Rescan))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
816 (reftex-kill-temporary-buffers)))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
817 (defun reftex-index-Rescan (&rest ignore)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
818 "Regenerate the *Index* buffer after reparsing the entire document."
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
819 (interactive)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
820 (let ((index-tag reftex-index-tag)
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
821 (line (+ (count-lines (point-min) (point)) (if (bolp) 1 0))))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
822 (switch-to-buffer
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
823 (reftex-get-file-buffer-force reftex-last-index-file))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
824 (setq current-prefix-arg '(16))
59534
9bad65481674 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 52401
diff changeset
825 (reftex-display-index index-tag nil 'redo line)))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
826 (defun reftex-index-revert (&rest ignore)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
827 "Regenerate the *Index* from the internal lists. No reparsing os done."
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
828 (interactive)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
829 (let ((buf (current-buffer))
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
830 (index-tag reftex-index-tag)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
831 (data (get-text-property (point) :data))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
832 (line (+ (count-lines (point-min) (point)) (if (bolp) 1 0))))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
833 (switch-to-buffer
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
834 (reftex-get-file-buffer-force reftex-last-index-file))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
835 (reftex-erase-buffer buf)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
836 (setq current-prefix-arg nil
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
837 reftex-last-follow-point 1)
59534
9bad65481674 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 52401
diff changeset
838 (reftex-display-index index-tag nil 'redo data line)))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
839 (defun reftex-index-switch-index-tag (&rest ignore)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
840 "Switch to a different index of the same document."
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
841 (interactive)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
842 (switch-to-buffer
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
843 (reftex-get-file-buffer-force reftex-last-index-file))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
844 (setq current-prefix-arg nil)
59534
9bad65481674 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 52401
diff changeset
845 (reftex-display-index nil nil 'redo))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
846
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
847 (defun reftex-index-restrict-to-section (&optional force)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
848 "Restrict index to entries defined in same document sect. as entry at point."
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
849 ;; Optional FORCE means, even if point is not on an index entry.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
850 (interactive)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
851 (let* ((data (get-text-property (point) :data))
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
852 (docstruct (symbol-value reftex-docstruct-symbol))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
853 bor eor)
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
854 (if (and (not data) force)
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
855 (setq data (assq 'toc docstruct)))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
856 (when data
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
857 (setq bor (reftex-last-assoc-before-elt 'toc data docstruct)
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
858 eor (car (memq (assq 'toc (cdr (memq bor docstruct)))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
859 docstruct))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
860 reftex-index-restriction-data (list bor eor)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
861 reftex-index-restriction-indicator (nth 6 bor) )))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
862 (reftex-index-revert))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
863
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
864 (defun reftex-index-widen (&rest ignore)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
865 "Show the unrestricted index (all entries)."
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
866 (interactive)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
867 (setq reftex-index-restriction-indicator nil
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
868 reftex-index-restriction-data nil)
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
869 (reftex-index-revert)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
870 (message "Index widened"))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
871 (defun reftex-index-restriction-forward (&rest ignore)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
872 "Restrict to previous section.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
873 When index is currently unrestricted, restrict it to a section.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
874 When index is restricted, select the next section as restriction criterion."
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
875 (interactive)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
876 (let* ((docstruct (symbol-value reftex-docstruct-symbol))
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
877 (bor (nth 1 reftex-index-restriction-data)))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
878 (if (or (not bor)
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
879 (not (eq (car bor) 'toc)))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
880 (reftex-index-restrict-to-section t)
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
881 (setq reftex-index-restriction-indicator (nth 6 bor)
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
882 reftex-index-restriction-data
99383
a5f24b6e48ef * international/mule-cmds.el (toggle-enable-multibyte-characters)
Juanma Barranquero <lekktu@gmail.com>
parents: 94670
diff changeset
883 (list bor
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
884 (car (memq (assq 'toc (cdr (memq bor docstruct)))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
885 docstruct))))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
886 (reftex-index-revert))))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
887 (defun reftex-index-restriction-backward (&rest ignore)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
888 "Restrict to next section.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
889 When index is currently unrestricted, restrict it to a section.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
890 When index is restricted, select the previous section as restriction criterion."
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
891 (interactive)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
892 (let* ((docstruct (symbol-value reftex-docstruct-symbol))
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
893 (eor (car reftex-index-restriction-data))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
894 (bor (reftex-last-assoc-before-elt 'toc eor docstruct t)))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
895 (if (or (not bor)
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
896 (not (eq (car bor) 'toc)))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
897 (reftex-index-restrict-to-section t)
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
898 (setq reftex-index-restriction-indicator (nth 6 bor)
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
899 reftex-index-restriction-data
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
900 (list bor eor))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
901 (reftex-index-revert))))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
902
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
903 (defun reftex-index-visit-location (&optional final no-revisit)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
904 ;; Visit the tex file corresponding to the index entry on the current line.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
905 ;; If FINAL is t, stay there
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
906 ;; If FINAL is 'hide, hide the *Index* window.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
907 ;; Otherwise, move cursor back into *Index* window.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
908 ;; NO-REVISIT means don't visit files, just use live biffers.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
909
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
910 (let* ((data (get-text-property (point) :data))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
911 (index-window (selected-window))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
912 show-window show-buffer match)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
913
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
914 (unless data (error "Don't know which index entry to visit"))
99383
a5f24b6e48ef * international/mule-cmds.el (toggle-enable-multibyte-characters)
Juanma Barranquero <lekktu@gmail.com>
parents: 94670
diff changeset
915
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
916 (if (eq (car data) 'index)
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
917 (setq match (reftex-index-show-entry data no-revisit)))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
918
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
919 (setq show-window (selected-window)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
920 show-buffer (current-buffer))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
921
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
922 (unless match
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
923 (select-window index-window)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
924 (error "Cannot find location"))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
925
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
926 (select-window index-window)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
927
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
928 ;; Use the `final' parameter to decide what to do next
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
929 (cond
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
930 ((eq final t)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
931 (reftex-unhighlight 0)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
932 (select-window show-window))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
933 ((eq final 'hide)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
934 (reftex-unhighlight 0)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
935 (or (one-window-p) (delete-window))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
936 (switch-to-buffer show-buffer))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
937 (t nil))))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
938
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
939 (defun reftex-index-analyze-entry (data)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
940 ;; This splits the index context so that key, attribute and visual
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
941 ;; values are accessible individually.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
942 (interactive)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
943 (let* ((arg (nth 5 data))
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
944 (context (nth 2 data))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
945 (sc reftex-index-special-chars)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
946 (boa (if (string-match (regexp-quote (concat "{" arg "}")) context)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
947 (1+ (match-beginning 0))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
948 (error "Something is wrong here")))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
949 (eoa (1- (match-end 0)))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
950 (boactual (if (string-match (concat "[^" (nth 3 sc) "]" (nth 2 sc))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
951 context boa)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
952 (1+ (match-beginning 0))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
953 eoa))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
954 (boattr (if (string-match (concat "[^" (nth 3 sc) "]" (nth 1 sc))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
955 context boa)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
956 (1+ (match-beginning 0))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
957 boactual))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
958 (pre (substring context 0 boa))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
959 (key (substring context boa boattr))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
960 (attr (substring context boattr boactual))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
961 (actual (substring context boactual eoa))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
962 (post (substring context eoa)))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
963 (list pre key attr actual post)))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
964
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
965 (defun reftex-index-edit ()
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
966 "Edit the index entry at point."
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
967 (interactive)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
968 (let* ((data (get-text-property (point) :data))
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
969 old new)
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
970 (unless data (error "Don't know which index entry to edit"))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
971 (reftex-index-view-entry)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
972 (setq old (nth 2 data) new (read-string "Edit: " old))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
973 (reftex-index-change-entry new)))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
974
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
975 (defun reftex-index-toggle-range-beginning ()
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
976 "Toggle the page range start attribute `|('."
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
977 (interactive)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
978 (let* ((data (get-text-property (point) :data))
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
979 (bor (concat (nth 1 reftex-index-special-chars) "("))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
980 new analyze attr)
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
981 (unless data (error "Don't know which index entry to edit"))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
982 (setq analyze (reftex-index-analyze-entry data)
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
983 attr (nth 2 analyze))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
984 (setf (nth 2 analyze) (if (string= attr bor) "" bor))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
985 (setq new (apply 'concat analyze))
99383
a5f24b6e48ef * international/mule-cmds.el (toggle-enable-multibyte-characters)
Juanma Barranquero <lekktu@gmail.com>
parents: 94670
diff changeset
986 (reftex-index-change-entry
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
987 new (if (string= (nth 2 analyze) bor)
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
988 "Entry is now START-OF-PAGE-RANGE"
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
989 "START-OF-PAGE-RANGE canceled"))))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
990
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
991 (defun reftex-index-toggle-range-end ()
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
992 "Toggle the page-range-end attribute `|)'."
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
993 (interactive)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
994 (let* ((data (get-text-property (point) :data))
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
995 (eor (concat (nth 1 reftex-index-special-chars) ")"))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
996 new analyze attr)
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
997 (unless data (error "Don't know which index entry to edit"))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
998 (setq analyze (reftex-index-analyze-entry data)
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
999 attr (nth 2 analyze))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1000 (setf (nth 2 analyze) (if (string= attr eor) "" eor))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1001 (setq new (apply 'concat analyze))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1002 (reftex-index-change-entry
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1003 new (if (string= (nth 2 analyze) eor)
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1004 "Entry is now END-OF-PAGE-RANGE"
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1005 "END-OF-PAGE-RANGE canceled"))))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1006
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1007 (defun reftex-index-edit-key ()
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1008 "Edit the KEY part of the index entry."
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1009 (interactive)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1010 (reftex-index-edit-part nil 1 "" "Key: " t))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1011
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1012 (defun reftex-index-edit-attribute (&optional arg)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1013 "EDIT the ATTRIBUTE part of the entry. With arg: remove entire ATTRIBUTE."
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1014 (interactive "P")
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1015 (reftex-index-edit-part arg 2 (nth 1 reftex-index-special-chars)
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1016 "Attribute: "))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1017
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1018 (defun reftex-index-edit-visual (&optional arg)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1019 "EDIT the VISUAL part of the entry. With arg: remove entire VISUAL string."
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1020 (interactive "P")
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1021 (reftex-index-edit-part arg 3 (nth 2 reftex-index-special-chars) "Visual: "))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1022
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1023 (defun reftex-index-edit-part (arg n initial prompt &optional dont-allow-empty)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1024 ;; This function does the work for all partial editing commands
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1025 (let* ((data (get-text-property (point) :data))
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1026 new analyze opart npart)
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1027 (unless data (error "Don't know which index entry to edit"))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1028 ;; Analyze the whole context string
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1029 (setq analyze (reftex-index-analyze-entry data)
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1030 opart (nth n analyze))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1031 (and (> (length opart) 0) (setq opart (substring opart 1)))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1032 ;; Have the user editing the part
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1033 (setq npart (if arg "" (read-string (concat prompt initial) opart)))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1034 ;; Tests:
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1035 (cond ((string= npart opart)
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1036 (error "Not changed"))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1037 ((string= npart "")
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1038 (if dont-allow-empty
60918
58a53f588384 * textmodes/refbib.el, textmodes/refer.el, textmodes/reftex-cite.el,
Werner LEMBERG <wl@gnu.org>
parents: 59534
diff changeset
1039 (error "Invalid value")
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1040 (setf (nth n analyze) npart)))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1041 (t (setf (nth n analyze) (concat initial npart))))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1042 (setq new (apply 'concat analyze))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1043 ;; Change the entry and insert the changed version into the index.
99383
a5f24b6e48ef * international/mule-cmds.el (toggle-enable-multibyte-characters)
Juanma Barranquero <lekktu@gmail.com>
parents: 94670
diff changeset
1044 (reftex-index-change-entry
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1045 new (if (string= npart "")
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1046 (format "Deleted: %s" opart)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1047 (format "New value is: %s" npart)))))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1048
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1049 (defun reftex-index-level-down ()
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1050 "Make index entry a subitem of another entry."
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1051 (interactive)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1052 (let* ((data (get-text-property (point) :data))
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1053 (docstruct (symbol-value reftex-docstruct-symbol))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1054 old new prefix key)
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1055 (unless data (error "Don't know which index entry to change"))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1056 (setq old (nth 2 data)
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1057 key (nth 6 data)
99383
a5f24b6e48ef * international/mule-cmds.el (toggle-enable-multibyte-characters)
Juanma Barranquero <lekktu@gmail.com>
parents: 94670
diff changeset
1058 prefix (completing-read
a5f24b6e48ef * international/mule-cmds.el (toggle-enable-multibyte-characters)
Juanma Barranquero <lekktu@gmail.com>
parents: 94670
diff changeset
1059 "Prefix: "
a5f24b6e48ef * international/mule-cmds.el (toggle-enable-multibyte-characters)
Juanma Barranquero <lekktu@gmail.com>
parents: 94670
diff changeset
1060 (reftex-sublist-nth
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1061 docstruct 6
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1062 (lambda (x)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1063 (and (eq (car x) 'index)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1064 (string= (nth 1 x) reftex-index-tag))) t)))
99383
a5f24b6e48ef * international/mule-cmds.el (toggle-enable-multibyte-characters)
Juanma Barranquero <lekktu@gmail.com>
parents: 94670
diff changeset
1065 (unless (string-match
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1066 (concat (regexp-quote (car reftex-index-special-chars)) "\\'")
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1067 prefix)
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1068 (setq prefix (concat prefix (car reftex-index-special-chars))))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1069 (if (string-match (regexp-quote key) old)
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1070 (setq new (replace-match (concat prefix key) t t old))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1071 (error "Cannot construct new index key"))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1072 (reftex-index-change-entry new (format "Added prefix: %s" prefix))))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1073
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1074 (defun reftex-index-level-up ()
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1075 "Remove the highest level of a hierarchical index entry."
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1076 (interactive)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1077 (let* ((data (get-text-property (point) :data))
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1078 old new prefix)
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1079 (unless data (error "Don't know which entry to change"))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1080 (setq old (nth 2 data))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1081 (if (string-match (concat "{\\([^" (nth 0 reftex-index-special-chars) "]*"
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1082 "[^" (nth 3 reftex-index-special-chars) "]"
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1083 (regexp-quote (nth 0 reftex-index-special-chars))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1084 "\\)")
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1085 old)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1086 (setq prefix (substring old (match-beginning 1) (match-end 1))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1087 new (concat (substring old 0 (match-beginning 1))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1088 (substring old (match-end 1))))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1089 (error "Entry is not a subitem"))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1090 (reftex-index-change-entry new (format "Removed prefix: %s" prefix))))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1091
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1092 (defun reftex-index-kill ()
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1093 "FIXME: Not yet implemented"
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1094 (interactive)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1095 (error "This function is currently not implemented"))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1096
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1097 (defun reftex-index-undo ()
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1098 "FIXME: Not yet implemented"
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1099 (interactive)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1100 (error "This function is currently not implemented"))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1101
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1102 (defun reftex-index-change-entry (new &optional message)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1103 ;; Change the full context string of the index entry at point to
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1104 ;; NEW. This actually edits the buffer where the entry is defined.
99383
a5f24b6e48ef * international/mule-cmds.el (toggle-enable-multibyte-characters)
Juanma Barranquero <lekktu@gmail.com>
parents: 94670
diff changeset
1105
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1106 (let* ((data (get-text-property (point) :data))
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1107 old beg end info)
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1108 (unless data (error "Cannot change entry"))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1109 (reftex-index-view-entry)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1110 (setq beg (match-beginning 0) end (match-end 0))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1111 (setq old (nth 2 data))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1112 (and (equal old new) (error "Entry unchanged"))
105813
df4934f25eef * textmodes/two-column.el (2C-split):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 104768
diff changeset
1113 (with-current-buffer (get-file-buffer (nth 3 data))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1114 (goto-char beg)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1115 (unless (looking-at (regexp-quote old))
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1116 (error "This should not happen (reftex-index-change-entry)"))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1117 (delete-region beg end)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1118 (insert new)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1119 (goto-char (1- beg))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1120 (when (and (re-search-forward (reftex-everything-regexp) nil t)
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1121 (match-end 10)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1122 (< (abs (- (match-beginning 10) beg)) (length new))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1123 (setq info (reftex-index-info-safe buffer-file-name)))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1124 (setcdr data (cdr info))))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1125 (let ((buffer-read-only nil))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1126 (save-excursion
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1127 (reftex-insert-index (list data) reftex-index-tag t
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1128 "EDITED")))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1129 (setq reftex-last-follow-point 1)
65583
703495630901 Message format spec fixes (2)
Deepak Goel <deego@gnufans.org>
parents: 65548
diff changeset
1130 (and message (message "%s" message))))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1131
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1132 (defun reftex-index-goto-letter (char)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1133 "Go to the CHAR section in the index."
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1134 (let ((pos (point))
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1135 (case-fold-search nil))
104543
da8b3e61b182 Use forward-line rather than goto-line.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
1136 (goto-char (point-min))
da8b3e61b182 Use forward-line rather than goto-line.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
1137 (forward-line 2)
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1138 (if (re-search-forward (concat "^" (char-to-string char)) nil t)
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1139 (progn
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1140 (beginning-of-line)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1141 (recenter 0)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1142 (reftex-index-next))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1143 (goto-char pos)
26910
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1144 (if (eq char ?!)
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1145 (error "This <%s> index does not contain entries sorted before the letters"
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1146 reftex-index-tag)
99383
a5f24b6e48ef * international/mule-cmds.el (toggle-enable-multibyte-characters)
Juanma Barranquero <lekktu@gmail.com>
parents: 94670
diff changeset
1147 (error "This <%s> index does not contain entries starting with `%c'"
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1148 reftex-index-tag char)))))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1149
26910
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1150
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1151 ;;----------------------------------------------------------------------
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1152 ;; The Index Phrases File
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1153
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1154 ;; Some constants and variables
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1155 (defconst reftex-index-phrases-comment-regexp "^[ \t]*%.*"
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1156 "Regular expression to match comment lines in phrases buffer")
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1157 (defconst reftex-index-phrases-macrodef-regexp
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1158 "^\\(>>>INDEX_MACRO_DEFINITION:\\)[ \t]+\\(\\S-\\)\\( *\t[ \t]*\\)\\([^\t]*[^ \t]\\)\\( *\t[ \t]*\\)\\(\\S-+\\)"
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1159 "Regular expression to match macro definition lines the phrases buffer.")
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1160 ;(defconst reftex-index-phrases-macrodef-regexp
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1161 ; "^\\(>>>INDEX_MACRO_DEFINITION:\\)[ \t]+\\(\\S-\\)\\([ \t]*\\)\\([^\t]*[^ \t]\\)\\([ \t]*\\)\\(nil\\|t\\)[ \t]*$"
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1162 ; "Regular expression to match macro definition lines the phrases buffer.
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1163 ;This version would allow just spaces as separators.")
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1164 (defconst reftex-index-phrases-phrase-regexp1
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1165 "^\\(\\S-?\\)\\(\t\\)\\([^\t\n]*\\S-\\)\\([ \t]*\\)$"
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1166 "Regular expression matching phrases which have no separate index key.")
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1167 (defconst reftex-index-phrases-phrase-regexp2
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1168 "^\\(\\S-?\\)\\(\t\\)\\([^\t]*\\S-\\)\\(\t[ \t]*\\)\\([^\n\t]*\\S-\\)[ \t]*$"
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1169 "Regular expression matching phrases which have a separate index key.")
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1170 (defconst reftex-index-phrases-phrase-regexp12
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1171 "^\\(\\S-?\\)\\(\t\\)\\([^\n\t]*\\S-\\)\\(\\(\t[ \t]*\\)\\([^\n\t]*\\S-\\)\\)?[ \t]*$"
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1172 "Regular expression matching all types of phrase lines.")
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1173 (defvar reftex-index-phrases-macro-data nil
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1174 "Alist containing the information taken from the macro definition lines.
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1175 This gets refreshed in every phrases command.")
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1176 (defvar reftex-index-phrases-files nil
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1177 "List of document files relevant for the phrases file.")
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1178
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1179 (defvar reftex-index-phrases-font-lock-keywords nil
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1180 "Font lock keywords for reftex-index-phrases-mode.")
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1181 (defvar reftex-index-phrases-font-lock-defaults nil
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1182 "Font lock defaults for reftex-index-phrases-mode.")
112213
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
1183 (defvar reftex-index-phrases-mode-map
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
1184 (let ((map (make-sparse-keymap)))
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
1185 ;; Keybindings and Menu for phrases buffer
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
1186 (loop for x in
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
1187 '(("\C-c\C-c" . reftex-index-phrases-save-and-return)
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
1188 ("\C-c\C-x" . reftex-index-this-phrase)
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
1189 ("\C-c\C-f" . reftex-index-next-phrase)
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
1190 ("\C-c\C-r" . reftex-index-region-phrases)
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
1191 ("\C-c\C-a" . reftex-index-all-phrases)
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
1192 ("\C-c\C-d" . reftex-index-remaining-phrases)
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
1193 ("\C-c\C-s" . reftex-index-sort-phrases)
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
1194 ("\C-c\C-n" . reftex-index-new-phrase)
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
1195 ("\C-c\C-m" . reftex-index-phrases-set-macro-key)
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
1196 ("\C-c\C-i" . reftex-index-phrases-info)
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
1197 ("\C-c\C-t" . reftex-index-find-next-conflict-phrase)
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
1198 ("\C-i" . self-insert-command))
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
1199 do (define-key map (car x) (cdr x)))
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
1200
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
1201 (easy-menu-define reftex-index-phrases-menu map
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
1202 "Menu for Phrases buffer"
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
1203 '("Phrases"
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
1204 ["New Phrase" reftex-index-new-phrase t]
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
1205 ["Set Phrase Macro" reftex-index-phrases-set-macro-key t]
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
1206 ["Recreate File Header" reftex-index-initialize-phrases-buffer t]
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
1207 "--"
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
1208 ("Sort Phrases"
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
1209 ["Sort" reftex-index-sort-phrases t]
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
1210 "--"
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
1211 "Sort Options"
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
1212 ["by Search Phrase" (setq reftex-index-phrases-sort-prefers-entry nil)
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
1213 :style radio :selected (not reftex-index-phrases-sort-prefers-entry)]
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
1214 ["by Index Entry" (setq reftex-index-phrases-sort-prefers-entry t)
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
1215 :style radio :selected reftex-index-phrases-sort-prefers-entry]
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
1216 ["in Blocks" (setq reftex-index-phrases-sort-in-blocks
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
1217 (not reftex-index-phrases-sort-in-blocks))
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
1218 :style toggle :selected reftex-index-phrases-sort-in-blocks])
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
1219 ["Describe Phrase" reftex-index-phrases-info t]
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
1220 ["Next Phrase Conflict" reftex-index-find-next-conflict-phrase t]
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
1221 "--"
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
1222 ("Find and Index in Document"
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
1223 ["Current Phrase" reftex-index-this-phrase t]
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
1224 ["Next Phrase" reftex-index-next-phrase t]
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
1225 ["Current and Following" reftex-index-remaining-phrases t]
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
1226 ["Region Phrases" reftex-index-region-phrases t]
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
1227 ["All Phrases" reftex-index-all-phrases t]
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
1228 "--"
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
1229 "Options"
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
1230 ["Match Whole Words" (setq reftex-index-phrases-search-whole-words
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
1231 (not reftex-index-phrases-search-whole-words))
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
1232 :style toggle :selected reftex-index-phrases-search-whole-words]
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
1233 ["Case Sensitive Search" (setq reftex-index-phrases-case-fold-search
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
1234 (not reftex-index-phrases-case-fold-search))
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
1235 :style toggle :selected (not
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
1236 reftex-index-phrases-case-fold-search)]
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
1237 ["Wrap Long Lines" (setq reftex-index-phrases-wrap-long-lines
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
1238 (not reftex-index-phrases-wrap-long-lines))
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
1239 :style toggle :selected reftex-index-phrases-wrap-long-lines]
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
1240 ["Skip Indexed Matches" (setq reftex-index-phrases-skip-indexed-matches
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
1241 (not reftex-index-phrases-skip-indexed-matches))
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
1242 :style toggle :selected reftex-index-phrases-skip-indexed-matches])
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
1243 "--"
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
1244 ["Save and Return" reftex-index-phrases-save-and-return t]))
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
1245
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
1246 map)
26910
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1247 "Keymap used for *toc* buffer.")
112213
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
1248 (define-obsolete-variable-alias
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
1249 'reftex-index-phrases-map 'reftex-index-phrases-mode-map "24.1")
26910
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1250
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1251
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1252 (defun reftex-index-phrase-selection-or-word (arg)
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1253 "Add current selection or word at point to the phrases buffer.
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1254 When you are in transient-mark-mode and the region is active, the
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1255 selection will be used - otherwise the word at point.
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1256 You get a chance to edit the entry in the phrases buffer - finish with
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1257 `C-c C-c'."
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1258 (interactive "P")
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1259 (set-marker reftex-index-return-marker (point))
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1260 (reftex-index-selection-or-word arg 'phrase)
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1261 (if (eq major-mode 'reftex-index-phrases-mode)
99383
a5f24b6e48ef * international/mule-cmds.el (toggle-enable-multibyte-characters)
Juanma Barranquero <lekktu@gmail.com>
parents: 94670
diff changeset
1262 (message "%s"
26910
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1263 (substitute-command-keys
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1264 "Return to LaTeX with \\[reftex-index-phrases-save-and-return]"))))
26910
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1265
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1266 (defun reftex-index-visit-phrases-buffer ()
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1267 "Switch to the phrases buffer, initialize if empty."
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1268 (interactive)
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1269 (reftex-access-scan-info)
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1270 (let* ((master (reftex-TeX-master-file))
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1271 (name (concat (file-name-sans-extension master)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1272 reftex-index-phrase-file-extension)))
26910
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1273 (find-file name)
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1274 (unless (eq major-mode 'reftex-index-phrases-mode)
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1275 (reftex-index-phrases-mode))
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1276 (if (= (buffer-size) 0)
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1277 (reftex-index-initialize-phrases-buffer master))))
26910
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1278
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1279 (defun reftex-index-initialize-phrases-buffer (&optional master)
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1280 "Initialize the phrases buffer by creating the header.
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1281 If the buffer is non-empty, delete the old header first."
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1282 (interactive)
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1283 (let* ((case-fold-search t)
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1284 (default-key (car reftex-index-default-macro))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1285 (default-macro (nth 1 (assoc default-key
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1286 reftex-key-to-index-macro-alist)))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1287 (macro-alist
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1288 (sort (copy-sequence reftex-index-macro-alist)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1289 (lambda (a b) (equal (car a) default-macro))))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1290 macro entry key repeat)
99383
a5f24b6e48ef * international/mule-cmds.el (toggle-enable-multibyte-characters)
Juanma Barranquero <lekktu@gmail.com>
parents: 94670
diff changeset
1291
26910
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1292 (if master (set (make-local-variable 'TeX-master)
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1293 (file-name-nondirectory master)))
26910
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1294
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1295 (when (> (buffer-size) 0)
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1296 (goto-char 1)
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1297 (set-mark (point))
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1298 (while (re-search-forward reftex-index-phrases-macrodef-regexp nil t)
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1299 (end-of-line))
26910
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1300 (beginning-of-line 2)
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1301 (if (looking-at reftex-index-phrases-comment-regexp)
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1302 (beginning-of-line 2))
26910
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1303 (while (looking-at "^[ \t]*$")
99383
a5f24b6e48ef * international/mule-cmds.el (toggle-enable-multibyte-characters)
Juanma Barranquero <lekktu@gmail.com>
parents: 94670
diff changeset
1304 (beginning-of-line 2))
a5f24b6e48ef * international/mule-cmds.el (toggle-enable-multibyte-characters)
Juanma Barranquero <lekktu@gmail.com>
parents: 94670
diff changeset
1305 (if (featurep 'xemacs)
87941
d77b6e5ee8af * sieve.el (sieve-make-overlay, sieve-overlay-put, sieve-overlays-at):
Dan Nicolaescu <dann@ics.uci.edu>
parents: 87649
diff changeset
1306 (zmacs-activate-region)
d77b6e5ee8af * sieve.el (sieve-make-overlay, sieve-overlay-put, sieve-overlays-at):
Dan Nicolaescu <dann@ics.uci.edu>
parents: 87649
diff changeset
1307 (setq mark-active t))
65689
96187e7edd1b 2005-09-25 Romain Francoise <romain@orebokech.com>
Romain Francoise <romain@orebokech.com>
parents: 65680
diff changeset
1308 (if (yes-or-no-p "Delete and rebuild header? ")
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1309 (delete-region (point-min) (point))))
26910
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1310
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1311 ;; Insert the mode line
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1312 (insert
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1313 (format "%% -*- mode: reftex-index-phrases; TeX-master: \"%s\" -*-\n"
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1314 (file-name-nondirectory (reftex-index-phrase-tex-master))))
26910
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1315 ;; Insert the macro definitions
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1316 (insert "% Key Macro Format Repeat\n")
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1317 (insert "%---------------------------------------------------------------------\n")
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1318 (while (setq entry (pop macro-alist))
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1319 (setq macro (car entry)
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1320 repeat (nth 7 entry)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1321 key (car (delq nil (mapcar (lambda (x) (if (equal (nth 1 x) macro)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1322 (car x)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1323 nil))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1324 reftex-key-to-index-macro-alist))))
26910
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1325 (insert (format ">>>INDEX_MACRO_DEFINITION:\t%s\t%-20s\t%s\n"
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1326 (char-to-string key) (concat macro "{%s}")
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1327 (if repeat "t" "nil"))))
26910
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1328 (insert "%---------------------------------------------------------------------\n\n\n")))
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1329
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1330 (defvar TeX-master)
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1331 (defun reftex-index-phrase-tex-master (&optional dir)
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1332 "Return the name of the master file associated with a phrase buffer."
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1333 (if (and (boundp 'TeX-master)
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1334 (local-variable-p 'TeX-master (current-buffer))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1335 (stringp TeX-master))
26910
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1336 ;; We have a local variable which tells us which file to use
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1337 (expand-file-name TeX-master dir)
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1338 ;; have to guess
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1339 (concat (file-name-sans-extension (buffer-file-name)) ".tex")))
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1340
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1341 (defun reftex-index-phrases-save-and-return ()
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1342 "Return to where the `reftex-index-phrase-selection-or-word' was called."
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1343 (interactive)
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1344 (save-buffer)
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1345 (switch-to-buffer (marker-buffer reftex-index-return-marker))
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1346 (goto-char (or (marker-position reftex-index-return-marker) (point))))
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1347
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1348
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1349 (defvar reftex-index-phrases-menu)
65548
253cad16882d Little fixes to remove compiler warnings
Carsten Dominik <dominik@science.uva.nl>
parents: 65269
diff changeset
1350 (defvar reftex-index-phrases-marker)
26910
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1351 (defvar reftex-index-phrases-restrict-file nil)
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1352 ;;;###autoload
112213
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
1353 (define-derived-mode reftex-index-phrases-mode fundamental-mode "Phrases"
26910
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1354 "Major mode for managing the Index phrases of a LaTeX document.
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1355 This buffer was created with RefTeX.
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1356
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1357 To insert new phrases, use
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1358 - `C-c \\' in the LaTeX document to copy selection or word
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1359 - `\\[reftex-index-new-phrase]' in the phrases buffer.
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1360
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1361 To index phrases use one of:
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1362
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1363 \\[reftex-index-this-phrase] index current phrase
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1364 \\[reftex-index-next-phrase] index next phrase (or N with prefix arg)
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1365 \\[reftex-index-all-phrases] index all phrases
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1366 \\[reftex-index-remaining-phrases] index current and following phrases
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1367 \\[reftex-index-region-phrases] index the phrases in the region
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1368
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1369 You can sort the phrases in this buffer with \\[reftex-index-sort-phrases].
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1370 To display information about the phrase at point, use \\[reftex-index-phrases-info].
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1371
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1372 For more information see the RefTeX User Manual.
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1373
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1374 Here are all local bindings.
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1375
112213
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
1376 \\{reftex-index-phrases-mode-map}"
99383
a5f24b6e48ef * international/mule-cmds.el (toggle-enable-multibyte-characters)
Juanma Barranquero <lekktu@gmail.com>
parents: 94670
diff changeset
1377 (set (make-local-variable 'font-lock-defaults)
26910
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1378 reftex-index-phrases-font-lock-defaults)
112213
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
1379 (easy-menu-add reftex-index-phrases-menu reftex-index-phrases-mode-map)
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
1380 (set (make-local-variable 'reftex-index-phrases-marker) (make-marker)))
6e613fbf73d7 Use run-mode-hooks for major mode hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111333
diff changeset
1381 ;; (add-hook 'reftex-index-phrases-mode-hook 'turn-on-font-lock)
26910
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1382
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1383 ;; Font Locking stuff
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1384 (let ((ss (if (featurep 'xemacs) 'secondary-selection ''secondary-selection)))
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1385 (setq reftex-index-phrases-font-lock-keywords
99383
a5f24b6e48ef * international/mule-cmds.el (toggle-enable-multibyte-characters)
Juanma Barranquero <lekktu@gmail.com>
parents: 94670
diff changeset
1386 (list
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1387 (cons reftex-index-phrases-comment-regexp 'font-lock-comment-face)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1388 (list reftex-index-phrases-macrodef-regexp
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1389 '(1 font-lock-type-face)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1390 '(2 font-lock-keyword-face)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1391 (list 3 ss)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1392 '(4 font-lock-function-name-face)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1393 (list 5 ss)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1394 '(6 font-lock-string-face))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1395 (list reftex-index-phrases-phrase-regexp1
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1396 '(1 font-lock-keyword-face)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1397 (list 2 ss)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1398 '(3 font-lock-string-face)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1399 (list 4 ss))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1400 (list reftex-index-phrases-phrase-regexp2
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1401 '(1 font-lock-keyword-face)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1402 (list 2 ss)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1403 '(3 font-lock-string-face)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1404 (list 4 ss)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1405 '(5 font-lock-function-name-face))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1406 (cons "^\t$" ss)))
26910
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1407 (setq reftex-index-phrases-font-lock-defaults
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1408 '((reftex-index-phrases-font-lock-keywords)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1409 nil t nil beginning-of-line))
99383
a5f24b6e48ef * international/mule-cmds.el (toggle-enable-multibyte-characters)
Juanma Barranquero <lekktu@gmail.com>
parents: 94670
diff changeset
1410 (put 'reftex-index-phrases-mode 'font-lock-defaults
26910
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1411 reftex-index-phrases-font-lock-defaults) ; XEmacs
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1412 )
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1413
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1414 (defun reftex-index-next-phrase (&optional arg)
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1415 "Index the next ARG phrases in the phrases buffer."
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1416 (interactive "p")
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1417 (reftex-index-phrases-parse-header t)
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1418 (while (> arg 0)
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1419 (decf arg)
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1420 (end-of-line)
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1421 (if (re-search-forward reftex-index-phrases-phrase-regexp12 nil t)
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1422 (progn
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1423 (goto-char (match-beginning 0))
59534
9bad65481674 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 52401
diff changeset
1424 (reftex-index-this-phrase 'slave))
26910
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1425 (error "No more phrase lines after point"))))
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1426
59534
9bad65481674 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 52401
diff changeset
1427 (defun reftex-index-this-phrase (&optional slave)
26910
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1428 "Index the phrase in the current line.
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1429 Does a global search and replace in the entire document. At each
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1430 match, the user will be asked to confirm the replacement."
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1431 (interactive)
59534
9bad65481674 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 52401
diff changeset
1432 (if (not slave) (reftex-index-phrases-parse-header t))
26910
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1433 (save-excursion
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1434 (beginning-of-line)
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1435 (cond ((looking-at reftex-index-phrases-comment-regexp)
59534
9bad65481674 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 52401
diff changeset
1436 (if (not slave) (error "Comment line")))
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1437 ((looking-at "^[ \t]*$")
59534
9bad65481674 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 52401
diff changeset
1438 (if (not slave) (error "Empty line")))
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1439 ((looking-at reftex-index-phrases-macrodef-regexp)
59534
9bad65481674 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 52401
diff changeset
1440 (if (not slave) (error "Macro definition line")))
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1441 ((looking-at reftex-index-phrases-phrase-regexp12)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1442 ;; This is a phrase
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1443 (let* ((char (if (not (equal (match-string 1) ""))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1444 (string-to-char (match-string 1))))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1445 (phrase (match-string 3))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1446 (index-key (match-string 6))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1447 (macro-data (cdr (if (null char)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1448 (car reftex-index-phrases-macro-data)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1449 (assoc char reftex-index-phrases-macro-data))))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1450 (macro-fmt (car macro-data))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1451 (repeat (nth 1 macro-data))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1452 (files
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1453 (cond ((and (stringp reftex-index-phrases-restrict-file)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1454 (file-regular-p reftex-index-phrases-restrict-file))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1455 (list reftex-index-phrases-restrict-file))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1456 ((stringp reftex-index-phrases-restrict-file)
60918
58a53f588384 * textmodes/refbib.el, textmodes/refer.el, textmodes/reftex-cite.el,
Werner LEMBERG <wl@gnu.org>
parents: 59534
diff changeset
1457 (error "Invalid restriction file %s"
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1458 reftex-index-phrases-restrict-file))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1459 (t reftex-index-phrases-files)))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1460 (as-words reftex-index-phrases-search-whole-words))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1461 (unless macro-data
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1462 (error "No macro associated with key %c" char))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1463 (unwind-protect
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1464 (let ((overlay-arrow-string "=>")
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1465 (overlay-arrow-position
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1466 reftex-index-phrases-marker)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1467 (replace-count 0))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1468 ;; Show the overlay arrow
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1469 (move-marker reftex-index-phrases-marker
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1470 (match-beginning 0) (current-buffer))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1471 ;; Start the query-replace
99383
a5f24b6e48ef * international/mule-cmds.el (toggle-enable-multibyte-characters)
Juanma Barranquero <lekktu@gmail.com>
parents: 94670
diff changeset
1472 (reftex-query-index-phrase-globally
a5f24b6e48ef * international/mule-cmds.el (toggle-enable-multibyte-characters)
Juanma Barranquero <lekktu@gmail.com>
parents: 94670
diff changeset
1473 files phrase macro-fmt
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1474 index-key repeat as-words)
99383
a5f24b6e48ef * international/mule-cmds.el (toggle-enable-multibyte-characters)
Juanma Barranquero <lekktu@gmail.com>
parents: 94670
diff changeset
1475 (message "%s replaced"
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1476 (reftex-number replace-count "occurrence"))))))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1477 (t (error "Cannot parse this line")))))
26910
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1478
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1479 (defun reftex-index-all-phrases ()
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1480 "Index all phrases in the phrases buffer.
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1481 Calls `reftex-index-this-phrase' on each line in the buffer."
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1482 (interactive)
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1483 (reftex-index-region-phrases (point-min) (point-max)))
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1484
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1485 (defun reftex-index-remaining-phrases ()
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1486 "Index all phrases in the phrases buffer.
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1487 Calls `reftex-index-this-phrase' on each line ay and below point in
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1488 the buffer."
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1489 (interactive)
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1490 (beginning-of-line)
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1491 (reftex-index-region-phrases (point) (point-max)))
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1492
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1493 (defun reftex-index-region-phrases (beg end)
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1494 "Index all phrases in the phrases buffer.
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1495 Calls `reftex-index-this-phrase' on each line in the region."
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1496 (interactive "r")
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1497 (reftex-index-phrases-parse-header t)
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1498 (goto-char beg)
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1499 (while (not (or (eobp)
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1500 (>= (point) end)))
59534
9bad65481674 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 52401
diff changeset
1501 (save-excursion (reftex-index-this-phrase 'slave))
26910
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1502 (beginning-of-line 2)))
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1503
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1504 (defun reftex-index-phrases-parse-header (&optional get-files)
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1505 "Parse the header of a phrases file to extract the macro definitions.
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1506 The definitions get stored in `reftex-index-phrases-macro-data'.
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1507 Also switches to the LaTeX document to find out which files belong to
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1508 the document and stores the list in `reftex-index-phrases-files'."
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1509 (let* ((master (reftex-index-phrase-tex-master))
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1510 buf)
26910
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1511 (if get-files
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1512 ;; Get the file list
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1513 (save-excursion
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1514 (setq buf (reftex-get-file-buffer-force master))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1515 (unless buf (error "Master file %s not found" master))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1516 (set-buffer buf)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1517 (reftex-access-scan-info)
99383
a5f24b6e48ef * international/mule-cmds.el (toggle-enable-multibyte-characters)
Juanma Barranquero <lekktu@gmail.com>
parents: 94670
diff changeset
1518 (setq reftex-index-phrases-files
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1519 (reftex-all-document-files))))
26910
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1520 ;; Parse the files header for macro definitions
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1521 (setq reftex-index-phrases-macro-data nil)
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1522 (save-excursion
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1523 (goto-char (point-min))
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1524 (while (re-search-forward reftex-index-phrases-macrodef-regexp nil t)
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1525 (push (list
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1526 (string-to-char (match-string 2))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1527 (match-string 4)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1528 (equal (match-string 6) "t"))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1529 reftex-index-phrases-macro-data))
26910
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1530 ;; Reverse the list, so that the first macro is first
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1531 (if (null reftex-index-phrases-macro-data)
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1532 (error "No valid MACRO DEFINITION line in %s file (make sure to use TAB separators)" reftex-index-phrase-file-extension))
99383
a5f24b6e48ef * international/mule-cmds.el (toggle-enable-multibyte-characters)
Juanma Barranquero <lekktu@gmail.com>
parents: 94670
diff changeset
1533 (setq reftex-index-phrases-macro-data
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1534 (nreverse reftex-index-phrases-macro-data))
26910
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1535 (goto-char (point-min)))))
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1536
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1537 (defun reftex-index-phrases-apply-to-region (beg end)
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1538 "Index all index phrases in the current region.
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1539 This works exactly like global indexing from the index phrases buffer,
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1540 but operation is restricted to the current region. This is useful if
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1541 you need to add/change text in an already indexed document and want to
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1542 index the new part without having to go over the unchanged parts again."
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1543 (interactive "r")
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1544 (let ((win-conf (current-window-configuration))
99383
a5f24b6e48ef * international/mule-cmds.el (toggle-enable-multibyte-characters)
Juanma Barranquero <lekktu@gmail.com>
parents: 94670
diff changeset
1545 (reftex-index-phrases-restrict-file (buffer-file-name)))
26910
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1546 (save-excursion
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1547 (save-restriction
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1548 (narrow-to-region beg end)
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1549 (unwind-protect
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1550 (progn
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1551 ;; Hide the region highlighting
87941
d77b6e5ee8af * sieve.el (sieve-make-overlay, sieve-overlay-put, sieve-overlays-at):
Dan Nicolaescu <dann@ics.uci.edu>
parents: 87649
diff changeset
1552 (if (featurep 'xemacs)
d77b6e5ee8af * sieve.el (sieve-make-overlay, sieve-overlay-put, sieve-overlays-at):
Dan Nicolaescu <dann@ics.uci.edu>
parents: 87649
diff changeset
1553 (zmacs-deactivate-region)
d77b6e5ee8af * sieve.el (sieve-make-overlay, sieve-overlay-put, sieve-overlays-at):
Dan Nicolaescu <dann@ics.uci.edu>
parents: 87649
diff changeset
1554 (deactivate-mark))
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1555 (delete-other-windows)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1556 (reftex-index-visit-phrases-buffer)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1557 (reftex-index-all-phrases))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1558 (set-window-configuration win-conf))))))
26910
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1559
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1560 (defun reftex-index-new-phrase (&optional text)
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1561 "Open a new line in the phrases buffer, insert TEXT."
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1562 (interactive)
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1563 (if (and text (stringp text))
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1564 (progn
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1565 ;; Check if the phrase is already in the buffer
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1566 (setq text (reftex-index-simplify-phrase text))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1567 (goto-char (point-min))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1568 (if (re-search-forward
99383
a5f24b6e48ef * international/mule-cmds.el (toggle-enable-multibyte-characters)
Juanma Barranquero <lekktu@gmail.com>
parents: 94670
diff changeset
1569 (concat "^\\(\\S-*\\)\t\\(" (regexp-quote text)
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1570 "\\) *[\t\n]") nil t)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1571 (progn
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1572 (goto-char (match-end 2))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1573 (error "Phrase is already in phrases buffer")))))
26910
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1574 ;; Add the new phrase line after the last in the buffer
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1575 (goto-char (point-max))
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1576 (if (re-search-backward reftex-index-phrases-phrase-regexp12 nil t)
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1577 (end-of-line))
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1578 (if (not (bolp))
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1579 (insert "\n"))
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1580 (insert "\t")
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1581 (if (and text (stringp text))
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1582 (insert text)))
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1583
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1584 (defun reftex-index-find-next-conflict-phrase (&optional arg)
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1585 "Find the next a phrase which is has conflicts in the phrase buffer.
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1586 The command helps to find possible conflicts in the phrase indexing process.
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1587 It searches downward from point for a phrase which is repeated elsewhere
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1588 in the buffer, or which is a subphrase of another phrase. If such a
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1589 phrase is found, the phrase info is displayed.
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1590 To check the whole buffer, start at the beginning and continue by calling
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1591 this function repeatedly."
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1592 (interactive "P")
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1593 (if (catch 'exit
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1594 (while (re-search-forward reftex-index-phrases-phrase-regexp12 nil t)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1595 (goto-char (match-beginning 3))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1596 (let* ((phrase (match-string 3))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1597 (case-fold-search reftex-index-phrases-case-fold-search)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1598 (re (reftex-index-phrases-find-dup-re phrase t)))
99383
a5f24b6e48ef * international/mule-cmds.el (toggle-enable-multibyte-characters)
Juanma Barranquero <lekktu@gmail.com>
parents: 94670
diff changeset
1599 (if (save-excursion
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1600 (goto-char (point-min))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1601 (and (re-search-forward re nil t)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1602 (re-search-forward re nil t)))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1603 (throw 'exit t)))))
26910
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1604 (progn
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1605 (reftex-index-phrases-info)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1606 (message "Phrase with match conflict discovered"))
26910
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1607 (goto-char (point-max))
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1608 (error "No further problematic phrases found")))
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1609
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1610 (defun reftex-index-phrases-info ()
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1611 "Display information about the phrase at point."
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1612 (interactive)
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1613 (save-excursion
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1614 (beginning-of-line)
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1615 (unless (looking-at reftex-index-phrases-phrase-regexp12)
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1616 (error "Not a phrase line"))
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1617 (save-match-data (reftex-index-phrases-parse-header t))
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1618 (let* ((char (if (not (equal (match-string 1) ""))
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1619 (string-to-char (match-string 1))))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1620 (phrase (match-string 3))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1621 (index-key (match-string 6))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1622 (index-keys (split-string
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1623 (or index-key phrase)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1624 reftex-index-phrases-logical-or-regexp))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1625 (macro-data (cdr (if (null char)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1626 (car reftex-index-phrases-macro-data)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1627 (assoc char reftex-index-phrases-macro-data))))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1628 (macro-fmt (car macro-data))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1629 (repeat (nth 1 macro-data))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1630 (as-words reftex-index-phrases-search-whole-words)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1631 (example (reftex-index-make-replace-string
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1632 macro-fmt (downcase phrase) (car index-keys) repeat))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1633 (re (reftex-index-make-phrase-regexp phrase as-words t))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1634 (re1 (reftex-index-phrases-find-dup-re phrase))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1635 (re2 (reftex-index-phrases-find-dup-re phrase 'sub))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1636 superphrases
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1637 (nmatches 0)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1638 (ntimes1 0)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1639 (ntimes2 0)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1640 (case-fold-search reftex-index-phrases-case-fold-search)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1641 file files buf)
26910
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1642 (setq files reftex-index-phrases-files)
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1643 (save-excursion
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1644 (save-restriction
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1645 (widen)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1646 (goto-char (point-min))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1647 (while (re-search-forward re1 nil t)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1648 (incf ntimes1))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1649 (goto-char (point-min))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1650 (while (re-search-forward re2 nil t)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1651 (push (cons (count-lines 1 (point)) (match-string 1)) superphrases)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1652 (incf ntimes2))))
105813
df4934f25eef * textmodes/two-column.el (2C-split):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 104768
diff changeset
1653 (save-current-buffer
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1654 (while (setq file (pop files))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1655 (setq buf (reftex-get-file-buffer-force file))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1656 (when buf
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1657 (set-buffer buf)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1658 (save-excursion
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1659 (save-restriction
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1660 (widen)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1661 (goto-char (point-min))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1662 (let ((case-fold-search reftex-index-phrases-case-fold-search))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1663 (while (re-search-forward re nil t)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1664 (or (reftex-in-comment)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1665 (incf nmatches)))))))))
26910
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1666 (with-output-to-temp-buffer "*Help*"
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1667 (princ (format " Phrase: %s\n" phrase))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1668 (princ (format " Macro key: %s\n" char))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1669 (princ (format " Macro format: %s\n" macro-fmt))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1670 (princ (format " Repeat: %s\n" repeat))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1671 (cond
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1672 (index-key
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1673 (let ((iks index-keys) (cnt 0) ik)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1674 (while (setq ik (pop iks))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1675 (princ (format "Index entry %d: %s\n" (incf cnt) ik)))))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1676 (repeat
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1677 (princ (format " Index entry: %s\n" phrase)))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1678 (t
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1679 (princ (format " Index key: <<Given by the match>>\n"))))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1680 (princ (format " Example: %s\n" example))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1681 (terpri)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1682 (princ (format "Total matches: %s in %s\n"
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1683 (reftex-number nmatches "match" "es")
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1684 (reftex-number (length reftex-index-phrases-files)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1685 "LaTeX file")))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1686 (princ (format " Uniqueness: Phrase occurs %s in phrase buffer\n"
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1687 (reftex-number ntimes1 "time")))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1688 (if (> ntimes2 1)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1689 (progn
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1690 (princ (format " Superphrases: Phrase matches the following %s in the phrase buffer:\n"
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1691 (reftex-number ntimes2 "line")))
99383
a5f24b6e48ef * international/mule-cmds.el (toggle-enable-multibyte-characters)
Juanma Barranquero <lekktu@gmail.com>
parents: 94670
diff changeset
1692 (mapcar (lambda(x)
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1693 (princ (format " Line %4d: %s\n" (car x) (cdr x))))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1694 (nreverse superphrases))))))))
26910
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1695
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1696 (defun reftex-index-phrases-set-macro-key ()
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1697 "Change the macro key for the current line.
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1698 Prompts for a macro key and insert is at the beginning of the line.
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1699 If you reply with SPACE, the macro keyn will be removed, so that the
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1700 default macro will be used. If you reply with `RET', just prints
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1701 information about the currently selected macro."
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1702 (interactive)
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1703 (reftex-index-phrases-parse-header)
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1704 (save-excursion
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1705 (beginning-of-line)
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1706 (unless (or (looking-at reftex-index-phrases-phrase-regexp12)
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1707 (looking-at "\t"))
26910
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1708 (error "This is not a phrase line"))
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1709 (let* ((nc (reftex-index-select-phrases-macro 0))
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1710 (macro-data (assoc nc reftex-index-phrases-macro-data))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1711 macro-fmt repeat)
26910
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1712 (cond (macro-data)
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1713 ((equal nc ?\ )
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1714 (setq nc ""
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1715 macro-data (car reftex-index-phrases-macro-data)))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1716 ((equal nc ?\C-m)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1717 (setq nc (char-after (point)))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1718 (if (equal nc ?\t)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1719 (setq nc ""
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1720 macro-data (car reftex-index-phrases-macro-data))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1721 (setq macro-data (assoc nc reftex-index-phrases-macro-data))))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1722 (t (error "No macro associated with %c" nc)))
26910
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1723
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1724 (setq macro-fmt (nth 1 macro-data)
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1725 repeat (nth 2 macro-data))
26910
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1726 (if macro-data
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1727 (progn
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1728 (if (looking-at "[^\t]") (delete-char 1))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1729 (insert nc)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1730 (message "Line will use %s %s repeat" macro-fmt
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1731 (if repeat "with" "without")))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1732 (error "Abort")))))
26910
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1733
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1734 (defun reftex-index-sort-phrases (&optional chars-first)
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1735 "Sort the phrases lines in the buffer alphabetically.
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1736 Normally, this looks only at the phrases. With a prefix arg CHARS-FIRST,
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1737 it first compares the macro identifying chars and then the phrases."
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1738 (interactive "P")
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1739 ;; Remember the current line, so that we can return
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1740 (let ((line (buffer-substring (progn (beginning-of-line) (point))
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1741 (progn (end-of-line) (point))))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1742 beg end)
26910
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1743 (goto-char (point-min))
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1744 ;; Find first and last phrase line in buffer
99383
a5f24b6e48ef * international/mule-cmds.el (toggle-enable-multibyte-characters)
Juanma Barranquero <lekktu@gmail.com>
parents: 94670
diff changeset
1745 (setq beg
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1746 (and (re-search-forward reftex-index-phrases-phrase-regexp12 nil t)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1747 (match-beginning 0)))
26910
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1748 (goto-char (point-max))
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1749 (setq end (re-search-backward reftex-index-phrases-phrase-regexp12 nil t))
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1750 (if end (setq end (progn (goto-char end) (end-of-line) (point))))
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1751 ;; Take the lines, sort them and re-insert.
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1752 (if (and beg end)
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1753 (progn
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1754 (message "Sorting lines...")
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1755 (let* ((lines (split-string (buffer-substring beg end) "\n"))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1756 (lines1 (sort lines 'reftex-compare-phrase-lines)))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1757 (message "Sorting lines...done")
111333
de02b794c330 Don't be so lax with spelling.
Glenn Morris <rgm@gnu.org>
parents: 110015
diff changeset
1758 (let ((inhibit-quit t)) ;; make sure we do not lose lines
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1759 (delete-region beg end)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1760 (insert (mapconcat 'identity lines1 "\n"))))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1761 (goto-char (point-max))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1762 (re-search-backward (concat "^" (regexp-quote line) "$") nil t))
26910
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1763 (error "Cannot find phrases lines to sort"))))
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1764
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1765 (defvar chars-first)
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1766 (defun reftex-compare-phrase-lines (a b)
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1767 "The comparison function used for sorting."
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1768 (let (ca cb pa pb c-p p-p)
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1769 (if (string-match reftex-index-phrases-phrase-regexp12 a)
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1770 (progn
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1771 ;; Extract macro char and phrase-or-key for a
99383
a5f24b6e48ef * international/mule-cmds.el (toggle-enable-multibyte-characters)
Juanma Barranquero <lekktu@gmail.com>
parents: 94670
diff changeset
1772 (setq ca (match-string 1 a)
a5f24b6e48ef * international/mule-cmds.el (toggle-enable-multibyte-characters)
Juanma Barranquero <lekktu@gmail.com>
parents: 94670
diff changeset
1773 pa (downcase
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1774 (or (and reftex-index-phrases-sort-prefers-entry
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1775 (match-string 6 a))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1776 (match-string 3 a))))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1777 (if (string-match reftex-index-phrases-phrase-regexp12 b)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1778 (progn
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1779 ;; Extract macro char and phrase-or-key for b
99383
a5f24b6e48ef * international/mule-cmds.el (toggle-enable-multibyte-characters)
Juanma Barranquero <lekktu@gmail.com>
parents: 94670
diff changeset
1780 (setq cb (match-string 1 b)
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1781 pb (downcase
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1782 (or (and reftex-index-phrases-sort-prefers-entry
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1783 (match-string 6 b))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1784 (match-string 3 b))))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1785 (setq c-p (string< ca cb)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1786 p-p (string< pa pb))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1787 ;; Do the right comparison, based on the value of `chars-first'
99383
a5f24b6e48ef * international/mule-cmds.el (toggle-enable-multibyte-characters)
Juanma Barranquero <lekktu@gmail.com>
parents: 94670
diff changeset
1788 ;; `chars-first' is bound locally in the calling function
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1789 (if chars-first
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1790 (if (string= ca cb) p-p c-p)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1791 (if (string= pa pb) c-p p-p)))))
26910
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1792 ;; If line a does not match, the answer we return determines
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1793 ;; if non-matching lines are collected at the beginning.
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1794 ;; When we return t here, non-matching lines form
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1795 ;; block separators for searches.
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1796 (not reftex-index-phrases-sort-in-blocks))))
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1797
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1798 (defvar reftex-index-phrases-menu)
99383
a5f24b6e48ef * international/mule-cmds.el (toggle-enable-multibyte-characters)
Juanma Barranquero <lekktu@gmail.com>
parents: 94670
diff changeset
1799 (defun reftex-index-make-phrase-regexp (phrase &optional
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1800 as-words allow-newline)
26910
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1801 "Return a regexp matching PHRASE, even if distributed over lines.
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1802 With optional arg AS-WORDS, require word boundary at beginning and end.
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1803 With optional arg ALLOW-NEWLINE, allow single newline between words."
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1804 (let* ((words (split-string phrase))
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1805 (space-re (if allow-newline
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1806 "\\([ \t]*\\(\n[ \t]*\\)?\\|[ \t]\\)"
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1807 "\\([ \t]+\\)")))
26910
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1808 (concat (if (and as-words (string-match "\\`\\w" (car words)))
59534
9bad65481674 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 52401
diff changeset
1809 "\\(\\<\\|[`']\\)" "")
99383
a5f24b6e48ef * international/mule-cmds.el (toggle-enable-multibyte-characters)
Juanma Barranquero <lekktu@gmail.com>
parents: 94670
diff changeset
1810 (mapconcat (lambda (w) (regexp-quote
59534
9bad65481674 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 52401
diff changeset
1811 (if reftex-index-phrases-case-fold-search
9bad65481674 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 52401
diff changeset
1812 (downcase w)
9bad65481674 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 52401
diff changeset
1813 w)))
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1814 words space-re)
99383
a5f24b6e48ef * international/mule-cmds.el (toggle-enable-multibyte-characters)
Juanma Barranquero <lekktu@gmail.com>
parents: 94670
diff changeset
1815 (if (and as-words
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1816 (string-match "\\w\\'" (nth (1- (length words)) words)))
59534
9bad65481674 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 52401
diff changeset
1817 "\\(\\>\\|'\\)" ""))))
26910
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1818
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1819 (defun reftex-index-simplify-phrase (phrase)
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1820 "Make phrase single spaces and single line."
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1821 (mapconcat 'identity (split-string phrase) " "))
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1822
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1823 (defun reftex-index-phrases-find-dup-re (phrase &optional sub)
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1824 "Return a regexp which matches variations of PHRASE (with additional space).
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1825 When SUB ins non-nil, the regexp will also match when PHRASE is a subphrase
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1826 of another phrase. The regexp works lonly in the phrase buffer."
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1827 (concat (if sub "^\\S-?\t\\([^\t\n]*" "^\\S-?\t")
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1828 (mapconcat 'regexp-quote (split-string phrase) " +")
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1829 (if sub "[^\t\n]*\\)\\([\t\n]\\|$\\)" " *\\([\t\n]\\|$\\)")))
26910
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1830
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1831 (defun reftex-index-make-replace-string (macro-fmt match index-key
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1832 &optional repeat mathp)
26910
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1833 "Return the string which can be used as replacement.
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1834 Treats the logical `and' for index phrases."
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1835 (let ((index-keys (split-string (or index-key match)
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1836 reftex-index-phrases-logical-and-regexp)))
26910
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1837 (concat
99383
a5f24b6e48ef * international/mule-cmds.el (toggle-enable-multibyte-characters)
Juanma Barranquero <lekktu@gmail.com>
parents: 94670
diff changeset
1838 (mapconcat (lambda (x)
a5f24b6e48ef * international/mule-cmds.el (toggle-enable-multibyte-characters)
Juanma Barranquero <lekktu@gmail.com>
parents: 94670
diff changeset
1839 (format macro-fmt
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1840 (format (if mathp reftex-index-math-format "%s") x)))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1841 index-keys "")
26910
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1842 (if repeat (reftex-index-simplify-phrase match) ""))))
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1843
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1844 (defun reftex-query-index-phrase-globally (files &rest args)
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1845 "Call `reftex-query-index-phrase' for all files in FILES."
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1846 (let ((win-conf (current-window-configuration))
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1847 (file))
26910
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1848 (unless files (error "No files"))
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1849 (unwind-protect
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1850 (progn
99383
a5f24b6e48ef * international/mule-cmds.el (toggle-enable-multibyte-characters)
Juanma Barranquero <lekktu@gmail.com>
parents: 94670
diff changeset
1851 (switch-to-buffer-other-window (reftex-get-file-buffer-force
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1852 (car files)))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1853 (catch 'no-more-files
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1854 (while (setq file (pop files))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1855 (switch-to-buffer (reftex-get-file-buffer-force file))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1856 (save-excursion
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1857 (save-restriction
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1858 (unless (stringp reftex-index-phrases-restrict-file)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1859 (widen))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1860 (goto-char (point-min))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1861 (apply 'reftex-query-index-phrase args))))))
26910
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1862 (reftex-unhighlight 0)
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1863 (set-window-configuration win-conf))))
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1864
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1865 (defconst reftex-index-phrases-help
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1866 " Keys for query-index search
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1867 ===========================
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1868 y Replace this match
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1869 n Skip this match
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1870 ! Replace this and all further matches in this file
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1871 q / Q Skip match, start next file / start next phrase
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1872 o Use a different indexing macro for this match
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1873 1 - 9 Select one of the multiple phrases
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1874 e Edit the replacement text
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1875 C-r Recursive edit.
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1876 s / S Save this buffer / Save all document buffers
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1877 C-g Abort"
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1878 "The help string for indexing phrases.")
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1879
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1880 (defvar replace-count)
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1881 (defun reftex-query-index-phrase (phrase macro-fmt &optional
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1882 index-key repeat as-words)
26910
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1883 "Search through buffer for PHRASE, and offer to replace it with an indexed
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1884 version. The index version is derived by applying `format' with MACRO-FMT
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1885 to INDEX-KEY or PHRASE. When REPEAT is non-nil, the PHRASE is inserted
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1886 again after the macro.
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1887 AS-WORDS means, the search for PHRASE should require word boundaries at
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1888 both ends."
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1889 (let* ((re (reftex-index-make-phrase-regexp phrase as-words 'allow-newline))
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1890 (case-fold-search reftex-index-phrases-case-fold-search)
99383
a5f24b6e48ef * international/mule-cmds.el (toggle-enable-multibyte-characters)
Juanma Barranquero <lekktu@gmail.com>
parents: 94670
diff changeset
1891 (index-keys (split-string
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1892 (or index-key phrase)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1893 reftex-index-phrases-logical-or-regexp))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1894 (nkeys (length index-keys))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1895 (ckey (nth 0 index-keys))
99383
a5f24b6e48ef * international/mule-cmds.el (toggle-enable-multibyte-characters)
Juanma Barranquero <lekktu@gmail.com>
parents: 94670
diff changeset
1896 (all-yes nil)
65548
253cad16882d Little fixes to remove compiler warnings
Carsten Dominik <dominik@science.uva.nl>
parents: 65269
diff changeset
1897 match rpl char (beg (make-marker)) (end (make-marker)) mathp)
253cad16882d Little fixes to remove compiler warnings
Carsten Dominik <dominik@science.uva.nl>
parents: 65269
diff changeset
1898 (move-marker beg 1)
253cad16882d Little fixes to remove compiler warnings
Carsten Dominik <dominik@science.uva.nl>
parents: 65269
diff changeset
1899 (move-marker end 1)
26910
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
1900 (unwind-protect
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1901 (while (re-search-forward re nil t)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1902 (catch 'next-match
59534
9bad65481674 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 52401
diff changeset
1903 (if (reftex-in-comment)
9bad65481674 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 52401
diff changeset
1904 (throw 'next-match nil))
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1905 (if (and (fboundp reftex-index-verify-function)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1906 (not (funcall reftex-index-verify-function)))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1907 (throw 'next-match nil))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1908 (setq match (match-string 0))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1909 (setq mathp
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1910 (save-match-data
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1911 (condition-case nil (texmathp) (error nil))))
65548
253cad16882d Little fixes to remove compiler warnings
Carsten Dominik <dominik@science.uva.nl>
parents: 65269
diff changeset
1912 (setq beg (move-marker beg (match-beginning 0))
253cad16882d Little fixes to remove compiler warnings
Carsten Dominik <dominik@science.uva.nl>
parents: 65269
diff changeset
1913 end (move-marker end (match-end 0)))
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1914 (if (and reftex-index-phrases-skip-indexed-matches
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1915 (save-match-data
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1916 (reftex-index-phrase-match-is-indexed beg
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1917 end)))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1918 (throw 'next-match nil))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1919 (reftex-highlight 0 (match-beginning 0) (match-end 0))
99383
a5f24b6e48ef * international/mule-cmds.el (toggle-enable-multibyte-characters)
Juanma Barranquero <lekktu@gmail.com>
parents: 94670
diff changeset
1920 (setq rpl
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1921 (save-match-data
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1922 (reftex-index-make-replace-string
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1923 macro-fmt (match-string 0) ckey repeat mathp)))
99383
a5f24b6e48ef * international/mule-cmds.el (toggle-enable-multibyte-characters)
Juanma Barranquero <lekktu@gmail.com>
parents: 94670
diff changeset
1924 (while
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1925 (not
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1926 (catch 'loop
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1927 (message "REPLACE: %s? (yn!qoe%s?)"
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1928 rpl
99383
a5f24b6e48ef * international/mule-cmds.el (toggle-enable-multibyte-characters)
Juanma Barranquero <lekktu@gmail.com>
parents: 94670
diff changeset
1929 (if (> nkeys 1)
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1930 (concat "1-" (int-to-string nkeys))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1931 ""))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1932 (setq char (if all-yes ?y (read-char-exclusive)))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1933 (cond ((member char '(?y ?Y ?\ ))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1934 ;; Yes!
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1935 (replace-match rpl t t)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1936 (incf replace-count)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1937 ;; See if we should insert newlines to shorten lines
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1938 (and reftex-index-phrases-wrap-long-lines
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1939 (reftex-index-phrases-fixup-line beg end))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1940 (throw 'loop t))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1941 ((member char '(?n ?N ?\C-h ?\C-?));; FIXME: DEL
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1942 ;; No
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1943 (throw 'loop t))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1944 ((equal char ?!)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1945 ;; Yes for all in this buffer
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1946 (setq all-yes t))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1947 ((equal char ?q)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1948 ;; Stop this one in this file
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1949 (goto-char (point-max))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1950 (throw 'loop t))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1951 ((equal char ?Q)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1952 ;; Stop this one
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1953 (throw 'no-more-files t))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1954 ((equal char ?s)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1955 (save-buffer))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1956 ((equal char ?S)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1957 (reftex-save-all-document-buffers))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1958 ((equal char ?\C-g)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1959 (keyboard-quit))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1960 ((member char '(?o ?O))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1961 ;; Select a differnt macro
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1962 (let* ((nc (reftex-index-select-phrases-macro 2))
99383
a5f24b6e48ef * international/mule-cmds.el (toggle-enable-multibyte-characters)
Juanma Barranquero <lekktu@gmail.com>
parents: 94670
diff changeset
1963 (macro-data
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1964 (cdr (assoc nc reftex-index-phrases-macro-data)))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1965 (macro-fmt (car macro-data))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1966 (repeat (nth 1 macro-data)))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1967 (if macro-data
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1968 (setq rpl (save-match-data
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1969 (reftex-index-make-replace-string
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1970 macro-fmt match
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1971 ckey repeat mathp)))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1972 (ding))))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1973 ((equal char ?\?)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1974 ;; Help
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1975 (with-output-to-temp-buffer "*Help*"
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1976 (princ reftex-index-phrases-help)))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1977 ((equal char ?\C-r)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1978 ;; Recursive edit
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1979 (save-match-data
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1980 (save-excursion
99383
a5f24b6e48ef * international/mule-cmds.el (toggle-enable-multibyte-characters)
Juanma Barranquero <lekktu@gmail.com>
parents: 94670
diff changeset
1981 (message "%s"
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1982 (substitute-command-keys
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1983 "Recursive edit. Resume with \\[exit-recursive-edit]"))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1984 (recursive-edit))))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1985 ((equal char ?e)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1986 (setq rpl (read-string "Edit: " rpl)))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1987 ((equal char ?0)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1988 (setq ckey (or index-key phrase)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1989 rpl (save-match-data
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1990 (reftex-index-make-replace-string
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1991 macro-fmt match ckey repeat mathp))))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1992 ((and (> char ?0)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1993 (<= char (+ ?0 nkeys)))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1994 (setq ckey (nth (1- (- char ?0)) index-keys)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1995 rpl (save-match-data
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1996 (reftex-index-make-replace-string
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1997 macro-fmt match ckey repeat mathp))))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1998 (t (ding)))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
1999 nil)))))
26910
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
2000 (message "")
65548
253cad16882d Little fixes to remove compiler warnings
Carsten Dominik <dominik@science.uva.nl>
parents: 65269
diff changeset
2001 (move-marker beg nil)
253cad16882d Little fixes to remove compiler warnings
Carsten Dominik <dominik@science.uva.nl>
parents: 65269
diff changeset
2002 (move-marker end nil)
26910
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
2003 (setq all-yes nil)
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
2004 (reftex-unhighlight 0))))
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
2005
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
2006 (defun reftex-index-phrase-match-is-indexed (beg end)
59534
9bad65481674 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 52401
diff changeset
2007 ;; Check if match is in an argument of an index macro, or if an
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
2008 ;; index macro is directly attached to the match.
26910
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
2009 (save-excursion
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
2010 (goto-char end)
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
2011 (let* ((all-macros (reftex-what-macro t))
65548
253cad16882d Little fixes to remove compiler warnings
Carsten Dominik <dominik@science.uva.nl>
parents: 65269
diff changeset
2012 ; (this-macro (car (car all-macros)))
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
2013 (before-macro
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
2014 (and (> beg 2)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
2015 (goto-char (1- beg))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
2016 (memq (char-after (point)) '(?\] ?\}))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
2017 (car (reftex-what-macro 1))))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
2018 (after-macro
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
2019 (and (goto-char end)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
2020 (looking-at "\\(\\\\[a-zA-Z]+\\*?\\)[[{]")
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
2021 (match-string 1)))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
2022 macro)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
2023 (or (catch 'matched
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
2024 (while (setq macro (pop all-macros))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
2025 (if (member (car macro) reftex-macros-with-index)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
2026 (throw 'matched t)))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
2027 nil)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
2028 (and before-macro
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
2029 (member before-macro reftex-macros-with-index))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
2030 (and after-macro
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
2031 (member after-macro reftex-macros-with-index))))))
49599
5ade352e8d1c Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47050
diff changeset
2032
26910
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
2033 (defun reftex-index-phrases-fixup-line (beg end)
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
2034 "Insert newlines before BEG and/or after END to shorten line."
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
2035 (let (bol eol space1 space2)
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
2036 (save-excursion
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
2037 ;; Find line boundaries and possible line breaks near BEG and END
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
2038 (beginning-of-line)
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
2039 (setq bol (point))
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
2040 (end-of-line)
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
2041 (setq eol (point))
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
2042 (goto-char beg)
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
2043 (skip-chars-backward "^ \n")
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
2044 (if (and (equal (preceding-char) ?\ )
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
2045 (string-match "\\S-" (buffer-substring bol (point))))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
2046 (setq space1 (1- (point))))
26910
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
2047 (goto-char end)
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
2048 (skip-chars-forward "^ \n")
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
2049 (if (and (equal (following-char) ?\ )
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
2050 (string-match "\\S-" (buffer-substring (point) eol)))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
2051 (setq space2 (point)))
26910
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
2052 ;; Now check what we have and insert the newlines
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
2053 (if (<= (- eol bol) fill-column)
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
2054 ;; Line is already short
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
2055 nil
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
2056 (cond
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
2057 ((and (not space1) (not space2))) ; No spaces available
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
2058 ((not space2) ; Do space1
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
2059 (reftex-index-phrases-replace-space space1))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
2060 ((not space1) ; Do space2
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
2061 (reftex-index-phrases-replace-space space2))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
2062 (t ; We have both spaces
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
2063 (let ((l1 (- space1 bol))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
2064 (l2 (- space2 space1))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
2065 (l3 (- eol space2)))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
2066 (if (> l2 fill-column)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
2067 ;; The central part alone is more than one line
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
2068 (progn
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
2069 (reftex-index-phrases-replace-space space1)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
2070 (reftex-index-phrases-replace-space space2))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
2071 (if (> (+ l1 l2) fill-column)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
2072 ;; Need to split beginning
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
2073 (reftex-index-phrases-replace-space space1))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
2074 (if (> (+ l2 l3) fill-column)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
2075 ;; Need to split end
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
2076 (reftex-index-phrases-replace-space space2))))))))))
26910
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
2077
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
2078 (defun reftex-index-phrases-replace-space (pos)
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
2079 "If there is a space at POS, replace it with a newline char.
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
2080 Does not do a save-excursion."
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
2081 (when (equal (char-after pos) ?\ )
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
2082 (goto-char pos)
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
2083 (delete-char 1)
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
2084 (insert "\n")))
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
2085
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
2086 (defun reftex-index-select-phrases-macro (&optional delay)
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
2087 "Offer a list of possible index macros and have the user select one."
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
2088 (let* ((prompt (concat "Select macro: ["
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
2089 (mapconcat (lambda (x) (char-to-string (car x)))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
2090 reftex-index-phrases-macro-data "")
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
2091 "] "))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
2092 (help (concat "Select an indexing macro\n========================\n"
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
2093 (mapconcat (lambda (x)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
2094 (format " [%c] %s"
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
2095 (car x) (nth 1 x)))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
2096 reftex-index-phrases-macro-data "\n"))))
26910
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
2097 (reftex-select-with-char prompt help delay)))
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
2098
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
2099
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2100 ;;; reftex-index.el ends here