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