Mercurial > emacs
annotate lisp/textmodes/reftex-toc.el @ 62579:ac78bdf5b4ce
*** empty log message ***
author | Eli Zaretskii <eliz@gnu.org> |
---|---|
date | Sat, 21 May 2005 11:38:21 +0000 |
parents | 35f6599373fc |
children | d99bc4dec744 f042e7c0fe20 |
rev | line source |
---|---|
38422
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
37998
diff
changeset
|
1 ;;; reftex-toc.el --- RefTeX's table of contents mode |
62467
35f6599373fc
* textmodes/reftex-vars.el (reftex-cite-format-builtin): Support
Carsten Dominik <dominik@science.uva.nl>
parents:
59579
diff
changeset
|
2 ;; Copyright (c) 1997, 1998, 1999, 2000, 2003, 2004, 2005 |
35f6599373fc
* textmodes/reftex-vars.el (reftex-cite-format-builtin): Support
Carsten Dominik <dominik@science.uva.nl>
parents:
59579
diff
changeset
|
3 ;; Free Software Foundation, Inc. |
27035 | 4 |
46612
7522419c4db0
Updated to reftex 4.17
Carsten Dominik <dominik@science.uva.nl>
parents:
41785
diff
changeset
|
5 ;; Author: Carsten Dominik <dominik@science.uva.nl> |
62467
35f6599373fc
* textmodes/reftex-vars.el (reftex-cite-format-builtin): Support
Carsten Dominik <dominik@science.uva.nl>
parents:
59579
diff
changeset
|
6 ;; Version: 4.28 |
27035 | 7 |
8 ;; This file is part of GNU Emacs. | |
9 | |
10 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
11 ;; it under the terms of the GNU General Public License as published by | |
12 ;; the Free Software Foundation; either version 2, or (at your option) | |
13 ;; any later version. | |
14 | |
15 ;; GNU Emacs is distributed in the hope that it will be useful, | |
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 ;; GNU General Public License for more details. | |
19 | |
20 ;; You should have received a copy of the GNU General Public License | |
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
23 ;; Boston, MA 02111-1307, USA. | |
25280 | 24 |
38422
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
37998
diff
changeset
|
25 ;;; Commentary: |
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
37998
diff
changeset
|
26 |
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
37998
diff
changeset
|
27 ;;; Code: |
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
37998
diff
changeset
|
28 |
26910
489a5439b988
* reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents:
25806
diff
changeset
|
29 (eval-when-compile (require 'cl)) |
25280 | 30 (provide 'reftex-toc) |
31 (require 'reftex) | |
32 ;;; | |
33 | |
34 (defvar reftex-toc-map (make-sparse-keymap) | |
35 "Keymap used for *toc* buffer.") | |
36 | |
37 (defvar reftex-toc-menu) | |
38 | |
39 (defun reftex-toc-mode () | |
40 "Major mode for managing Table of Contents for LaTeX files. | |
41 This buffer was created with RefTeX. | |
42 Press `?' for a summary of important key bindings. | |
43 | |
44 Here are all local bindings. | |
45 | |
46 \\{reftex-toc-map}" | |
47 (interactive) | |
48 (kill-all-local-variables) | |
49 (setq major-mode 'reftex-toc-mode | |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
50 mode-name "TOC") |
25280 | 51 (use-local-map reftex-toc-map) |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
52 (set (make-local-variable 'transient-mark-mode) t) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
53 (set (make-local-variable 'zmacs-regions) t) |
25280 | 54 (set (make-local-variable 'revert-buffer-function) 'reftex-toc-revert) |
55 (set (make-local-variable 'reftex-toc-include-labels-indicator) "") | |
26910
489a5439b988
* reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents:
25806
diff
changeset
|
56 (set (make-local-variable 'reftex-toc-max-level-indicator) |
489a5439b988
* reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents:
25806
diff
changeset
|
57 (if (= reftex-toc-max-level 100) |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
58 "ALL" |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
59 (int-to-string reftex-toc-max-level))) |
25280 | 60 (setq mode-line-format |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
61 (list "---- " 'mode-line-buffer-identification |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
62 " " 'global-mode-string " (" mode-name ")" |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
63 " L<" 'reftex-toc-include-labels-indicator ">" |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
64 " I<" 'reftex-toc-include-index-indicator ">" |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
65 " T<" 'reftex-toc-max-level-indicator ">" |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
66 " -%-")) |
25280 | 67 (setq truncate-lines t) |
46683
060f433ebf11
Updated to RefTeX 4.18
Carsten Dominik <dominik@science.uva.nl>
parents:
46612
diff
changeset
|
68 (when (featurep 'xemacs) |
060f433ebf11
Updated to RefTeX 4.18
Carsten Dominik <dominik@science.uva.nl>
parents:
46612
diff
changeset
|
69 ;; XEmacs needs the call to make-local-hook |
060f433ebf11
Updated to RefTeX 4.18
Carsten Dominik <dominik@science.uva.nl>
parents:
46612
diff
changeset
|
70 (make-local-hook 'post-command-hook) |
060f433ebf11
Updated to RefTeX 4.18
Carsten Dominik <dominik@science.uva.nl>
parents:
46612
diff
changeset
|
71 (make-local-hook 'pre-command-hook)) |
25280 | 72 (make-local-variable 'reftex-last-follow-point) |
73 (add-hook 'post-command-hook 'reftex-toc-post-command-hook nil t) | |
74 (add-hook 'pre-command-hook 'reftex-toc-pre-command-hook nil t) | |
75 (easy-menu-add reftex-toc-menu reftex-toc-map) | |
76 (run-hooks 'reftex-toc-mode-hook)) | |
77 | |
78 (defvar reftex-last-toc-file nil | |
79 "Stores the file name from which `reftex-toc' was called. For redo command.") | |
80 | |
81 (defvar reftex-last-window-height nil) | |
46612
7522419c4db0
Updated to reftex 4.17
Carsten Dominik <dominik@science.uva.nl>
parents:
41785
diff
changeset
|
82 (defvar reftex-last-window-width nil) |
25280 | 83 (defvar reftex-toc-include-labels-indicator nil) |
84 (defvar reftex-toc-include-index-indicator nil) | |
26910
489a5439b988
* reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents:
25806
diff
changeset
|
85 (defvar reftex-toc-max-level-indicator nil) |
25280 | 86 |
87 (defvar reftex-toc-return-marker (make-marker) | |
88 "Marker which makes it possible to return from toc to old position.") | |
89 | |
90 (defconst reftex-toc-help | |
91 " AVAILABLE KEYS IN TOC BUFFER | |
92 ============================ | |
93 n / p next-line / previous-line | |
94 SPC Show the corresponding location of the LaTeX document. | |
95 TAB Goto the location and keep the *toc* window. | |
96 RET Goto the location and hide the *toc* window (also on mouse-2). | |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
97 < / > Promote / Demote section, or all sections in region. |
25280 | 98 C-c > Display Index. With prefix arg, restrict index to current section. |
99 q / k Hide/Kill *toc* buffer, return to position of reftex-toc command. | |
100 l i c F Toggle display of [l]abels, [i]ndex, [c]ontext, [F]ile borders. | |
26910
489a5439b988
* reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents:
25806
diff
changeset
|
101 t Change maximum toc depth (e.g. `3 t' hides levels greater than 3). |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
102 f / g Toggle follow mode / Refresh *toc* buffer. |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
103 a / d Toggle auto recenter / Toggle dedicated frame |
25280 | 104 r / C-u r Reparse the LaTeX document / Reparse entire LaTeX document. |
105 . In other window, show position from where `reftex-toc' was called. | |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
106 M-% Global search and replace to rename label at point. |
37998
706af946b1e7
* reftex-ref.el (reftex-select-label-help): Added "z" key
Carsten Dominik <dominik@science.uva.nl>
parents:
34402
diff
changeset
|
107 x Switch to TOC of external document (with LaTeX package `xr'). |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
108 z Jump to a specific section (e.g. '3 z' goes to section 3).") |
25280 | 109 |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
110 (defun reftex-toc (&optional rebuild reuse) |
25280 | 111 "Show the table of contents for the current document. |
112 When called with a raw C-u prefix, rescan the document first." | |
113 | |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
114 ;; The REUSE argument means, search all visible frames for a window |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
115 ;; displaying the toc window. If yes, reuse this window. |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
116 |
25280 | 117 (interactive) |
118 | |
119 (if (or (not (string= reftex-last-toc-master (reftex-TeX-master-file))) | |
120 current-prefix-arg) | |
121 (reftex-erase-buffer "*toc*")) | |
122 | |
123 (setq reftex-last-toc-file (buffer-file-name)) | |
124 (setq reftex-last-toc-master (reftex-TeX-master-file)) | |
125 | |
126 (set-marker reftex-toc-return-marker (point)) | |
127 | |
128 ;; If follow mode is active, arrange to delay it one command | |
129 (if reftex-toc-follow-mode | |
130 (setq reftex-toc-follow-mode 1)) | |
131 | |
132 (and reftex-toc-include-index-entries | |
133 (reftex-ensure-index-support)) | |
134 (or reftex-support-index | |
135 (setq reftex-toc-include-index-entries nil)) | |
136 | |
137 ;; Ensure access to scanning info and rescan buffer if prefix are is '(4) | |
138 (reftex-access-scan-info current-prefix-arg) | |
139 | |
140 (let* ((this-buf (current-buffer)) | |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
141 (docstruct-symbol reftex-docstruct-symbol) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
142 (xr-data (assq 'xr (symbol-value reftex-docstruct-symbol))) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
143 (xr-alist (cons (cons "" (buffer-file-name)) (nth 1 xr-data))) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
144 (here-I-am (if (boundp 'reftex-rebuilding-toc) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
145 (get 'reftex-toc :reftex-data) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
146 (car (reftex-where-am-I)))) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
147 (unsplittable (if (fboundp 'frame-property) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
148 (frame-property (selected-frame) 'unsplittable) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
149 (frame-parameter (selected-frame) 'unsplittable))) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
150 offset toc-window) |
25280 | 151 |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
152 (if (setq toc-window (get-buffer-window |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
153 "*toc*" |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
154 (if reuse 'visible))) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
155 (select-window toc-window) |
25280 | 156 (when (or (not reftex-toc-keep-other-windows) |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
157 (< (window-height) (* 2 window-min-height))) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
158 (delete-other-windows)) |
46612
7522419c4db0
Updated to reftex 4.17
Carsten Dominik <dominik@science.uva.nl>
parents:
41785
diff
changeset
|
159 |
7522419c4db0
Updated to reftex 4.17
Carsten Dominik <dominik@science.uva.nl>
parents:
41785
diff
changeset
|
160 (setq reftex-last-window-width (window-width) |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
161 reftex-last-window-height (window-height)) ; remember |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
162 |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
163 (unless unsplittable |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
164 (if reftex-toc-split-windows-horizontally |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
165 (split-window-horizontally |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
166 (floor (* (window-width) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
167 reftex-toc-split-windows-fraction))) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
168 (split-window-vertically |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
169 (floor (* (window-height) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
170 reftex-toc-split-windows-fraction))))) |
46612
7522419c4db0
Updated to reftex 4.17
Carsten Dominik <dominik@science.uva.nl>
parents:
41785
diff
changeset
|
171 |
25280 | 172 (let ((default-major-mode 'reftex-toc-mode)) |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
173 (switch-to-buffer "*toc*"))) |
25280 | 174 |
175 (or (eq major-mode 'reftex-toc-mode) (reftex-toc-mode)) | |
176 (set (make-local-variable 'reftex-docstruct-symbol) docstruct-symbol) | |
177 (setq reftex-toc-include-labels-indicator | |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
178 (if (eq reftex-toc-include-labels t) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
179 "ALL" |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
180 reftex-toc-include-labels)) |
25280 | 181 (setq reftex-toc-include-index-indicator |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
182 (if (eq reftex-toc-include-index-entries t) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
183 "ALL" |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
184 reftex-toc-include-index-entries)) |
25280 | 185 |
186 (cond | |
187 ((= (buffer-size) 0) | |
188 ;; buffer is empty - fill it with the table of contents | |
189 (message "Building *toc* buffer...") | |
190 | |
191 (setq buffer-read-only nil) | |
192 (insert (format | |
193 "TABLE-OF-CONTENTS on %s | |
194 SPC=view TAB=goto RET=goto+hide [q]uit [r]escan [l]abels [f]ollow [x]r [?]Help | |
195 ------------------------------------------------------------------------------ | |
196 " (abbreviate-file-name reftex-last-toc-master))) | |
197 | |
198 (if (reftex-use-fonts) | |
50979
85e525daebfc
(reftex-toc-visit-location):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
199 (put-text-property (point-min) (point) 'face reftex-toc-header-face)) |
85e525daebfc
(reftex-toc-visit-location):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
200 (put-text-property (point-min) (point) 'intangible t) |
85e525daebfc
(reftex-toc-visit-location):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
201 (put-text-property (point-min) (1+ (point-min)) 'xr-alist xr-alist) |
25280 | 202 |
203 (setq offset | |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
204 (reftex-insert-docstruct |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
205 this-buf |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
206 t ; include toc |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
207 reftex-toc-include-labels |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
208 reftex-toc-include-index-entries |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
209 reftex-toc-include-file-boundaries |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
210 reftex-toc-include-context |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
211 nil ; counter |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
212 nil ; commented |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
213 here-I-am |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
214 "" ; xr-prefix |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
215 t ; a toc buffer |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
216 )) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
217 |
25280 | 218 (run-hooks 'reftex-display-copied-context-hook) |
219 (message "Building *toc* buffer...done.") | |
220 (setq buffer-read-only t)) | |
221 (t | |
222 ;; Only compute the offset | |
223 (setq offset | |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
224 (or (reftex-get-offset this-buf here-I-am |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
225 (if reftex-toc-include-labels " " nil) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
226 t |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
227 reftex-toc-include-index-entries |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
228 reftex-toc-include-file-boundaries) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
229 (reftex-last-assoc-before-elt |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
230 'toc here-I-am |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
231 (symbol-value reftex-docstruct-symbol)))) |
25280 | 232 (put 'reftex-toc :reftex-line 3) |
233 (goto-line 3) | |
234 (beginning-of-line))) | |
235 | |
236 ;; Find the correct starting point | |
237 (reftex-find-start-point (point) offset (get 'reftex-toc :reftex-line)) | |
238 (setq reftex-last-follow-point (point)))) | |
239 | |
47050
904fd28be439
Update to RefTeX 4.19
Carsten Dominik <dominik@science.uva.nl>
parents:
46683
diff
changeset
|
240 (defun reftex-toc-recenter (&optional arg) |
904fd28be439
Update to RefTeX 4.19
Carsten Dominik <dominik@science.uva.nl>
parents:
46683
diff
changeset
|
241 "Display the TOC window and highlight line corresponding to current position." |
904fd28be439
Update to RefTeX 4.19
Carsten Dominik <dominik@science.uva.nl>
parents:
46683
diff
changeset
|
242 (interactive "P") |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
243 (let ((buf (current-buffer)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
244 (frame (selected-frame))) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
245 (reftex-toc arg t) |
47050
904fd28be439
Update to RefTeX 4.19
Carsten Dominik <dominik@science.uva.nl>
parents:
46683
diff
changeset
|
246 (if (= (count-lines 1 (point)) 2) |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
247 (let ((current-prefix-arg nil)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
248 (select-window (get-buffer-window buf frame)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
249 (reftex-toc nil t))) |
47050
904fd28be439
Update to RefTeX 4.19
Carsten Dominik <dominik@science.uva.nl>
parents:
46683
diff
changeset
|
250 (and (> (point) 1) |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
251 (not (get-text-property (point) 'intangible)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
252 (memq reftex-highlight-selection '(cursor both)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
253 (reftex-highlight 2 |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
254 (or (previous-single-property-change |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
255 (min (point-max) (1+ (point))) :data) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
256 (point-min)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
257 (or (next-single-property-change (point) :data) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
258 (point-max)))) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
259 (select-window (get-buffer-window buf frame)))) |
47050
904fd28be439
Update to RefTeX 4.19
Carsten Dominik <dominik@science.uva.nl>
parents:
46683
diff
changeset
|
260 |
25280 | 261 (defun reftex-toc-pre-command-hook () |
262 ;; used as pre command hook in *toc* buffer | |
263 (reftex-unhighlight 0) | |
47050
904fd28be439
Update to RefTeX 4.19
Carsten Dominik <dominik@science.uva.nl>
parents:
46683
diff
changeset
|
264 ) |
25280 | 265 |
266 (defun reftex-toc-post-command-hook () | |
267 ;; used in the post-command-hook for the *toc* buffer | |
268 (when (get-text-property (point) :data) | |
269 (put 'reftex-toc :reftex-data (get-text-property (point) :data)) | |
270 (and (> (point) 1) | |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
271 (not (get-text-property (point) 'intangible)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
272 (memq reftex-highlight-selection '(cursor both)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
273 (reftex-highlight 2 |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
274 (or (previous-single-property-change (1+ (point)) :data) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
275 (point-min)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
276 (or (next-single-property-change (point) :data) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
277 (point-max))))) |
25280 | 278 (if (integerp reftex-toc-follow-mode) |
279 ;; remove delayed action | |
280 (setq reftex-toc-follow-mode t) | |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
281 (and (not (reftex-toc-dframe-p)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
282 reftex-toc-follow-mode |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
283 (not (equal reftex-last-follow-point (point))) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
284 ;; show context in other window |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
285 (setq reftex-last-follow-point (point)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
286 (condition-case nil |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
287 (reftex-toc-visit-location nil (not reftex-revisit-to-follow)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
288 (error t))))) |
25280 | 289 |
290 (defun reftex-re-enlarge () | |
50979
85e525daebfc
(reftex-toc-visit-location):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
291 ;; Enlarge window to a remembered size. |
46612
7522419c4db0
Updated to reftex 4.17
Carsten Dominik <dominik@science.uva.nl>
parents:
41785
diff
changeset
|
292 (if reftex-toc-split-windows-horizontally |
7522419c4db0
Updated to reftex 4.17
Carsten Dominik <dominik@science.uva.nl>
parents:
41785
diff
changeset
|
293 (enlarge-window-horizontally |
7522419c4db0
Updated to reftex 4.17
Carsten Dominik <dominik@science.uva.nl>
parents:
41785
diff
changeset
|
294 (max 0 (- (or reftex-last-window-width (window-width)) |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
295 (window-width)))) |
46612
7522419c4db0
Updated to reftex 4.17
Carsten Dominik <dominik@science.uva.nl>
parents:
41785
diff
changeset
|
296 (enlarge-window |
7522419c4db0
Updated to reftex 4.17
Carsten Dominik <dominik@science.uva.nl>
parents:
41785
diff
changeset
|
297 (max 0 (- (or reftex-last-window-height (window-height)) |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
298 (window-height)))))) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
299 |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
300 (defun reftex-toc-dframe-p (&optional frame error) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
301 ;; Check if FRAME is the dedicated TOC frame. |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
302 ;; If yes, and ERROR is non-nil, throw an error. |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
303 (setq frame (or frame (selected-frame))) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
304 (let ((res (equal |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
305 (if (fboundp 'frame-property) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
306 (frame-property frame 'name) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
307 (frame-parameter frame 'name)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
308 "RefTeX TOC Frame"))) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
309 (if (and res error) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
310 (error "This frame is view-only. Use `C-c =' to create toc window for commands.")) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
311 res)) |
25280 | 312 |
313 (defun reftex-toc-show-help () | |
314 "Show a summary of special key bindings." | |
315 (interactive) | |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
316 (reftex-toc-dframe-p nil 'error) |
25280 | 317 (with-output-to-temp-buffer "*RefTeX Help*" |
318 (princ reftex-toc-help)) | |
319 (reftex-enlarge-to-fit "*RefTeX Help*" t) | |
320 ;; If follow mode is active, arrange to delay it one command | |
321 (if reftex-toc-follow-mode | |
322 (setq reftex-toc-follow-mode 1))) | |
323 | |
324 (defun reftex-toc-next (&optional arg) | |
325 "Move to next selectable item." | |
326 (interactive "p") | |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
327 (if (boundp 'zmacs-region-stays) (setq zmacs-region-stays t)) |
25280 | 328 (setq reftex-callback-fwd t) |
329 (or (eobp) (forward-char 1)) | |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
330 (goto-char (or (next-single-property-change (point) :data) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
331 (point)))) |
25280 | 332 (defun reftex-toc-previous (&optional arg) |
333 "Move to previous selectable item." | |
334 (interactive "p") | |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
335 (if (boundp 'zmacs-region-stays) (setq zmacs-region-stays t)) |
25280 | 336 (setq reftex-callback-fwd nil) |
337 (goto-char (or (previous-single-property-change (point) :data) | |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
338 (point)))) |
25280 | 339 (defun reftex-toc-next-heading (&optional arg) |
340 "Move to next table of contentes line." | |
341 (interactive "p") | |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
342 (if (boundp 'zmacs-region-stays) (setq zmacs-region-stays t)) |
25280 | 343 (end-of-line) |
344 (re-search-forward "^ " nil t arg) | |
345 (beginning-of-line)) | |
346 (defun reftex-toc-previous-heading (&optional arg) | |
347 "Move to previous table of contentes line." | |
348 (interactive "p") | |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
349 (if (boundp 'zmacs-region-stays) (setq zmacs-region-stays t)) |
25280 | 350 (re-search-backward "^ " nil t arg)) |
351 (defun reftex-toc-toggle-follow () | |
352 "Toggle follow (other window follows with context)." | |
353 (interactive) | |
354 (setq reftex-last-follow-point -1) | |
355 (setq reftex-toc-follow-mode (not reftex-toc-follow-mode))) | |
356 (defun reftex-toc-toggle-file-boundary () | |
357 "Toggle inclusion of file boundaries in *toc* buffer." | |
358 (interactive) | |
359 (setq reftex-toc-include-file-boundaries | |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
360 (not reftex-toc-include-file-boundaries)) |
25280 | 361 (reftex-toc-revert)) |
362 (defun reftex-toc-toggle-labels (arg) | |
363 "Toggle inclusion of labels in *toc* buffer. | |
364 With prefix ARG, prompt for a label type and include only labels of | |
365 that specific type." | |
366 (interactive "P") | |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
367 (setq reftex-toc-include-labels |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
368 (if arg (reftex-query-label-type) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
369 (not reftex-toc-include-labels))) |
25280 | 370 (reftex-toc-revert)) |
371 (defun reftex-toc-toggle-index (arg) | |
372 "Toggle inclusion of index in *toc* buffer. | |
373 With prefix arg, prompt for an index tag and include only entries of that | |
374 specific index." | |
375 (interactive "P") | |
376 (setq reftex-toc-include-index-entries | |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
377 (if arg (reftex-index-select-tag) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
378 (not reftex-toc-include-index-entries))) |
25280 | 379 (reftex-toc-revert)) |
380 (defun reftex-toc-toggle-context () | |
381 "Toggle inclusion of label context in *toc* buffer. | |
382 Label context is only displayed when the labels are there as well." | |
383 (interactive) | |
384 (setq reftex-toc-include-context (not reftex-toc-include-context)) | |
385 (reftex-toc-revert)) | |
26910
489a5439b988
* reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents:
25806
diff
changeset
|
386 (defun reftex-toc-max-level (arg) |
489a5439b988
* reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents:
25806
diff
changeset
|
387 "Set the maximum level of toc lines in this buffer to value of prefix ARG. |
489a5439b988
* reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents:
25806
diff
changeset
|
388 When no prefix is given, set the max level to a large number, so that all |
489a5439b988
* reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents:
25806
diff
changeset
|
389 levels are shown. For eaxample, to set the level to 3, type `3 m'." |
489a5439b988
* reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents:
25806
diff
changeset
|
390 (interactive "P") |
489a5439b988
* reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents:
25806
diff
changeset
|
391 (setq reftex-toc-max-level (if arg |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
392 (prefix-numeric-value arg) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
393 100)) |
26910
489a5439b988
* reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents:
25806
diff
changeset
|
394 (setq reftex-toc-max-level-indicator |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
395 (if arg (int-to-string reftex-toc-max-level) "ALL")) |
26910
489a5439b988
* reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents:
25806
diff
changeset
|
396 (reftex-toc-revert)) |
25280 | 397 (defun reftex-toc-view-line () |
398 "View document location in other window." | |
399 (interactive) | |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
400 (reftex-toc-dframe-p nil 'error) |
25280 | 401 (reftex-toc-visit-location)) |
402 (defun reftex-toc-goto-line-and-hide () | |
403 "Go to document location in other window. Hide the *toc* window." | |
404 (interactive) | |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
405 (reftex-toc-dframe-p nil 'error) |
25280 | 406 (reftex-toc-visit-location 'hide)) |
407 (defun reftex-toc-goto-line () | |
408 "Go to document location in other window. *toc* window stays." | |
409 (interactive) | |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
410 (reftex-toc-dframe-p nil 'error) |
25280 | 411 (reftex-toc-visit-location t)) |
412 (defun reftex-toc-mouse-goto-line-and-hide (ev) | |
413 "Go to document location in other window. Hide the *toc* window." | |
414 (interactive "e") | |
415 (mouse-set-point ev) | |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
416 (reftex-toc-dframe-p nil 'error) |
25280 | 417 (reftex-toc-visit-location 'hide)) |
418 (defun reftex-toc-show-calling-point () | |
419 "Show point where reftex-toc was called from." | |
420 (interactive) | |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
421 (reftex-toc-dframe-p nil 'error) |
25280 | 422 (let ((this-window (selected-window))) |
423 (unwind-protect | |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
424 (progn |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
425 (switch-to-buffer-other-window |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
426 (marker-buffer reftex-toc-return-marker)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
427 (goto-char (marker-position reftex-toc-return-marker)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
428 (recenter '(4))) |
25280 | 429 (select-window this-window)))) |
430 (defun reftex-toc-quit () | |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
431 "Hide the *toc* window and do not move point. |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
432 If the toc window is the only window on the dedicated TOC frame, the frame |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
433 is destroyed." |
25280 | 434 (interactive) |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
435 (if (and (one-window-p) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
436 (reftex-toc-dframe-p) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
437 (> (length (frame-list)) 1)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
438 (delete-frame) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
439 (or (one-window-p) (delete-window)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
440 (switch-to-buffer (marker-buffer reftex-toc-return-marker)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
441 (reftex-re-enlarge) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
442 (goto-char (or (marker-position reftex-toc-return-marker) (point))))) |
25280 | 443 (defun reftex-toc-quit-and-kill () |
444 "Kill the *toc* buffer." | |
445 (interactive) | |
446 (kill-buffer "*toc*") | |
447 (or (one-window-p) (delete-window)) | |
448 (switch-to-buffer (marker-buffer reftex-toc-return-marker)) | |
449 (reftex-re-enlarge) | |
450 (goto-char (marker-position reftex-toc-return-marker))) | |
451 (defun reftex-toc-display-index (&optional arg) | |
452 "Display the index buffer for the current document. | |
453 This works just like `reftex-display-index' from a LaTeX buffer. | |
454 With prefix arg 1, restrict index to the section at point." | |
455 (interactive "P") | |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
456 (reftex-toc-dframe-p nil 'error) |
25280 | 457 (let ((data (get-text-property (point) :data)) |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
458 (docstruct (symbol-value reftex-docstruct-symbol)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
459 bor eor restr) |
25280 | 460 (when (equal arg 2) |
461 (setq bor (reftex-last-assoc-before-elt 'toc data docstruct) | |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
462 eor (assoc 'toc (cdr (memq bor docstruct))) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
463 restr (list (nth 6 bor) bor eor))) |
25280 | 464 (reftex-toc-goto-line) |
465 (reftex-display-index (if restr nil arg) restr))) | |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
466 |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
467 ;; Rescanning the document and rebuilding the TOC buffer. |
25280 | 468 (defun reftex-toc-rescan (&rest ignore) |
469 "Regenerate the *toc* buffer by reparsing file of section at point." | |
470 (interactive) | |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
471 (if (and reftex-enable-partial-scans |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
472 (null current-prefix-arg)) |
25280 | 473 (let* ((data (get-text-property (point) :data)) |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
474 (what (car data)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
475 (file (cond ((eq what 'toc) (nth 3 data)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
476 ((memq what '(eof bof file-error)) (nth 1 data)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
477 ((stringp what) (nth 3 data)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
478 ((eq what 'index) (nth 3 data)))) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
479 (line (+ (count-lines (point-min) (point)) (if (bolp) 1 0)))) |
25280 | 480 (if (not file) |
481 (error "Don't know which file to rescan. Try `C-u r'") | |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
482 (put 'reftex-toc :reftex-line line) |
25280 | 483 (switch-to-buffer-other-window |
484 (reftex-get-file-buffer-force file)) | |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
485 (setq current-prefix-arg '(4)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
486 (let ((reftex-rebuilding-toc t)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
487 (reftex-toc)))) |
25280 | 488 (reftex-toc-Rescan)) |
489 (reftex-kill-temporary-buffers)) | |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
490 |
25280 | 491 (defun reftex-toc-Rescan (&rest ignore) |
492 "Regenerate the *toc* buffer by reparsing the entire document." | |
493 (interactive) | |
47050
904fd28be439
Update to RefTeX 4.19
Carsten Dominik <dominik@science.uva.nl>
parents:
46683
diff
changeset
|
494 (let* ((line (+ (count-lines (point-min) (point)) (if (bolp) 1 0)))) |
904fd28be439
Update to RefTeX 4.19
Carsten Dominik <dominik@science.uva.nl>
parents:
46683
diff
changeset
|
495 (put 'reftex-toc :reftex-line line)) |
25280 | 496 (switch-to-buffer-other-window |
497 (reftex-get-file-buffer-force reftex-last-toc-file)) | |
498 (setq current-prefix-arg '(16)) | |
47050
904fd28be439
Update to RefTeX 4.19
Carsten Dominik <dominik@science.uva.nl>
parents:
46683
diff
changeset
|
499 (let ((reftex-rebuilding-toc t)) |
904fd28be439
Update to RefTeX 4.19
Carsten Dominik <dominik@science.uva.nl>
parents:
46683
diff
changeset
|
500 (reftex-toc))) |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
501 |
25280 | 502 (defun reftex-toc-revert (&rest ignore) |
503 "Regenerate the *toc* from the internal lists." | |
504 (interactive) | |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
505 (let ((unsplittable |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
506 (if (fboundp 'frame-property) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
507 (frame-property (selected-frame) 'unsplittable) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
508 (frame-parameter (selected-frame) 'unsplittable))) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
509 (reftex-rebuilding-toc t)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
510 (if unsplittable |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
511 (switch-to-buffer |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
512 (reftex-get-file-buffer-force reftex-last-toc-file)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
513 (switch-to-buffer-other-window |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
514 (reftex-get-file-buffer-force reftex-last-toc-file)))) |
25280 | 515 (reftex-erase-buffer "*toc*") |
516 (setq current-prefix-arg nil) | |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
517 (reftex-toc t)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
518 |
25280 | 519 (defun reftex-toc-external (&rest ignore) |
520 "Switch to table of contents of an external document." | |
521 (interactive) | |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
522 (reftex-toc-dframe-p nil 'error) |
25280 | 523 (let* ((old-buf (current-buffer)) |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
524 (xr-alist (get-text-property 1 'xr-alist)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
525 (xr-index (reftex-select-external-document |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
526 xr-alist 0))) |
25280 | 527 (switch-to-buffer-other-window (or (reftex-get-file-buffer-force |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
528 (cdr (nth xr-index xr-alist))) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
529 (error "Cannot switch document"))) |
25280 | 530 (reftex-toc) |
531 (if (equal old-buf (current-buffer)) | |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
532 (message "") |
25280 | 533 (message "Switched document")))) |
534 | |
37998
706af946b1e7
* reftex-ref.el (reftex-select-label-help): Added "z" key
Carsten Dominik <dominik@science.uva.nl>
parents:
34402
diff
changeset
|
535 (defun reftex-toc-jump (arg) |
706af946b1e7
* reftex-ref.el (reftex-select-label-help): Added "z" key
Carsten Dominik <dominik@science.uva.nl>
parents:
34402
diff
changeset
|
536 "Jump to a specific section. E.g. '3 z' jumps to section 3. |
706af946b1e7
* reftex-ref.el (reftex-select-label-help): Added "z" key
Carsten Dominik <dominik@science.uva.nl>
parents:
34402
diff
changeset
|
537 Useful for large TOC's." |
706af946b1e7
* reftex-ref.el (reftex-select-label-help): Added "z" key
Carsten Dominik <dominik@science.uva.nl>
parents:
34402
diff
changeset
|
538 (interactive "P") |
706af946b1e7
* reftex-ref.el (reftex-select-label-help): Added "z" key
Carsten Dominik <dominik@science.uva.nl>
parents:
34402
diff
changeset
|
539 (goto-char (point-min)) |
706af946b1e7
* reftex-ref.el (reftex-select-label-help): Added "z" key
Carsten Dominik <dominik@science.uva.nl>
parents:
34402
diff
changeset
|
540 (re-search-forward |
706af946b1e7
* reftex-ref.el (reftex-select-label-help): Added "z" key
Carsten Dominik <dominik@science.uva.nl>
parents:
34402
diff
changeset
|
541 (concat "^ *" (number-to-string (if (numberp arg) arg 1)) " ") |
706af946b1e7
* reftex-ref.el (reftex-select-label-help): Added "z" key
Carsten Dominik <dominik@science.uva.nl>
parents:
34402
diff
changeset
|
542 nil t) |
706af946b1e7
* reftex-ref.el (reftex-select-label-help): Added "z" key
Carsten Dominik <dominik@science.uva.nl>
parents:
34402
diff
changeset
|
543 (beginning-of-line)) |
706af946b1e7
* reftex-ref.el (reftex-select-label-help): Added "z" key
Carsten Dominik <dominik@science.uva.nl>
parents:
34402
diff
changeset
|
544 |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
545 ;; Promotion/Demotion stuff |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
546 |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
547 (defun reftex-toc-demote (&optional arg) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
548 "Demote section at point. If region is active, apply to all in region." |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
549 (interactive "p") |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
550 (reftex-toc-do-promote 1)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
551 (defun reftex-toc-promote (&optional arg) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
552 "Promote section at point. If region is active, apply to all in region." |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
553 (interactive "p") |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
554 (reftex-toc-do-promote -1)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
555 (defun reftex-toc-do-promote (delta) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
556 "Workhorse for reftex-toc-promote and reftex-to-demote. |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
557 Changes the level of sections in the current region, or just the section at |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
558 point." |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
559 ;; We should not do anything unless we are sure this is going to work for |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
560 ;; each section in the region. Therefore we first collect information and |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
561 ;; test. |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
562 (let* ((start-line (+ (count-lines (point-min) (point)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
563 (if (bolp) 1 0))) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
564 (mark-line (if (reftex-region-active-p) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
565 (save-excursion (goto-char (mark)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
566 (+ (count-lines (point-min) (point)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
567 (if (bolp) 1 0))))) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
568 (start-pos (point)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
569 (pro-or-de (if (> delta 0) "de" "pro")) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
570 beg end entries data sections nsec mpos msg) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
571 (setq msg |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
572 (catch 'exit |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
573 (if (reftex-region-active-p) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
574 ;; A region is dangerous, check if we have a brandnew scan, |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
575 ;; to make sure we are not missing any section statements. |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
576 (if (not (reftex-toc-check-docstruct)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
577 (reftex-toc-load-all-files-for-promotion) ;; exits |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
578 (setq beg (min (point) (mark)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
579 end (max (point) (mark)))) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
580 (setq beg (point) end (point))) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
581 (goto-char beg) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
582 (while (and (setq data (get-text-property (point) :data)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
583 (<= (point) end)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
584 (if (eq (car data) 'toc) (push (cons data (point)) entries)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
585 (goto-char (or (next-single-property-change (point) :data) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
586 (point-max)))) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
587 (setq entries (nreverse entries)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
588 ;; Get the relevant section numbers, for an informative message |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
589 (goto-char start-pos) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
590 (setq sections (reftex-toc-extract-section-number (car entries))) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
591 (if (> (setq nsec (length entries)) 1) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
592 (setq sections |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
593 (concat sections "-" |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
594 (reftex-toc-extract-section-number |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
595 (nth (1- nsec) entries))))) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
596 ;; Run through the list and prepare the changes. |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
597 (setq entries (mapcar 'reftex-toc-promote-prepare entries)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
598 ;; Ask for permission |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
599 (if (or (not reftex-toc-confirm-promotion) ; never confirm |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
600 (and (integerp reftex-toc-confirm-promotion) ; confirm if many |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
601 (< nsec reftex-toc-confirm-promotion)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
602 (yes-or-no-p ; ask |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
603 (format "%s %d toc-entr%s (section%s %s)? " |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
604 (if (< delta 0) "Promote" "Demote") |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
605 nsec |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
606 (if (= 1 nsec) "y" "ies") |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
607 (if (= 1 nsec) "" "s") |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
608 sections))) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
609 nil ; we have permission, do nothing |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
610 (error "Abort")) ; abort, we don't have permission |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
611 ;; Do the changes |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
612 (mapcar 'reftex-toc-promote-action entries) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
613 ;; Rescan the document and rebuilt the toc buffer |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
614 (save-window-excursion |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
615 (reftex-toc-Rescan)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
616 (reftex-toc-restore-region start-line mark-line) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
617 (message "%d section%s %smoted" |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
618 nsec (if (= 1 nsec) "" "s") pro-or-de) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
619 nil)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
620 (if msg (progn (ding) (message msg))))) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
621 |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
622 (defvar delta) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
623 (defvar mpos) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
624 (defvar pro-or-de) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
625 (defvar start-pos) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
626 (defvar start-line) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
627 (defvar mark-line) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
628 |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
629 (defun reftex-toc-restore-region (point-line &optional mark-line) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
630 (if mark-line |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
631 (progn (goto-line mark-line) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
632 (setq mpos (point)))) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
633 (if point-line (goto-line point-line)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
634 (if mark-line |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
635 (progn |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
636 (set-mark mpos) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
637 (if (fboundp 'zmacs-activate-region) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
638 (zmacs-activate-region) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
639 (setq mark-active t |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
640 deactivate-mark nil))))) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
641 |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
642 (defun reftex-toc-promote-prepare (x) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
643 "Look at a toc entry and see if we could pro/demote it. |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
644 Expects the level change DELTA to be dynamically scoped into this function. |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
645 This function prepares everything for the changes, but does not do it. |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
646 The return value is a list with information needed when doing the |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
647 promotion/demotion later." |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
648 (let* ((data (car x)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
649 (toc-point (cdr x)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
650 (marker (nth 4 data)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
651 (literal (nth 7 data)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
652 (load nil) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
653 (name nil) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
654 ;; Here follows some paranoid code to make very sure we are not |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
655 ;; going to break anything |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
656 (name1 ; dummy |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
657 (if (and (markerp marker) (marker-buffer marker)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
658 ;; Buffer is still live and we have the marker. |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
659 (progn |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
660 (save-excursion |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
661 ;; Goto the buffer and check of section is unchanged |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
662 (set-buffer (marker-buffer marker)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
663 (goto-char (marker-position marker)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
664 (if (looking-at (regexp-quote literal)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
665 ;; OK, get the makro name |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
666 (progn |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
667 (beginning-of-line 1) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
668 (if (looking-at reftex-section-regexp) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
669 (setq name (reftex-match-string 2)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
670 (error "Something is wrong! Contact maintainer!"))) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
671 ;; Section has changed, request scan and loading |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
672 ;; We use a variable to delay until after the safe-exc. |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
673 ;; because otherwise we loose the region. |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
674 (setq load t))) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
675 ;; Scan document and load all files, this exits command |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
676 (if load (reftex-toc-load-all-files-for-promotion))) ; exits |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
677 ;; We don't have a live marker: scan and load files. |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
678 (reftex-toc-load-all-files-for-promotion))) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
679 (level (cdr (assoc name reftex-section-levels-all))) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
680 (dummy (if (not (integerp level)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
681 (progn |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
682 (goto-char toc-point) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
683 (error "Cannot %smote special sections" pro-or-de)))) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
684 ;; Delta is dynamically scoped into here... |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
685 (newlevel (if (>= level 0) (+ delta level) (- level delta))) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
686 (dummy2 (if (or (and (>= level 0) (= newlevel -1)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
687 (and (< level 0) (= newlevel 0))) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
688 (error "Cannot %smote \\%s" pro-or-de name))) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
689 (newname (reftex-toc-newhead-from-alist newlevel name |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
690 reftex-section-levels-all))) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
691 (if (and name newname) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
692 (list data name newname toc-point) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
693 (goto-char toc-point) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
694 (error "Cannot %smote \\%s" pro-or-de name)))) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
695 |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
696 (defun reftex-toc-promote-action (x) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
697 "Change the level of a toc entry. |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
698 DELTA and PRO-OR-DE are assumed to be dynamically scoped into this function." |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
699 (let* ((data (car x)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
700 (name (nth 1 x)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
701 (newname (nth 2 x)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
702 (marker (nth 4 data))) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
703 (save-excursion |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
704 (set-buffer (marker-buffer marker)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
705 (goto-char (marker-position marker)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
706 (if (looking-at (concat "\\([ \t]*\\\\\\)" (regexp-quote name))) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
707 (replace-match (concat "\\1" newname)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
708 (error "Fatal error during %smotion" pro-or-de))))) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
709 |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
710 (defun reftex-toc-extract-section-number (entry) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
711 "Get the numbering of a toc entry, for message purposes." |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
712 (if (string-match "\\s-*\\(\\S-+\\)" (nth 2 (car entry))) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
713 (match-string 1 (nth 2 (car entry))) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
714 "?")) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
715 |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
716 (defun reftex-toc-newhead-from-alist (nlevel head alist) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
717 "Get new heading with level NLEVEL from ALIST. |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
718 If there are no such entries, return nil. |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
719 If there are several different entries with same new level, choose |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
720 the one with the smallest distance to the assocation of HEAD in the alist. |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
721 This makes it possible for promotion to work several sets of headings, |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
722 if these sets are sorted blocks in the alist." |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
723 (let* ((al alist) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
724 (ass (assoc head al)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
725 (pos (length (memq ass al))) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
726 dist (mindist 1000) newhead) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
727 (while al |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
728 (if (equal (cdar al) nlevel) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
729 (progn |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
730 (setq dist (abs (- (length al) pos))) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
731 (if (< dist mindist) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
732 (setq newhead (car (car al)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
733 mindist dist)))) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
734 (setq al (cdr al))) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
735 newhead)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
736 |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
737 (defun reftex-toc-check-docstruct () |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
738 "Check if the current docstruct is fully up to date and all files visited." |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
739 ;; We do this by checking if all sections are on the right position |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
740 (let ((docstruct (symbol-value reftex-docstruct-symbol)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
741 entry marker empoint) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
742 (catch 'exit |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
743 (while (setq entry (pop docstruct)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
744 (if (eq (car entry) 'toc) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
745 (progn |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
746 (setq marker (nth 4 entry) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
747 empoint (nth 8 entry)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
748 (if (not (and (markerp marker) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
749 (marker-buffer marker) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
750 (= (marker-position marker) empoint))) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
751 (throw 'exit nil))))) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
752 t))) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
753 |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
754 (defun reftex-toc-load-all-files-for-promotion () |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
755 "Make sure all files of the document are being visited by buffers, |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
756 and that the scanning info is absolutely up to date. |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
757 We do this by rescanning with reftex-keep-temporary-buffers bound to t. |
59579
a588c86a429c
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-40
Miles Bader <miles@gnu.org>
parents:
59534
diff
changeset
|
758 The variable PRO-OR-DE is assumed to be dynamically scoped into this function. |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
759 When finished, we exit with an error message." |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
760 (let ((reftex-keep-temporary-buffers t)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
761 (reftex-toc-Rescan) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
762 (reftex-toc-restore-region start-line mark-line) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
763 (throw 'exit |
59579
a588c86a429c
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-40
Miles Bader <miles@gnu.org>
parents:
59534
diff
changeset
|
764 "TOC had to be updated first. Please check selection and repeat the command."))) |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
765 |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
766 (defun reftex-toc-rename-label () |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
767 "Rename the currently selected label in the *TOC* buffer. |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
768 This launches a global search and replace in order to rename a label. |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
769 Renaming a label is hardly ever necessary - the only exeption is after |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
770 promotion/demotion in connection with a package like fancyref, where the |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
771 label prefix determines the wording of a reference." |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
772 (interactive) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
773 (let* ((toc (get-text-property (point) :data)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
774 (label (car toc)) newlabel) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
775 (if (not (stringp label)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
776 (error "This is not a label entry.")) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
777 (setq newlabel (read-string (format "Rename label \"%s\" to:" label))) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
778 (if (assoc newlabel (symbol-value reftex-docstruct-symbol)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
779 (if (not (y-or-n-p |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
780 (format "Label '%s' exists. Use anyway? " label))) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
781 (error "Abort"))) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
782 (save-excursion |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
783 (save-window-excursion |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
784 (reftex-toc-visit-location t) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
785 (condition-case nil |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
786 (reftex-query-replace-document |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
787 (concat "{" (regexp-quote label) "}") |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
788 (format "{%s}" newlabel)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
789 (error t)))) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
790 (reftex-toc-rescan))) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
791 |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
792 |
25280 | 793 (defun reftex-toc-visit-location (&optional final no-revisit) |
794 ;; Visit the tex file corresponding to the toc entry on the current line. | |
795 ;; If FINAL is t, stay there | |
796 ;; If FINAL is 'hide, hide the *toc* window. | |
797 ;; Otherwise, move cursor back into *toc* window. | |
50979
85e525daebfc
(reftex-toc-visit-location):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
798 ;; NO-REVISIT means don't visit files, just use live buffers. |
25280 | 799 ;; This function is pretty clever about finding back a section heading, |
800 ;; even if the buffer is not live, or things like outline, x-symbol etc. | |
801 ;; have been active. | |
802 | |
803 (let* ((toc (get-text-property (point) :data)) | |
804 (toc-window (selected-window)) | |
805 show-window show-buffer match) | |
806 | |
807 (unless toc (error "Don't know which toc line to visit")) | |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
808 |
25280 | 809 (cond |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
810 |
25280 | 811 ((eq (car toc) 'toc) |
812 ;; a toc entry | |
813 (setq match (reftex-toc-find-section toc no-revisit))) | |
814 | |
815 ((eq (car toc) 'index) | |
816 ;; an index entry | |
817 (setq match (reftex-index-show-entry toc no-revisit))) | |
818 | |
819 ((memq (car toc) '(bof eof)) | |
820 ;; A file entry | |
821 (setq match | |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
822 (let ((where (car toc)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
823 (file (nth 1 toc))) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
824 (if (or (not no-revisit) (reftex-get-buffer-visiting file)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
825 (progn |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
826 (switch-to-buffer-other-window |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
827 (reftex-get-file-buffer-force file nil)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
828 (goto-char (if (eq where 'bof) (point-min) (point-max)))) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
829 (message reftex-no-follow-message) nil)))) |
25280 | 830 |
831 ((stringp (car toc)) | |
832 ;; a label | |
833 (setq match (reftex-show-label-location toc reftex-callback-fwd | |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
834 no-revisit t)))) |
25280 | 835 |
836 (setq show-window (selected-window) | |
837 show-buffer (current-buffer)) | |
838 | |
839 (unless match | |
840 (select-window toc-window) | |
841 (error "Cannot find location")) | |
842 | |
843 (select-window toc-window) | |
844 | |
845 ;; use the `final' parameter to decide what to do next | |
846 (cond | |
847 ((eq final t) | |
848 (reftex-unhighlight 0) | |
849 (select-window show-window)) | |
850 ((eq final 'hide) | |
851 (reftex-unhighlight 0) | |
852 (or (one-window-p) (delete-window)) | |
50979
85e525daebfc
(reftex-toc-visit-location):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
853 ;; If `show-window' is still live, show-buffer is already visible |
85e525daebfc
(reftex-toc-visit-location):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
854 ;; so let's not make it visible in yet-another-window. |
85e525daebfc
(reftex-toc-visit-location):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
855 (if (window-live-p show-window) |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
856 (set-buffer show-buffer) |
50979
85e525daebfc
(reftex-toc-visit-location):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
857 (switch-to-buffer show-buffer)) |
25280 | 858 (reftex-re-enlarge)) |
859 (t nil)))) | |
860 | |
861 (defun reftex-toc-find-section (toc &optional no-revisit) | |
862 (let* ((file (nth 3 toc)) | |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
863 (marker (nth 4 toc)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
864 (level (nth 5 toc)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
865 (literal (nth 7 toc)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
866 (emergency-point (nth 8 toc)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
867 (match |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
868 (cond |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
869 ((and (markerp marker) (marker-buffer marker)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
870 ;; Buffer is still live and we have the marker. Should be easy. |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
871 (switch-to-buffer-other-window (marker-buffer marker)) |
59534
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
53852
diff
changeset
|
872 (push-mark nil) |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
873 (goto-char (marker-position marker)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
874 (or (looking-at (regexp-quote literal)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
875 (looking-at (reftex-make-regexp-allow-for-ctrl-m literal)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
876 (looking-at (reftex-make-desperate-section-regexp literal)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
877 (looking-at (concat "\\\\" |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
878 (regexp-quote |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
879 (car |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
880 (rassq level |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
881 reftex-section-levels-all))) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
882 "[[{]?")))) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
883 ((or (not no-revisit) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
884 (reftex-get-buffer-visiting file)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
885 ;; Marker is lost. Use the backup method. |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
886 (switch-to-buffer-other-window |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
887 (reftex-get-file-buffer-force file nil)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
888 (goto-char (or emergency-point (point-min))) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
889 (or (looking-at (regexp-quote literal)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
890 (let ((len (length literal))) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
891 (or (reftex-nearest-match (regexp-quote literal) len) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
892 (reftex-nearest-match |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
893 (reftex-make-regexp-allow-for-ctrl-m literal) len) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
894 (reftex-nearest-match |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
895 (reftex-make-desperate-section-regexp literal) len))))) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
896 (t (message reftex-no-follow-message) nil)))) |
25280 | 897 (when match |
898 (goto-char (match-beginning 0)) | |
899 (if (not (= (point) (point-max))) (recenter 1)) | |
900 (reftex-highlight 0 (match-beginning 0) (match-end 0) (current-buffer))) | |
901 match)) | |
902 | |
903 (defun reftex-make-desperate-section-regexp (old) | |
904 ;; Return a regexp which will still match a section statement even if | |
905 ;; x-symbol or isotex or the like have been at work in the mean time. | |
906 (let* ((n (1+ (string-match "[[{]" old))) | |
907 (new (regexp-quote (substring old 0 (1+ (string-match "[[{]" old))))) | |
908 (old (substring old n))) | |
909 (while (string-match | |
910 "\\([\r\n]\\)\\|\\(\\`\\|[ \t\n\r]\\)\\([a-zA-Z0-9]+\\)\\([ \t\n\r]\\|}\\'\\)" | |
911 old) | |
912 (if (match-beginning 1) | |
913 (setq new (concat new "[^\n\r]*[\n\r]")) | |
914 (setq new (concat new "[^\n\r]*" (match-string 3 old)))) | |
915 (setq old (substring old (match-end 0)))) | |
916 new)) | |
917 | |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
918 ;; Auto recentering of TOC window |
47050
904fd28be439
Update to RefTeX 4.19
Carsten Dominik <dominik@science.uva.nl>
parents:
46683
diff
changeset
|
919 |
904fd28be439
Update to RefTeX 4.19
Carsten Dominik <dominik@science.uva.nl>
parents:
46683
diff
changeset
|
920 (defun reftex-recenter-toc-when-idle () |
904fd28be439
Update to RefTeX 4.19
Carsten Dominik <dominik@science.uva.nl>
parents:
46683
diff
changeset
|
921 (and (> (buffer-size) 5) |
904fd28be439
Update to RefTeX 4.19
Carsten Dominik <dominik@science.uva.nl>
parents:
46683
diff
changeset
|
922 reftex-mode |
904fd28be439
Update to RefTeX 4.19
Carsten Dominik <dominik@science.uva.nl>
parents:
46683
diff
changeset
|
923 (not (active-minibuffer-window)) |
904fd28be439
Update to RefTeX 4.19
Carsten Dominik <dominik@science.uva.nl>
parents:
46683
diff
changeset
|
924 (fboundp 'reftex-toc-mode) |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
925 (get-buffer-window "*toc*" 'visible) |
47050
904fd28be439
Update to RefTeX 4.19
Carsten Dominik <dominik@science.uva.nl>
parents:
46683
diff
changeset
|
926 (string= reftex-last-toc-master (reftex-TeX-master-file)) |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
927 (let (current-prefix-arg) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
928 (reftex-toc-recenter)))) |
47050
904fd28be439
Update to RefTeX 4.19
Carsten Dominik <dominik@science.uva.nl>
parents:
46683
diff
changeset
|
929 |
904fd28be439
Update to RefTeX 4.19
Carsten Dominik <dominik@science.uva.nl>
parents:
46683
diff
changeset
|
930 (defun reftex-toggle-auto-toc-recenter () |
904fd28be439
Update to RefTeX 4.19
Carsten Dominik <dominik@science.uva.nl>
parents:
46683
diff
changeset
|
931 "Toggle the automatic recentering of the toc window. |
904fd28be439
Update to RefTeX 4.19
Carsten Dominik <dominik@science.uva.nl>
parents:
46683
diff
changeset
|
932 When active, leaving point idle will make the toc window jump to the correct |
904fd28be439
Update to RefTeX 4.19
Carsten Dominik <dominik@science.uva.nl>
parents:
46683
diff
changeset
|
933 section." |
904fd28be439
Update to RefTeX 4.19
Carsten Dominik <dominik@science.uva.nl>
parents:
46683
diff
changeset
|
934 (interactive) |
904fd28be439
Update to RefTeX 4.19
Carsten Dominik <dominik@science.uva.nl>
parents:
46683
diff
changeset
|
935 (if reftex-toc-auto-recenter-timer |
904fd28be439
Update to RefTeX 4.19
Carsten Dominik <dominik@science.uva.nl>
parents:
46683
diff
changeset
|
936 (progn |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
937 (if (featurep 'xemacs) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
938 (delete-itimer reftex-toc-auto-recenter-timer) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
939 (cancel-timer reftex-toc-auto-recenter-timer)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
940 (setq reftex-toc-auto-recenter-timer nil) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
941 (message "Automatic recentering of toc windwo was turned off")) |
47050
904fd28be439
Update to RefTeX 4.19
Carsten Dominik <dominik@science.uva.nl>
parents:
46683
diff
changeset
|
942 (setq reftex-toc-auto-recenter-timer |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
943 (if (featurep 'xemacs) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
944 (start-itimer "RefTeX Idle Timer for recenter" |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
945 'reftex-recenter-toc-when-idle |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
946 reftex-idle-time reftex-idle-time t) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
947 (run-with-idle-timer |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
948 reftex-idle-time t 'reftex-recenter-toc-when-idle))) |
47050
904fd28be439
Update to RefTeX 4.19
Carsten Dominik <dominik@science.uva.nl>
parents:
46683
diff
changeset
|
949 (message "Automatic recentering of toc window was turned on"))) |
904fd28be439
Update to RefTeX 4.19
Carsten Dominik <dominik@science.uva.nl>
parents:
46683
diff
changeset
|
950 |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
951 (defun reftex-toc-toggle-dedicated-frame () |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
952 "Toggle the display of a separate frame for the TOC. |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
953 This frame is not used by the `reftex-toc' commands, but it is useful to |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
954 always show the current section in connection with the option |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
955 `reftex-auto-recenter-toc'." |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
956 (interactive) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
957 (catch 'exit |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
958 (let* ((frames (frame-list)) frame |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
959 (get-frame-prop-func (if (fboundp 'frame-property) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
960 'frame-property |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
961 'frame-parameter))) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
962 (while (setq frame (pop frames)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
963 (if (equal (funcall get-frame-prop-func frame 'name) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
964 "RefTeX TOC Frame") |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
965 (progn |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
966 (delete-frame frame) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
967 (throw 'exit nil)))) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
968 (reftex-make-separate-toc-frame)))) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
969 |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
970 (defun reftex-make-separate-toc-frame () |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
971 ;; Create a new fame showing only the toc buffer. |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
972 (let ((current-frame (selected-frame)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
973 (current-window (selected-window)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
974 (current-toc-window (get-buffer-window "*toc*" 'visible)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
975 current-toc-frame) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
976 (if (and current-toc-window |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
977 (not (equal (selected-frame) (window-frame current-toc-window)))) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
978 nil |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
979 (setq current-toc-frame |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
980 (make-frame |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
981 '((name . "RefTeX TOC Frame") |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
982 (height . 20) (width . 60) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
983 (unsplittable . t) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
984 (minibuffer . nil) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
985 (default-toolbar-visible-p . nil) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
986 (menubar-visible-p . nil) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
987 (horizontal-scrollbar-visible-p . nil)))) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
988 (select-frame current-toc-frame) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
989 (switch-to-buffer "*toc*") |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
990 (select-frame current-frame) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
991 (if (fboundp 'focus-frame) (focus-frame current-frame) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
992 (if (fboundp 'x-focus-frame) (x-focus-frame current-frame))) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
993 (select-window current-window) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
994 (when (eq reftex-auto-recenter-toc 'frame) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
995 (unless reftex-toc-auto-recenter-timer |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
996 (reftex-toggle-auto-toc-recenter)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
997 (add-hook 'delete-frame-hook 'reftex-toc-delete-frame-hook))))) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
998 |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
999 (defun reftex-toc-delete-frame-hook (frame) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
1000 (if (and reftex-toc-auto-recenter-timer |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
1001 (reftex-toc-dframe-p frame)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
1002 (progn |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
1003 (reftex-toggle-auto-toc-recenter)))) |
47050
904fd28be439
Update to RefTeX 4.19
Carsten Dominik <dominik@science.uva.nl>
parents:
46683
diff
changeset
|
1004 |
25280 | 1005 ;; Table of Contents map |
1006 (define-key reftex-toc-map (if (featurep 'xemacs) [(button2)] [(mouse-2)]) | |
1007 'reftex-toc-mouse-goto-line-and-hide) | |
1008 | |
1009 (substitute-key-definition | |
1010 'next-line 'reftex-toc-next reftex-toc-map global-map) | |
1011 (substitute-key-definition | |
1012 'previous-line 'reftex-toc-previous reftex-toc-map global-map) | |
1013 | |
1014 (loop for x in | |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
1015 '(("n" . reftex-toc-next) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
1016 ("p" . reftex-toc-previous) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
1017 ("?" . reftex-toc-show-help) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
1018 (" " . reftex-toc-view-line) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
1019 ("\C-m" . reftex-toc-goto-line-and-hide) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
1020 ("\C-i" . reftex-toc-goto-line) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
1021 ("\C-c>" . reftex-toc-display-index) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
1022 ("r" . reftex-toc-rescan) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
1023 ("R" . reftex-toc-Rescan) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
1024 ("g" . revert-buffer) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
1025 ("q" . reftex-toc-quit); |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
1026 ("k" . reftex-toc-quit-and-kill) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
1027 ("f" . reftex-toc-toggle-follow); |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
1028 ("a" . reftex-toggle-auto-toc-recenter) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
1029 ("d" . reftex-toc-toggle-dedicated-frame) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
1030 ("F" . reftex-toc-toggle-file-boundary) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
1031 ("i" . reftex-toc-toggle-index) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
1032 ("l" . reftex-toc-toggle-labels) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
1033 ("t" . reftex-toc-max-level) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
1034 ("c" . reftex-toc-toggle-context) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
1035 ; ("%" . reftex-toc-toggle-commented) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
1036 ("\M-%" . reftex-toc-rename-label) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
1037 ("x" . reftex-toc-external) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
1038 ("z" . reftex-toc-jump) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
1039 ("." . reftex-toc-show-calling-point) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
1040 ("\C-c\C-n" . reftex-toc-next-heading) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
1041 ("\C-c\C-p" . reftex-toc-previous-heading) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
1042 (">" . reftex-toc-demote) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
1043 ("<" . reftex-toc-promote)) |
25280 | 1044 do (define-key reftex-toc-map (car x) (cdr x))) |
1045 | |
1046 (loop for key across "0123456789" do | |
1047 (define-key reftex-toc-map (vector (list key)) 'digit-argument)) | |
1048 (define-key reftex-toc-map "-" 'negative-argument) | |
1049 | |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
1050 (easy-menu-define |
25280 | 1051 reftex-toc-menu reftex-toc-map |
1052 "Menu for Table of Contents buffer" | |
1053 '("TOC" | |
1054 ["Show Location" reftex-toc-view-line t] | |
1055 ["Go To Location" reftex-toc-goto-line t] | |
1056 ["Exit & Go To Location" reftex-toc-goto-line-and-hide t] | |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
1057 ["Show Calling Point" reftex-toc-show-calling-point t] |
25280 | 1058 ["Quit" reftex-toc-quit t] |
1059 "--" | |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
1060 ("Edit" |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
1061 ["Promote" reftex-toc-promote t] |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
1062 ["Demote" reftex-toc-demote t] |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
1063 ["Rename Label" reftex-toc-rename-label t]) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
1064 "--" |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
1065 ["Index" reftex-toc-display-index t] |
25280 | 1066 ["External Document TOC " reftex-toc-external t] |
1067 "--" | |
1068 ("Update" | |
34402
5eec8d1d09f0
Update to RefTeX 4.15, see ChangeLog for details
Carsten Dominik <dominik@science.uva.nl>
parents:
34211
diff
changeset
|
1069 ["Rebuilt *toc* Buffer" revert-buffer t] |
25280 | 1070 ["Rescan One File" reftex-toc-rescan reftex-enable-partial-scans] |
1071 ["Rescan Entire Document" reftex-toc-Rescan t]) | |
1072 ("Options" | |
1073 "TOC Items" | |
1074 ["File Boundaries" reftex-toc-toggle-file-boundary :style toggle | |
1075 :selected reftex-toc-include-file-boundaries] | |
1076 ["Labels" reftex-toc-toggle-labels :style toggle | |
1077 :selected reftex-toc-include-labels] | |
1078 ["Index Entries" reftex-toc-toggle-index :style toggle | |
1079 :selected reftex-toc-include-index-entries] | |
1080 ["Context" reftex-toc-toggle-context :style toggle | |
1081 :selected reftex-toc-include-context] | |
1082 "--" | |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
1083 ["Follow Mode" reftex-toc-toggle-follow :style toggle |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
1084 :selected reftex-toc-follow-mode] |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
1085 ["Auto Recenter" reftex-toggle-auto-toc-recenter :style toggle |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
1086 :selected reftex-toc-auto-recenter-timer] |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50979
diff
changeset
|
1087 ["Dedicated Frame" reftex-toc-toggle-dedicated-frame t]) |
25280 | 1088 "--" |
1089 ["Help" reftex-toc-show-help t])) | |
1090 | |
1091 | |
52401 | 1092 ;;; arch-tag: 92400ce2-0b86-4c89-a606-4ed71acea17e |
59534
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
53852
diff
changeset
|
1093 ;;; reftex-toc.el ends here |