Mercurial > emacs
annotate lisp/textmodes/reftex-toc.el @ 26340:f1ae5b57d9db
Changed the mail addess of the maintainer.
author | Francesco Potortì <pot@gnu.org> |
---|---|
date | Wed, 03 Nov 1999 23:13:10 +0000 |
parents | 7ed67319c5aa |
children | 489a5439b988 |
rev | line source |
---|---|
25280 | 1 ;;; reftex-toc.el - RefTeX's table of contents mode |
25806
7ed67319c5aa
version number change
Carsten Dominik <dominik@science.uva.nl>
parents:
25280
diff
changeset
|
2 ;;; Version: 4.6 |
25280 | 3 ;;; |
4 ;;; See main file reftex.el for licensing information | |
5 | |
6 (provide 'reftex-toc) | |
7 (require 'reftex) | |
8 ;;; | |
9 | |
10 (defvar reftex-toc-map (make-sparse-keymap) | |
11 "Keymap used for *toc* buffer.") | |
12 | |
13 (defvar reftex-toc-menu) | |
14 | |
15 (defun reftex-toc-mode () | |
16 "Major mode for managing Table of Contents for LaTeX files. | |
17 This buffer was created with RefTeX. | |
18 Press `?' for a summary of important key bindings. | |
19 | |
20 Here are all local bindings. | |
21 | |
22 \\{reftex-toc-map}" | |
23 (interactive) | |
24 (kill-all-local-variables) | |
25 (setq major-mode 'reftex-toc-mode | |
26 mode-name "TOC") | |
27 (use-local-map reftex-toc-map) | |
28 (set (make-local-variable 'revert-buffer-function) 'reftex-toc-revert) | |
29 (set (make-local-variable 'reftex-toc-include-labels-indicator) "") | |
30 (set (make-local-variable 'reftex-toc-include-index-indicator) "") | |
31 (setq mode-line-format | |
32 (list "---- " 'mode-line-buffer-identification | |
33 " " 'global-mode-string " (" mode-name ")" | |
34 " L<" 'reftex-toc-include-labels-indicator ">" | |
35 " I<" 'reftex-toc-include-index-indicator ">" | |
36 " -%-")) | |
37 (setq truncate-lines t) | |
38 (make-local-hook 'post-command-hook) | |
39 (make-local-hook 'pre-command-hook) | |
40 (make-local-variable 'reftex-last-follow-point) | |
41 (add-hook 'post-command-hook 'reftex-toc-post-command-hook nil t) | |
42 (add-hook 'pre-command-hook 'reftex-toc-pre-command-hook nil t) | |
43 (easy-menu-add reftex-toc-menu reftex-toc-map) | |
44 (run-hooks 'reftex-toc-mode-hook)) | |
45 | |
46 (defvar reftex-last-toc-file nil | |
47 "Stores the file name from which `reftex-toc' was called. For redo command.") | |
48 | |
49 (defvar reftex-last-window-height nil) | |
50 (defvar reftex-toc-include-labels-indicator nil) | |
51 (defvar reftex-toc-include-index-indicator nil) | |
52 | |
53 (defvar reftex-toc-return-marker (make-marker) | |
54 "Marker which makes it possible to return from toc to old position.") | |
55 | |
56 (defconst reftex-toc-help | |
57 " AVAILABLE KEYS IN TOC BUFFER | |
58 ============================ | |
59 n / p next-line / previous-line | |
60 SPC Show the corresponding location of the LaTeX document. | |
61 TAB Goto the location and keep the *toc* window. | |
62 RET Goto the location and hide the *toc* window (also on mouse-2). | |
63 C-c > Display Index. With prefix arg, restrict index to current section. | |
64 q / k Hide/Kill *toc* buffer, return to position of reftex-toc command. | |
65 l i c F Toggle display of [l]abels, [i]ndex, [c]ontext, [F]ile borders. | |
66 f / g Toggle follow mode on and off / Refresh *toc* buffer. | |
67 r / C-u r Reparse the LaTeX document / Reparse entire LaTeX document. | |
68 . In other window, show position from where `reftex-toc' was called. | |
69 x Switch to TOC of external document (with LaTeX package `xr').") | |
70 | |
71 (defun reftex-toc (&optional rebuild) | |
72 "Show the table of contents for the current document. | |
73 When called with a raw C-u prefix, rescan the document first." | |
74 | |
75 (interactive) | |
76 | |
77 (if (or (not (string= reftex-last-toc-master (reftex-TeX-master-file))) | |
78 current-prefix-arg) | |
79 (reftex-erase-buffer "*toc*")) | |
80 | |
81 (setq reftex-last-toc-file (buffer-file-name)) | |
82 (setq reftex-last-toc-master (reftex-TeX-master-file)) | |
83 | |
84 (set-marker reftex-toc-return-marker (point)) | |
85 | |
86 ;; If follow mode is active, arrange to delay it one command | |
87 (if reftex-toc-follow-mode | |
88 (setq reftex-toc-follow-mode 1)) | |
89 | |
90 (and reftex-toc-include-index-entries | |
91 (reftex-ensure-index-support)) | |
92 (or reftex-support-index | |
93 (setq reftex-toc-include-index-entries nil)) | |
94 | |
95 ;; Ensure access to scanning info and rescan buffer if prefix are is '(4) | |
96 (reftex-access-scan-info current-prefix-arg) | |
97 | |
98 (let* ((this-buf (current-buffer)) | |
99 (docstruct-symbol reftex-docstruct-symbol) | |
100 (xr-data (assq 'xr (symbol-value reftex-docstruct-symbol))) | |
101 (xr-alist (cons (cons "" (buffer-file-name)) (nth 1 xr-data))) | |
102 (here-I-am (if rebuild | |
103 (get 'reftex-toc :reftex-data) | |
104 (car (reftex-where-am-I)))) | |
105 offset) | |
106 | |
107 (if (get-buffer-window "*toc*") | |
108 (select-window (get-buffer-window "*toc*")) | |
109 (when (or (not reftex-toc-keep-other-windows) | |
110 (< (window-height) (* 2 window-min-height))) | |
111 (delete-other-windows)) | |
112 (setq reftex-last-window-height (window-height)) ; remember | |
113 (split-window) | |
114 (let ((default-major-mode 'reftex-toc-mode)) | |
115 (switch-to-buffer "*toc*"))) | |
116 | |
117 (or (eq major-mode 'reftex-toc-mode) (reftex-toc-mode)) | |
118 (set (make-local-variable 'reftex-docstruct-symbol) docstruct-symbol) | |
119 (setq reftex-toc-include-labels-indicator | |
120 (if (eq reftex-toc-include-labels t) | |
121 "ALL" | |
122 reftex-toc-include-labels)) | |
123 (setq reftex-toc-include-index-indicator | |
124 (if (eq reftex-toc-include-index-entries t) | |
125 "ALL" | |
126 reftex-toc-include-index-entries)) | |
127 | |
128 (cond | |
129 ((= (buffer-size) 0) | |
130 ;; buffer is empty - fill it with the table of contents | |
131 (message "Building *toc* buffer...") | |
132 | |
133 (setq buffer-read-only nil) | |
134 (insert (format | |
135 "TABLE-OF-CONTENTS on %s | |
136 SPC=view TAB=goto RET=goto+hide [q]uit [r]escan [l]abels [f]ollow [x]r [?]Help | |
137 ------------------------------------------------------------------------------ | |
138 " (abbreviate-file-name reftex-last-toc-master))) | |
139 | |
140 (if (reftex-use-fonts) | |
141 (put-text-property 1 (point) 'face reftex-toc-header-face)) | |
142 (put-text-property 1 (point) 'intangible t) | |
143 (put-text-property 1 2 'xr-alist xr-alist) | |
144 | |
145 (setq offset | |
146 (reftex-insert-docstruct | |
147 this-buf | |
148 t ; include toc | |
149 reftex-toc-include-labels | |
150 reftex-toc-include-index-entries | |
151 reftex-toc-include-file-boundaries | |
152 reftex-toc-include-context | |
153 nil ; counter | |
154 nil ; commented | |
155 here-I-am | |
156 "" ; xr-prefix | |
157 t ; a toc buffer | |
158 )) | |
159 | |
160 (run-hooks 'reftex-display-copied-context-hook) | |
161 (message "Building *toc* buffer...done.") | |
162 (setq buffer-read-only t)) | |
163 (t | |
164 ;; Only compute the offset | |
165 (setq offset | |
166 (or (reftex-get-offset this-buf here-I-am | |
167 (if reftex-toc-include-labels " " nil) | |
168 t | |
169 reftex-toc-include-index-entries | |
170 reftex-toc-include-file-boundaries) | |
171 (reftex-last-assoc-before-elt | |
172 'toc here-I-am | |
173 (symbol-value reftex-docstruct-symbol)))) | |
174 (put 'reftex-toc :reftex-line 3) | |
175 (goto-line 3) | |
176 (beginning-of-line))) | |
177 | |
178 ;; Find the correct starting point | |
179 (reftex-find-start-point (point) offset (get 'reftex-toc :reftex-line)) | |
180 (setq reftex-last-follow-point (point)))) | |
181 | |
182 (defun reftex-toc-pre-command-hook () | |
183 ;; used as pre command hook in *toc* buffer | |
184 (reftex-unhighlight 0) | |
185 (reftex-unhighlight 1)) | |
186 | |
187 (defun reftex-toc-post-command-hook () | |
188 ;; used in the post-command-hook for the *toc* buffer | |
189 (when (get-text-property (point) :data) | |
190 (put 'reftex-toc :reftex-data (get-text-property (point) :data)) | |
191 (and (> (point) 1) | |
192 (not (get-text-property (point) 'intangible)) | |
193 (memq reftex-highlight-selection '(cursor both)) | |
194 (reftex-highlight 1 | |
195 (or (previous-single-property-change (1+ (point)) :data) | |
196 (point-min)) | |
197 (or (next-single-property-change (point) :data) | |
198 (point-max))))) | |
199 (if (integerp reftex-toc-follow-mode) | |
200 ;; remove delayed action | |
201 (setq reftex-toc-follow-mode t) | |
202 (and reftex-toc-follow-mode | |
203 (not (equal reftex-last-follow-point (point))) | |
204 ;; show context in other window | |
205 (setq reftex-last-follow-point (point)) | |
206 (condition-case nil | |
207 (reftex-toc-visit-location nil (not reftex-revisit-to-follow)) | |
208 (error t))))) | |
209 | |
210 (defun reftex-re-enlarge () | |
211 ;; Enlarge windiw to a remembered size | |
212 (enlarge-window | |
213 (max 0 (- (or reftex-last-window-height (window-height)) | |
214 (window-height))))) | |
215 | |
216 (defun reftex-toc-show-help () | |
217 "Show a summary of special key bindings." | |
218 (interactive) | |
219 (with-output-to-temp-buffer "*RefTeX Help*" | |
220 (princ reftex-toc-help)) | |
221 (reftex-enlarge-to-fit "*RefTeX Help*" t) | |
222 ;; If follow mode is active, arrange to delay it one command | |
223 (if reftex-toc-follow-mode | |
224 (setq reftex-toc-follow-mode 1))) | |
225 | |
226 (defun reftex-toc-next (&optional arg) | |
227 "Move to next selectable item." | |
228 (interactive "p") | |
229 (setq reftex-callback-fwd t) | |
230 (or (eobp) (forward-char 1)) | |
231 (goto-char (or (next-single-property-change (point) :data) | |
232 (point)))) | |
233 (defun reftex-toc-previous (&optional arg) | |
234 "Move to previous selectable item." | |
235 (interactive "p") | |
236 (setq reftex-callback-fwd nil) | |
237 (goto-char (or (previous-single-property-change (point) :data) | |
238 (point)))) | |
239 (defun reftex-toc-next-heading (&optional arg) | |
240 "Move to next table of contentes line." | |
241 (interactive "p") | |
242 (end-of-line) | |
243 (re-search-forward "^ " nil t arg) | |
244 (beginning-of-line)) | |
245 (defun reftex-toc-previous-heading (&optional arg) | |
246 "Move to previous table of contentes line." | |
247 (interactive "p") | |
248 (re-search-backward "^ " nil t arg)) | |
249 (defun reftex-toc-toggle-follow () | |
250 "Toggle follow (other window follows with context)." | |
251 (interactive) | |
252 (setq reftex-last-follow-point -1) | |
253 (setq reftex-toc-follow-mode (not reftex-toc-follow-mode))) | |
254 (defun reftex-toc-toggle-file-boundary () | |
255 "Toggle inclusion of file boundaries in *toc* buffer." | |
256 (interactive) | |
257 (setq reftex-toc-include-file-boundaries | |
258 (not reftex-toc-include-file-boundaries)) | |
259 (reftex-toc-revert)) | |
260 (defun reftex-toc-toggle-labels (arg) | |
261 "Toggle inclusion of labels in *toc* buffer. | |
262 With prefix ARG, prompt for a label type and include only labels of | |
263 that specific type." | |
264 (interactive "P") | |
265 (setq reftex-toc-include-labels | |
266 (if arg (reftex-query-label-type) | |
267 (not reftex-toc-include-labels))) | |
268 (reftex-toc-revert)) | |
269 (defun reftex-toc-toggle-index (arg) | |
270 "Toggle inclusion of index in *toc* buffer. | |
271 With prefix arg, prompt for an index tag and include only entries of that | |
272 specific index." | |
273 (interactive "P") | |
274 (setq reftex-toc-include-index-entries | |
275 (if arg (reftex-index-select-tag) | |
276 (not reftex-toc-include-index-entries))) | |
277 (reftex-toc-revert)) | |
278 (defun reftex-toc-toggle-context () | |
279 "Toggle inclusion of label context in *toc* buffer. | |
280 Label context is only displayed when the labels are there as well." | |
281 (interactive) | |
282 (setq reftex-toc-include-context (not reftex-toc-include-context)) | |
283 (reftex-toc-revert)) | |
284 (defun reftex-toc-view-line () | |
285 "View document location in other window." | |
286 (interactive) | |
287 (reftex-toc-visit-location)) | |
288 (defun reftex-toc-goto-line-and-hide () | |
289 "Go to document location in other window. Hide the *toc* window." | |
290 (interactive) | |
291 (reftex-toc-visit-location 'hide)) | |
292 (defun reftex-toc-goto-line () | |
293 "Go to document location in other window. *toc* window stays." | |
294 (interactive) | |
295 (reftex-toc-visit-location t)) | |
296 (defun reftex-toc-mouse-goto-line-and-hide (ev) | |
297 "Go to document location in other window. Hide the *toc* window." | |
298 (interactive "e") | |
299 (mouse-set-point ev) | |
300 (reftex-toc-visit-location 'hide)) | |
301 (defun reftex-toc-show-calling-point () | |
302 "Show point where reftex-toc was called from." | |
303 (interactive) | |
304 (let ((this-window (selected-window))) | |
305 (unwind-protect | |
306 (progn | |
307 (switch-to-buffer-other-window | |
308 (marker-buffer reftex-toc-return-marker)) | |
309 (goto-char (marker-position reftex-toc-return-marker)) | |
310 (recenter '(4))) | |
311 (select-window this-window)))) | |
312 (defun reftex-toc-quit () | |
313 "Hide the *toc* window and do not move point." | |
314 (interactive) | |
315 (or (one-window-p) (delete-window)) | |
316 (switch-to-buffer (marker-buffer reftex-toc-return-marker)) | |
317 (reftex-re-enlarge) | |
318 (goto-char (or (marker-position reftex-toc-return-marker) (point)))) | |
319 (defun reftex-toc-quit-and-kill () | |
320 "Kill the *toc* buffer." | |
321 (interactive) | |
322 (kill-buffer "*toc*") | |
323 (or (one-window-p) (delete-window)) | |
324 (switch-to-buffer (marker-buffer reftex-toc-return-marker)) | |
325 (reftex-re-enlarge) | |
326 (goto-char (marker-position reftex-toc-return-marker))) | |
327 (defun reftex-toc-display-index (&optional arg) | |
328 "Display the index buffer for the current document. | |
329 This works just like `reftex-display-index' from a LaTeX buffer. | |
330 With prefix arg 1, restrict index to the section at point." | |
331 (interactive "P") | |
332 (let ((data (get-text-property (point) :data)) | |
333 (docstruct (symbol-value reftex-docstruct-symbol)) | |
334 bor eor restr) | |
335 (when (equal arg 2) | |
336 (setq bor (reftex-last-assoc-before-elt 'toc data docstruct) | |
337 eor (assoc 'toc (cdr (memq bor docstruct))) | |
338 restr (list (nth 6 bor) bor eor))) | |
339 (reftex-toc-goto-line) | |
340 (reftex-display-index (if restr nil arg) restr))) | |
341 (defun reftex-toc-rescan (&rest ignore) | |
342 "Regenerate the *toc* buffer by reparsing file of section at point." | |
343 (interactive) | |
344 (if (and reftex-enable-partial-scans | |
345 (null current-prefix-arg)) | |
346 (let* ((data (get-text-property (point) :data)) | |
347 (what (car data)) | |
348 (file (cond ((eq what 'toc) (nth 3 data)) | |
349 ((memq what '(eof bof file-error)) (nth 1 data)) | |
350 ((stringp what) (nth 3 data)) | |
351 ((eq what 'index) (nth 3 data)))) | |
352 (line (+ (count-lines (point-min) (point)) (if (bolp) 1 0)))) | |
353 (if (not file) | |
354 (error "Don't know which file to rescan. Try `C-u r'") | |
355 (put 'reftex-toc :reftex-line line) | |
356 (switch-to-buffer-other-window | |
357 (reftex-get-file-buffer-force file)) | |
358 (setq current-prefix-arg '(4)) | |
359 (reftex-toc t))) | |
360 (reftex-toc-Rescan)) | |
361 (reftex-kill-temporary-buffers)) | |
362 (defun reftex-toc-Rescan (&rest ignore) | |
363 "Regenerate the *toc* buffer by reparsing the entire document." | |
364 (interactive) | |
365 (switch-to-buffer-other-window | |
366 (reftex-get-file-buffer-force reftex-last-toc-file)) | |
367 (setq current-prefix-arg '(16)) | |
368 (reftex-toc t)) | |
369 (defun reftex-toc-revert (&rest ignore) | |
370 "Regenerate the *toc* from the internal lists." | |
371 (interactive) | |
372 (switch-to-buffer-other-window | |
373 (reftex-get-file-buffer-force reftex-last-toc-file)) | |
374 (reftex-erase-buffer "*toc*") | |
375 (setq current-prefix-arg nil) | |
376 (reftex-toc t)) | |
377 (defun reftex-toc-external (&rest ignore) | |
378 "Switch to table of contents of an external document." | |
379 (interactive) | |
380 (let* ((old-buf (current-buffer)) | |
381 (xr-alist (get-text-property 1 'xr-alist)) | |
382 (xr-index (reftex-select-external-document | |
383 xr-alist 0))) | |
384 (switch-to-buffer-other-window (or (reftex-get-file-buffer-force | |
385 (cdr (nth xr-index xr-alist))) | |
386 (error "Cannot switch document"))) | |
387 (reftex-toc) | |
388 (if (equal old-buf (current-buffer)) | |
389 (message "") | |
390 (message "Switched document")))) | |
391 | |
392 (defun reftex-toc-visit-location (&optional final no-revisit) | |
393 ;; Visit the tex file corresponding to the toc entry on the current line. | |
394 ;; If FINAL is t, stay there | |
395 ;; If FINAL is 'hide, hide the *toc* window. | |
396 ;; Otherwise, move cursor back into *toc* window. | |
397 ;; NO-REVISIT means don't visit files, just use live biffers. | |
398 ;; This function is pretty clever about finding back a section heading, | |
399 ;; even if the buffer is not live, or things like outline, x-symbol etc. | |
400 ;; have been active. | |
401 | |
402 (let* ((toc (get-text-property (point) :data)) | |
403 (toc-window (selected-window)) | |
404 show-window show-buffer match) | |
405 | |
406 (unless toc (error "Don't know which toc line to visit")) | |
407 | |
408 (cond | |
409 | |
410 ((eq (car toc) 'toc) | |
411 ;; a toc entry | |
412 (setq match (reftex-toc-find-section toc no-revisit))) | |
413 | |
414 ((eq (car toc) 'index) | |
415 ;; an index entry | |
416 (setq match (reftex-index-show-entry toc no-revisit))) | |
417 | |
418 ((memq (car toc) '(bof eof)) | |
419 ;; A file entry | |
420 (setq match | |
421 (let ((where (car toc)) | |
422 (file (nth 1 toc))) | |
423 (if (or (not no-revisit) (reftex-get-buffer-visiting file)) | |
424 (progn | |
425 (switch-to-buffer-other-window | |
426 (reftex-get-file-buffer-force file nil)) | |
427 (goto-char (if (eq where 'bof) (point-min) (point-max)))) | |
428 (message reftex-no-follow-message) nil)))) | |
429 | |
430 ((stringp (car toc)) | |
431 ;; a label | |
432 (setq match (reftex-show-label-location toc reftex-callback-fwd | |
433 no-revisit t)))) | |
434 | |
435 (setq show-window (selected-window) | |
436 show-buffer (current-buffer)) | |
437 | |
438 (unless match | |
439 (select-window toc-window) | |
440 (error "Cannot find location")) | |
441 | |
442 (select-window toc-window) | |
443 | |
444 ;; use the `final' parameter to decide what to do next | |
445 (cond | |
446 ((eq final t) | |
447 (reftex-unhighlight 0) | |
448 (select-window show-window)) | |
449 ((eq final 'hide) | |
450 (reftex-unhighlight 0) | |
451 (or (one-window-p) (delete-window)) | |
452 (switch-to-buffer show-buffer) | |
453 (reftex-re-enlarge)) | |
454 (t nil)))) | |
455 | |
456 (defun reftex-toc-find-section (toc &optional no-revisit) | |
457 (let* ((file (nth 3 toc)) | |
458 (marker (nth 4 toc)) | |
459 (level (nth 5 toc)) | |
460 (literal (nth 7 toc)) | |
461 (emergency-point (nth 8 toc)) | |
462 (match | |
463 (cond | |
464 ((and (markerp marker) (marker-buffer marker)) | |
465 ;; Buffer is still live and we have the marker. Should be easy. | |
466 (switch-to-buffer-other-window (marker-buffer marker)) | |
467 (goto-char (marker-position marker)) | |
468 (or (looking-at (regexp-quote literal)) | |
469 (looking-at (reftex-make-regexp-allow-for-ctrl-m literal)) | |
470 (looking-at (reftex-make-desperate-section-regexp literal)) | |
471 (looking-at (concat "\\\\" | |
472 (regexp-quote | |
473 (car | |
474 (rassq level | |
475 reftex-section-levels-all))) | |
476 "[[{]")))) | |
477 ((or (not no-revisit) | |
478 (reftex-get-buffer-visiting file)) | |
479 ;; Marker is lost. Use the backup method. | |
480 (switch-to-buffer-other-window | |
481 (reftex-get-file-buffer-force file nil)) | |
482 (goto-char (or emergency-point (point-min))) | |
483 (or (looking-at (regexp-quote literal)) | |
484 (let ((len (length literal))) | |
485 (or (reftex-nearest-match (regexp-quote literal) len) | |
486 (reftex-nearest-match | |
487 (reftex-make-regexp-allow-for-ctrl-m literal) len) | |
488 (reftex-nearest-match | |
489 (reftex-make-desperate-section-regexp literal) len))))) | |
490 (t (message reftex-no-follow-message) nil)))) | |
491 (when match | |
492 (goto-char (match-beginning 0)) | |
493 (if (not (= (point) (point-max))) (recenter 1)) | |
494 (reftex-highlight 0 (match-beginning 0) (match-end 0) (current-buffer))) | |
495 match)) | |
496 | |
497 (defun reftex-make-desperate-section-regexp (old) | |
498 ;; Return a regexp which will still match a section statement even if | |
499 ;; x-symbol or isotex or the like have been at work in the mean time. | |
500 (let* ((n (1+ (string-match "[[{]" old))) | |
501 (new (regexp-quote (substring old 0 (1+ (string-match "[[{]" old))))) | |
502 (old (substring old n))) | |
503 (while (string-match | |
504 "\\([\r\n]\\)\\|\\(\\`\\|[ \t\n\r]\\)\\([a-zA-Z0-9]+\\)\\([ \t\n\r]\\|}\\'\\)" | |
505 old) | |
506 (if (match-beginning 1) | |
507 (setq new (concat new "[^\n\r]*[\n\r]")) | |
508 (setq new (concat new "[^\n\r]*" (match-string 3 old)))) | |
509 (setq old (substring old (match-end 0)))) | |
510 new)) | |
511 | |
512 ;; Table of Contents map | |
513 (define-key reftex-toc-map (if (featurep 'xemacs) [(button2)] [(mouse-2)]) | |
514 'reftex-toc-mouse-goto-line-and-hide) | |
515 | |
516 (substitute-key-definition | |
517 'next-line 'reftex-toc-next reftex-toc-map global-map) | |
518 (substitute-key-definition | |
519 'previous-line 'reftex-toc-previous reftex-toc-map global-map) | |
520 | |
521 (loop for x in | |
522 '(("n" . reftex-toc-next) | |
523 ("p" . reftex-toc-previous) | |
524 ("?" . reftex-toc-show-help) | |
525 (" " . reftex-toc-view-line) | |
526 ("\C-m" . reftex-toc-goto-line-and-hide) | |
527 ("\C-i" . reftex-toc-goto-line) | |
528 ("\C-c>". reftex-toc-display-index) | |
529 ("r" . reftex-toc-rescan) | |
530 ("R" . reftex-toc-Rescan) | |
531 ("g" . revert-buffer) | |
532 ("q" . reftex-toc-quit) | |
533 ("k" . reftex-toc-quit-and-kill) | |
534 ("f" . reftex-toc-toggle-follow) | |
535 ("F" . reftex-toc-toggle-file-boundary) | |
536 ("i" . reftex-toc-toggle-index) | |
537 ("l" . reftex-toc-toggle-labels) | |
538 ("c" . reftex-toc-toggle-context) | |
539 ("%" . reftex-toc-toggle-commented) | |
540 ("x" . reftex-toc-external) | |
541 ("." . reftex-toc-show-calling-point) | |
542 ("\C-c\C-n" . reftex-toc-next-heading) | |
543 ("\C-c\C-p" . reftex-toc-previous-heading)) | |
544 do (define-key reftex-toc-map (car x) (cdr x))) | |
545 | |
546 (loop for key across "0123456789" do | |
547 (define-key reftex-toc-map (vector (list key)) 'digit-argument)) | |
548 (define-key reftex-toc-map "-" 'negative-argument) | |
549 | |
550 (easy-menu-define | |
551 reftex-toc-menu reftex-toc-map | |
552 "Menu for Table of Contents buffer" | |
553 '("TOC" | |
554 ["Show Location" reftex-toc-view-line t] | |
555 ["Go To Location" reftex-toc-goto-line t] | |
556 ["Exit & Go To Location" reftex-toc-goto-line-and-hide t] | |
557 ["Index" reftex-toc-display-index t] | |
558 ["Quit" reftex-toc-quit t] | |
559 "--" | |
560 ["External Document TOC " reftex-toc-external t] | |
561 "--" | |
562 ("Update" | |
563 ["Rebuilt *toc* Buffer" revert-buffer t] | |
564 ["Rescan One File" reftex-toc-rescan reftex-enable-partial-scans] | |
565 ["Rescan Entire Document" reftex-toc-Rescan t]) | |
566 ("Options" | |
567 "TOC Items" | |
568 ["File Boundaries" reftex-toc-toggle-file-boundary :style toggle | |
569 :selected reftex-toc-include-file-boundaries] | |
570 ["Labels" reftex-toc-toggle-labels :style toggle | |
571 :selected reftex-toc-include-labels] | |
572 ["Index Entries" reftex-toc-toggle-index :style toggle | |
573 :selected reftex-toc-include-index-entries] | |
574 ["Context" reftex-toc-toggle-context :style toggle | |
575 :selected reftex-toc-include-context] | |
576 "--" | |
577 ["Follow Mode" reftex-toc-toggle-follow :style toggle | |
578 :selected reftex-toc-follow-mode]) | |
579 "--" | |
580 ["Help" reftex-toc-show-help t])) | |
581 | |
582 | |
583 ;;; reftex-toc.el ends here |