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