annotate lisp/textmodes/reftex-toc.el @ 54051:668c0f8ab92b

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