annotate lisp/textmodes/reftex-toc.el @ 112365:8fd096a52b28

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