annotate lisp/textmodes/reftex-sel.el @ 68648:067115a6e738

Update years in copyright notice; nfc.
author Thien-Thi Nguyen <ttn@gnuvola.org>
date Mon, 06 Feb 2006 12:31:40 +0000
parents e274642bf5d5
children bfd5c5e60410 c5406394f567
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-sel.el --- the selection modes for RefTeX
68648
067115a6e738 Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 65638
diff changeset
2 ;; Copyright (C) 1997, 1998, 1999, 2000, 2003, 2440, 2005,
067115a6e738 Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 65638
diff changeset
3 ;; 2006 Free Software Foundation, Inc.
27035
083669ed376a Supply licensing info.
Richard M. Stallman <rms@gnu.org>
parents: 26910
diff changeset
4
46612
7522419c4db0 Updated to reftex 4.17
Carsten Dominik <dominik@science.uva.nl>
parents: 43352
diff changeset
5 ;; Author: Carsten Dominik <dominik@science.uva.nl>
65548
253cad16882d Little fixes to remove compiler warnings
Carsten Dominik <dominik@science.uva.nl>
parents: 64751
diff changeset
6 ;; Version: VERSIONTAG
27035
083669ed376a Supply licensing info.
Richard M. Stallman <rms@gnu.org>
parents: 26910
diff changeset
7
083669ed376a Supply licensing info.
Richard M. Stallman <rms@gnu.org>
parents: 26910
diff changeset
8 ;; This file is part of GNU Emacs.
083669ed376a Supply licensing info.
Richard M. Stallman <rms@gnu.org>
parents: 26910
diff changeset
9
083669ed376a Supply licensing info.
Richard M. Stallman <rms@gnu.org>
parents: 26910
diff changeset
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
083669ed376a Supply licensing info.
Richard M. Stallman <rms@gnu.org>
parents: 26910
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
083669ed376a Supply licensing info.
Richard M. Stallman <rms@gnu.org>
parents: 26910
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
083669ed376a Supply licensing info.
Richard M. Stallman <rms@gnu.org>
parents: 26910
diff changeset
13 ;; any later version.
083669ed376a Supply licensing info.
Richard M. Stallman <rms@gnu.org>
parents: 26910
diff changeset
14
083669ed376a Supply licensing info.
Richard M. Stallman <rms@gnu.org>
parents: 26910
diff changeset
15 ;; 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
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
083669ed376a Supply licensing info.
Richard M. Stallman <rms@gnu.org>
parents: 26910
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
083669ed376a Supply licensing info.
Richard M. Stallman <rms@gnu.org>
parents: 26910
diff changeset
18 ;; GNU General Public License for more details.
083669ed376a Supply licensing info.
Richard M. Stallman <rms@gnu.org>
parents: 26910
diff changeset
19
083669ed376a Supply licensing info.
Richard M. Stallman <rms@gnu.org>
parents: 26910
diff changeset
20 ;; You should have received a copy of the GNU General Public License
083669ed376a Supply licensing info.
Richard M. Stallman <rms@gnu.org>
parents: 26910
diff changeset
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
65638
e274642bf5d5 Update FSF street address; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 65548
diff changeset
22 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
e274642bf5d5 Update FSF street address; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 65548
diff changeset
23 ;; Boston, MA 02110-1301, USA.
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
24
38422
7a94f1c588c4 Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 37998
diff changeset
25 ;;; Commentary:
7a94f1c588c4 Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 37998
diff changeset
26
7a94f1c588c4 Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 37998
diff changeset
27 ;;; Code:
7a94f1c588c4 Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 37998
diff changeset
28
26910
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
29 (eval-when-compile (require 'cl))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
30 (provide 'reftex-sel)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
31 (require 'reftex)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
32 ;;;
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
33
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
34 (defvar reftex-select-label-map nil
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
35 "Keymap used for *RefTeX Select* buffer, when selecting a label.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
36 This keymap can be used to configure the label selection process which is
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
37 started with the command \\[reftex-reference].")
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
38
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
39 (defun reftex-select-label-mode ()
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
40 "Major mode for selecting a label in a LaTeX document.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
41 This buffer was created with RefTeX.
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
42 It only has a meaningful keymap when you are in the middle of a
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
43 selection process.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
44 To select a label, move the cursor to it and press RET.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
45 Press `?' for a summary of important key bindings.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
46
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
47 During a selection process, these are the local bindings.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
48
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
49 \\{reftex-select-label-map}"
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
50
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
51 (interactive)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
52 (kill-all-local-variables)
46683
060f433ebf11 Updated to RefTeX 4.18
Carsten Dominik <dominik@science.uva.nl>
parents: 46612
diff changeset
53 (when (featurep 'xemacs)
060f433ebf11 Updated to RefTeX 4.18
Carsten Dominik <dominik@science.uva.nl>
parents: 46612
diff changeset
54 ;; XEmacs needs the call to make-local-hook
060f433ebf11 Updated to RefTeX 4.18
Carsten Dominik <dominik@science.uva.nl>
parents: 46612
diff changeset
55 (make-local-hook 'pre-command-hook)
060f433ebf11 Updated to RefTeX 4.18
Carsten Dominik <dominik@science.uva.nl>
parents: 46612
diff changeset
56 (make-local-hook 'post-command-hook))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
57 (setq major-mode 'reftex-select-label-mode
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
58 mode-name "LSelect")
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
59 (set (make-local-variable 'reftex-select-marked) nil)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
60 (when (syntax-table-p reftex-latex-syntax-table)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
61 (set-syntax-table reftex-latex-syntax-table))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
62 ;; We do not set a local map - reftex-select-item does this.
65548
253cad16882d Little fixes to remove compiler warnings
Carsten Dominik <dominik@science.uva.nl>
parents: 64751
diff changeset
63 (run-hooks 'reftex-select-label-mode-hook))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
64
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
65 (defvar reftex-select-bib-map nil
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
66 "Keymap used for *RefTeX Select* buffer, when selecting a BibTeX entry.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
67 This keymap can be used to configure the BibTeX selection process which is
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
68 started with the command \\[reftex-citation].")
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
69
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
70 (defun reftex-select-bib-mode ()
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
71 "Major mode for selecting a citation key in a LaTeX document.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
72 This buffer was created with RefTeX.
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
73 It only has a meaningful keymap when you are in the middle of a
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
74 selection process.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
75 In order to select a citation, move the cursor to it and press RET.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
76 Press `?' for a summary of important key bindings.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
77
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
78 During a selection process, these are the local bindings.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
79
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
80 \\{reftex-select-label-map}"
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
81 (interactive)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
82 (kill-all-local-variables)
46683
060f433ebf11 Updated to RefTeX 4.18
Carsten Dominik <dominik@science.uva.nl>
parents: 46612
diff changeset
83 (when (featurep 'xemacs)
060f433ebf11 Updated to RefTeX 4.18
Carsten Dominik <dominik@science.uva.nl>
parents: 46612
diff changeset
84 ;; XEmacs needs the call to make-local-hook
060f433ebf11 Updated to RefTeX 4.18
Carsten Dominik <dominik@science.uva.nl>
parents: 46612
diff changeset
85 (make-local-hook 'pre-command-hook)
060f433ebf11 Updated to RefTeX 4.18
Carsten Dominik <dominik@science.uva.nl>
parents: 46612
diff changeset
86 (make-local-hook 'post-command-hook))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
87 (setq major-mode 'reftex-select-bib-mode
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
88 mode-name "BSelect")
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
89 (set (make-local-variable 'reftex-select-marked) nil)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
90 ;; We do not set a local map - reftex-select-item does this.
65548
253cad16882d Little fixes to remove compiler warnings
Carsten Dominik <dominik@science.uva.nl>
parents: 64751
diff changeset
91 (run-hooks 'reftex-select-bib-mode-hook))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
92
47050
904fd28be439 Update to RefTeX 4.19
Carsten Dominik <dominik@science.uva.nl>
parents: 46683
diff changeset
93 ;;; (defun reftex-get-offset (buf here-am-I &optional typekey toc index file)
904fd28be439 Update to RefTeX 4.19
Carsten Dominik <dominik@science.uva.nl>
parents: 46683
diff changeset
94 ;;; ;; Find the correct offset data, like insert-docstruct would, but faster.
904fd28be439 Update to RefTeX 4.19
Carsten Dominik <dominik@science.uva.nl>
parents: 46683
diff changeset
95 ;;; ;; Buffer BUF knows the correct docstruct to use.
904fd28be439 Update to RefTeX 4.19
Carsten Dominik <dominik@science.uva.nl>
parents: 46683
diff changeset
96 ;;; ;; Basically this finds the first docstruct entry after HERE-I-AM which
904fd28be439 Update to RefTeX 4.19
Carsten Dominik <dominik@science.uva.nl>
parents: 46683
diff changeset
97 ;;; ;; is of allowed type. The optional arguments specify what is allowed.
904fd28be439 Update to RefTeX 4.19
Carsten Dominik <dominik@science.uva.nl>
parents: 46683
diff changeset
98 ;;; (catch 'exit
904fd28be439 Update to RefTeX 4.19
Carsten Dominik <dominik@science.uva.nl>
parents: 46683
diff changeset
99 ;;; (save-excursion
904fd28be439 Update to RefTeX 4.19
Carsten Dominik <dominik@science.uva.nl>
parents: 46683
diff changeset
100 ;;; (set-buffer buf)
904fd28be439 Update to RefTeX 4.19
Carsten Dominik <dominik@science.uva.nl>
parents: 46683
diff changeset
101 ;;; (reftex-access-scan-info)
904fd28be439 Update to RefTeX 4.19
Carsten Dominik <dominik@science.uva.nl>
parents: 46683
diff changeset
102 ;;; (let* ((rest (memq here-am-I (symbol-value reftex-docstruct-symbol)))
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
103 ;;; entry)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
104 ;;; (while (setq entry (pop rest))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
105 ;;; (if (or (and typekey
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
106 ;;; (stringp (car entry))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
107 ;;; (or (equal typekey " ")
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
108 ;;; (equal typekey (nth 1 entry))))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
109 ;;; (and toc (eq (car entry) 'toc))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
110 ;;; (and index (eq (car entry) 'index))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
111 ;;; (and file
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
112 ;;; (memq (car entry) '(bof eof file-error))))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
113 ;;; (throw 'exit entry)))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
114 ;;; nil))))
47050
904fd28be439 Update to RefTeX 4.19
Carsten Dominik <dominik@science.uva.nl>
parents: 46683
diff changeset
115
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
116 (defun reftex-get-offset (buf here-am-I &optional typekey toc index file)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
117 ;; Find the correct offset data, like insert-docstruct would, but faster.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
118 ;; Buffer BUF knows the correct docstruct to use.
47050
904fd28be439 Update to RefTeX 4.19
Carsten Dominik <dominik@science.uva.nl>
parents: 46683
diff changeset
119 ;; Basically this finds the first docstruct entry before HERE-I-AM which
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
120 ;; is of allowed type. The optional arguments specify what is allowed.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
121 (catch 'exit
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
122 (save-excursion
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
123 (set-buffer buf)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
124 (reftex-access-scan-info)
47050
904fd28be439 Update to RefTeX 4.19
Carsten Dominik <dominik@science.uva.nl>
parents: 46683
diff changeset
125 (let* ((rest (symbol-value reftex-docstruct-symbol))
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
126 lastentry entry)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
127 (while (setq entry (pop rest))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
128 (if (or (and typekey
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
129 (stringp (car entry))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
130 (or (equal typekey " ")
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
131 (equal typekey (nth 1 entry))))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
132 (and toc (eq (car entry) 'toc))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
133 (and index (eq (car entry) 'index))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
134 (and file
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
135 (memq (car entry) '(bof eof file-error))))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
136 (setq lastentry entry))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
137 (if (eq entry here-am-I)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
138 (throw 'exit (or lastentry entry))))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
139 nil))))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
140
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
141 (defun reftex-insert-docstruct
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
142 (buf toc labels index-entries files context counter show-commented
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
143 here-I-am xr-prefix toc-buffer)
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
144 ;; Insert an excerpt of the docstruct list.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
145 ;; Return the data property of the entry corresponding to HERE-I-AM.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
146 ;; BUF is the buffer which has the correct docstruct-symbol.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
147 ;; LABELS non-nil means to include labels into the list.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
148 ;; When a string, indicates the label type to include
34402
5eec8d1d09f0 Update to RefTeX 4.15, see ChangeLog for details
Carsten Dominik <dominik@science.uva.nl>
parents: 29775
diff changeset
149 ;; FILES non-nil means to display file boundaries.
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
150 ;; CONTEXT non-nil means to include label context.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
151 ;; COUNTER means to count the labels.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
152 ;; SHOW-COMMENTED means to include also labels which are commented out.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
153 ;; HERE-I-AM is a member of the docstruct list. The function will return
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
154 ;; a used member near to this one, as a possible starting point.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
155 ;; XR-PREFIX is the prefix to put in front of labels.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
156 ;; TOC-BUFFER means this is to fill the toc buffer.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
157 (let* ((font (reftex-use-fonts))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
158 (cnt 0)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
159 (index -1)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
160 (toc-indent " ")
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
161 (label-indent
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
162 (concat "> "
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
163 (if toc (make-string (* 7 reftex-level-indent) ?\ ) "")))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
164 (context-indent
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
165 (concat ". "
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
166 (if toc (make-string (* 7 reftex-level-indent) ?\ ) "")))
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
167 (mouse-face
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
168 (if (memq reftex-highlight-selection '(mouse both))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
169 reftex-mouse-selected-face
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
170 nil))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
171 (label-face (reftex-verified-face reftex-label-face
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
172 'font-lock-constant-face
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
173 'font-lock-reference-face))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
174 (index-face (reftex-verified-face reftex-index-face
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
175 'font-lock-constant-face
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
176 'font-lock-reference-face))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
177 all cell text label typekey note comment master-dir-re
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
178 prev-inserted offset from to index-tag docstruct-symbol)
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
179
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
180 ;; Pop to buffer buf to get the correct buffer-local variables
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
181 (save-excursion
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
182 (set-buffer buf)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
183
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
184 ;; Ensure access to scanning info
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
185 (reftex-access-scan-info)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
186
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
187 (setq docstruct-symbol reftex-docstruct-symbol
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
188 all (symbol-value reftex-docstruct-symbol)
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
189 reftex-active-toc nil
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
190 master-dir-re
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
191 (concat "\\`" (regexp-quote
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
192 (file-name-directory (reftex-TeX-master-file))))))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
193
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
194 (set (make-local-variable 'reftex-docstruct-symbol) docstruct-symbol)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
195 (set (make-local-variable 'reftex-prefix)
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
196 (cdr (assoc labels reftex-typekey-to-prefix-alist)))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
197 (if (equal reftex-prefix " ") (setq reftex-prefix nil))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
198
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
199 ;; Walk the docstruct and insert the appropriate stuff
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
200 (while (setq cell (pop all))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
201
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
202 (incf index)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
203 (setq from (point))
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 (cond
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
206
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
207 ((memq (car cell) '(bib thebib label-numbers appendix
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
208 master-dir bibview-cache is-multi xr xr-doc)))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
209 ;; These are currently ignored
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
210
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
211 ((memq (car cell) '(bof eof file-error))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
212 ;; Beginning or end of a file
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
213 (when files
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
214 (setq prev-inserted cell)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
215 ; (if (eq offset 'attention) (setq offset cell))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
216 (insert
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
217 " File " (if (string-match master-dir-re (nth 1 cell))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
218 (substring (nth 1 cell) (match-end 0))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
219 (nth 1 cell))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
220 (cond ((eq (car cell) 'bof) " starts here\n")
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
221 ((eq (car cell) 'eof) " ends here\n")
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
222 ((eq (car cell) 'file-error) " was not found\n")))
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
223 (setq to (point))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
224 (when font
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
225 (put-text-property from to
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
226 'face reftex-file-boundary-face))
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
227 (when toc-buffer
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
228 (if mouse-face
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
229 (put-text-property from (1- to)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
230 'mouse-face mouse-face))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
231 (put-text-property from to :data cell))))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
232
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
233 ((eq (car cell) 'toc)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
234 ;; a table of contents entry
26910
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
235 (when (and toc
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
236 (<= (nth 5 cell) reftex-toc-max-level))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
237 (setq prev-inserted cell)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
238 ; (if (eq offset 'attention) (setq offset cell))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
239 (setq reftex-active-toc cell)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
240 (insert (concat toc-indent (nth 2 cell) "\n"))
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
241 (setq to (point))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
242 (when font
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
243 (put-text-property from to
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
244 'face reftex-section-heading-face))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
245 (when toc-buffer
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
246 (if mouse-face
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
247 (put-text-property from (1- to)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
248 'mouse-face mouse-face))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
249 (put-text-property from to :data cell))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
250 (goto-char to)))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
251
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
252 ((stringp (car cell))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
253 ;; a label
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
254 (when (null (nth 2 cell))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
255 ;; No context yet. Quick update.
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
256 (setcdr cell (cdr (reftex-label-info-update cell)))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
257 (put docstruct-symbol 'modified t))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
258
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
259 (setq label (car cell)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
260 typekey (nth 1 cell)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
261 text (nth 2 cell)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
262 comment (nth 4 cell)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
263 note (nth 5 cell))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
264
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
265 (when (and labels
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
266 (or (eq labels t)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
267 (string= typekey labels)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
268 (string= labels " "))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
269 (or show-commented (null comment)))
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 ;; Yes we want this one
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
272 (incf cnt)
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
273 (setq prev-inserted cell)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
274 ; (if (eq offset 'attention) (setq offset cell))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
275
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
276 (setq label (concat xr-prefix label))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
277 (when comment (setq label (concat "% " label)))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
278 (insert label-indent label)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
279 (when font
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
280 (setq to (point))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
281 (put-text-property
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
282 (- (point) (length label)) to
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
283 'face (if comment
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
284 'font-lock-comment-face
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
285 label-face))
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
286 (goto-char to))
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 (insert (if counter (format " (%d) " cnt) "")
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
289 (if comment " LABEL IS COMMENTED OUT " "")
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
290 (if (stringp note) (concat " " note) "")
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
291 "\n")
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
292 (setq to (point))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
293
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
294 (when context
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
295 (insert context-indent text "\n")
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
296 (setq to (point)))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
297 (put-text-property from to :data cell)
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
298 (when mouse-face
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
299 (put-text-property from (1- to)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
300 'mouse-face mouse-face))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
301 (goto-char to)))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
302
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
303 ((eq (car cell) 'index)
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
304 ;; index entry
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
305 (when (and index-entries
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
306 (or (eq t index-entries)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
307 (string= index-entries (nth 1 cell))))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
308 (setq prev-inserted cell)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
309 ; (if (eq offset 'attention) (setq offset cell))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
310 (setq index-tag (format "<%s>" (nth 1 cell)))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
311 (and font
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
312 (put-text-property 0 (length index-tag)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
313 'face reftex-index-tag-face index-tag))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
314 (insert label-indent index-tag " " (nth 7 cell))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
315
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
316 (when font
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
317 (setq to (point))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
318 (put-text-property
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
319 (- (point) (length (nth 7 cell))) to
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
320 'face index-face)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
321 (goto-char to))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
322 (insert "\n")
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
323 (setq to (point))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
324
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
325 (when context
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
326 (insert context-indent (nth 2 cell) "\n")
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
327 (setq to (point)))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
328 (put-text-property from to :data cell)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
329 (when mouse-face
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
330 (put-text-property from (1- to)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
331 'mouse-face mouse-face))
47050
904fd28be439 Update to RefTeX 4.19
Carsten Dominik <dominik@science.uva.nl>
parents: 46683
diff changeset
332 (goto-char to))))
904fd28be439 Update to RefTeX 4.19
Carsten Dominik <dominik@science.uva.nl>
parents: 46683
diff changeset
333
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
334 (if (eq cell here-I-am)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
335 (setq offset 'attention))
47050
904fd28be439 Update to RefTeX 4.19
Carsten Dominik <dominik@science.uva.nl>
parents: 46683
diff changeset
336 (if (and prev-inserted (eq offset 'attention))
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
337 (setq offset prev-inserted))
47050
904fd28be439 Update to RefTeX 4.19
Carsten Dominik <dominik@science.uva.nl>
parents: 46683
diff changeset
338 )
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
339
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
340 (when (reftex-refontify)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
341 ;; we need to fontify the buffer
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
342 (reftex-fontify-select-label-buffer buf))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
343 (run-hooks 'reftex-display-copied-context-hook)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
344 offset))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
345
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
346 (defun reftex-find-start-point (fallback &rest locations)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
347 ;; Set point to the first available LOCATION. When a LOCATION is a list,
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
348 ;; search for such a :data text property. When it is an integer,
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
349 ;; use is as line number. FALLBACK is a buffer position used if everything
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
350 ;; else fails.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
351 (catch 'exit
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
352 (goto-char (point-min))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
353 (let (loc pos)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
354 (while locations
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
355 (setq loc (pop locations))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
356 (cond
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
357 ((null loc))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
358 ((listp loc)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
359 (setq pos (text-property-any (point-min) (point-max) :data loc))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
360 (when pos
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
361 (goto-char pos)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
362 (throw 'exit t)))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
363 ((integerp loc)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
364 (when (<= loc (count-lines (point-min) (point-max)))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
365 (goto-line loc)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
366 (throw 'exit t)))))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
367 (goto-char fallback))))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
368
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
369 (defvar reftex-last-data nil)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
370 (defvar reftex-last-line nil)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
371 (defvar reftex-select-marked nil)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
372
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
373 (defun reftex-select-item (prompt help-string keymap
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
374 &optional offset
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
375 call-back cb-flag)
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
376 ;; Select an item, using PROMPT. The function returns a key indicating
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
377 ;; an exit status, along with a data structure indicating which item was
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
378 ;; selected.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
379 ;; HELP-STRING contains help. KEYMAP is a keymap with the available
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
380 ;; selection commands.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
381 ;; OFFSET can be a label list item which will be selected at start.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
382 ;; When it is t, point will start out at the beginning of the buffer.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
383 ;; Any other value will cause restart where last selection left off.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
384 ;; When CALL-BACK is given, it is a function which is called with the index
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
385 ;; of the element.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
386 ;; CB-FLAG is the initial value of that flag.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
387
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
388 (let* (ev data last-data (selection-buffer (current-buffer)))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
389
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
390 (setq reftex-select-marked nil)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
391
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
392 (setq ev
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
393 (catch 'myexit
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
394 (save-window-excursion
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
395 (setq truncate-lines t)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
396
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
397 ;; Find a good starting point
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
398 (reftex-find-start-point
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
399 (point-min) offset reftex-last-data reftex-last-line)
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
400 (beginning-of-line 1)
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
401 (set (make-local-variable 'reftex-last-follow-point) (point))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
402
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
403 (unwind-protect
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
404 (progn
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
405 (use-local-map keymap)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
406 (add-hook 'pre-command-hook 'reftex-select-pre-command-hook nil t)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
407 (add-hook 'post-command-hook 'reftex-select-post-command-hook nil t)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
408 (princ prompt)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
409 (set-marker reftex-recursive-edit-marker (point))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
410 ;; XEmacs does not run post-command-hook here
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
411 (and (featurep 'xemacs) (run-hooks 'post-command-hook))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
412 (recursive-edit))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
413
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
414 (set-marker reftex-recursive-edit-marker nil)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
415 (save-excursion
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
416 (set-buffer selection-buffer)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
417 (use-local-map nil)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
418 (remove-hook 'pre-command-hook 'reftex-select-pre-command-hook t)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
419 (remove-hook 'post-command-hook
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
420 'reftex-select-post-command-hook t))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
421 ;; Kill the mark overlays
62467
35f6599373fc * textmodes/reftex-vars.el (reftex-cite-format-builtin): Support
Carsten Dominik <dominik@science.uva.nl>
parents: 59534
diff changeset
422 (mapcar (lambda (c) (reftex-delete-overlay (nth 1 c)))
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
423 reftex-select-marked)))))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
424
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
425 (set (make-local-variable 'reftex-last-line)
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
426 (+ (count-lines (point-min) (point)) (if (bolp) 1 0)))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
427 (set (make-local-variable 'reftex-last-data) last-data)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
428 (reftex-kill-buffer "*RefTeX Help*")
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
429 (setq reftex-callback-fwd (not reftex-callback-fwd)) ;; ;-)))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
430 (message "")
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
431 (list ev data last-data)))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
432
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
433 ;; The following variables are all bound dynamically in `reftex-select-item'.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
434 ;; The defvars are here only to silence the byte compiler.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
435
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
436 (defvar found-list)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
437 (defvar cb-flag)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
438 (defvar data)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
439 (defvar prompt)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
440 (defvar last-data)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
441 (defvar call-back)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
442 (defvar help-string)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
443 (defvar refstyle)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
444
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
445 ;; The selection commands
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
446
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
447 (defun reftex-select-pre-command-hook ()
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
448 (reftex-unhighlight 1)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
449 (reftex-unhighlight 0))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
450
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
451 (defun reftex-select-post-command-hook ()
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
452 (let (b e)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
453 (setq data (get-text-property (point) :data))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
454 (setq last-data (or data last-data))
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
455
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
456 (when (and data cb-flag
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
457 (not (equal reftex-last-follow-point (point))))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
458 (setq reftex-last-follow-point (point))
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
459 (funcall call-back data reftex-callback-fwd
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
460 (not reftex-revisit-to-follow)))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
461 (if data
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
462 (setq b (or (previous-single-property-change
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
463 (1+ (point)) :data)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
464 (point-min))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
465 e (or (next-single-property-change
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
466 (point) :data)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
467 (point-max)))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
468 (setq b (point) e (point)))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
469 (and (memq reftex-highlight-selection '(cursor both))
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
470 (reftex-highlight 1 b e))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
471 (if (or (not (pos-visible-in-window-p b))
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
472 (not (pos-visible-in-window-p e)))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
473 (recenter '(4)))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
474 (unless (current-message)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
475 (princ prompt))))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
476
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
477 (defun reftex-select-next (&optional arg)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
478 "Move to next selectable item."
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
479 (interactive "p")
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
480 (setq reftex-callback-fwd t)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
481 (or (eobp) (forward-char 1))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
482 (re-search-forward "^[^. \t\n\r]" nil t arg)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
483 (beginning-of-line 1))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
484 (defun reftex-select-previous (&optional arg)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
485 "Move to previous selectable item."
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
486 (interactive "p")
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
487 (setq reftex-callback-fwd nil)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
488 (re-search-backward "^[^. \t\n\r]" nil t arg))
37998
706af946b1e7 * reftex-ref.el (reftex-select-label-help): Added "z" key
Carsten Dominik <dominik@science.uva.nl>
parents: 34402
diff changeset
489 (defun reftex-select-jump (arg)
706af946b1e7 * reftex-ref.el (reftex-select-label-help): Added "z" key
Carsten Dominik <dominik@science.uva.nl>
parents: 34402
diff changeset
490 "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
491 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
492 (interactive "P")
706af946b1e7 * reftex-ref.el (reftex-select-label-help): Added "z" key
Carsten Dominik <dominik@science.uva.nl>
parents: 34402
diff changeset
493 (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
494 (re-search-forward
706af946b1e7 * reftex-ref.el (reftex-select-label-help): Added "z" key
Carsten Dominik <dominik@science.uva.nl>
parents: 34402
diff changeset
495 (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
496 nil t)
706af946b1e7 * reftex-ref.el (reftex-select-label-help): Added "z" key
Carsten Dominik <dominik@science.uva.nl>
parents: 34402
diff changeset
497 (beginning-of-line))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
498 (defun reftex-select-next-heading (&optional arg)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
499 "Move to next table of contentes line."
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
500 (interactive "p")
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
501 (end-of-line)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
502 (re-search-forward "^ " nil t arg)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
503 (beginning-of-line))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
504 (defun reftex-select-previous-heading (&optional arg)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
505 "Move to previous table of contentes line."
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
506 (interactive "p")
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
507 (re-search-backward "^ " nil t arg))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
508 (defun reftex-select-quit ()
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
509 "Abort selection process."
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
510 (interactive)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
511 (throw 'myexit nil))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
512 (defun reftex-select-keyboard-quit ()
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
513 "Abort selection process."
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
514 (interactive)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
515 (throw 'exit t))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
516 (defun reftex-select-jump-to-previous ()
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
517 "Jump back to where previous selection process left off."
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
518 (interactive)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
519 (let (pos)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
520 (cond
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
521 ((and (local-variable-p 'reftex-last-data (current-buffer))
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
522 reftex-last-data
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
523 (setq pos (text-property-any (point-min) (point-max)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
524 :data reftex-last-data)))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
525 (goto-char pos))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
526 ((and (local-variable-p 'reftex-last-line (current-buffer))
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
527 (integerp reftex-last-line))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
528 (goto-line reftex-last-line))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
529 (t (ding)))))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
530 (defun reftex-select-toggle-follow ()
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
531 "Toggle follow mode: Other window follows with full context."
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
532 (interactive)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
533 (setq reftex-last-follow-point -1)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
534 (setq cb-flag (not cb-flag)))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
535 (defun reftex-select-toggle-varioref ()
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
536 "Toggle the macro used for referencing the label between \\ref and \\vref."
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
537 (interactive)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
538 (if (string= refstyle "\\ref")
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
539 (setq refstyle "\\vref")
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
540 (setq refstyle "\\ref"))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
541 (force-mode-line-update))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
542 (defun reftex-select-toggle-fancyref ()
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
543 "Toggle the macro used for referencing the label between \\ref and \\vref."
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
544 (interactive)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
545 (setq refstyle
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
546 (cond ((string= refstyle "\\ref") "\\fref")
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
547 ((string= refstyle "\\fref") "\\Fref")
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
548 (t "\\ref")))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
549 (force-mode-line-update))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
550 (defun reftex-select-show-insertion-point ()
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
551 "Show the point from where selection was started in another window."
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
552 (interactive)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
553 (let ((this-window (selected-window)))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
554 (unwind-protect
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
555 (progn
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
556 (switch-to-buffer-other-window
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
557 (marker-buffer reftex-select-return-marker))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
558 (goto-char (marker-position reftex-select-return-marker))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
559 (recenter '(4)))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
560 (select-window this-window))))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
561 (defun reftex-select-callback ()
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
562 "Show full context in another window."
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
563 (interactive)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
564 (if data (funcall call-back data reftex-callback-fwd nil) (ding)))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
565 (defun reftex-select-accept ()
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
566 "Accept the currently selected item."
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
567 (interactive)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
568 (throw 'myexit 'return))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
569 (defun reftex-select-mouse-accept (ev)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
570 "Accept the item at the mouse click."
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
571 (interactive "e")
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
572 (mouse-set-point ev)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
573 (setq data (get-text-property (point) :data))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
574 (setq last-data (or data last-data))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
575 (throw 'myexit 'return))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
576 (defun reftex-select-read-label ()
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
577 "Use minibuffer to read a label to reference, with completion."
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
578 (interactive)
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
579 (let ((label (completing-read
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
580 "Label: " (symbol-value reftex-docstruct-symbol)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
581 nil nil reftex-prefix)))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
582 (unless (or (equal label "") (equal label reftex-prefix))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
583 (throw 'myexit label))))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
584 (defun reftex-select-read-cite ()
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
585 "Use minibuffer to read a citation key with completion."
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
586 (interactive)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
587 (let* ((key (completing-read "Citation key: " found-list))
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
588 (entry (assoc key found-list)))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
589 (cond
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
590 ((or (null key) (equal key "")))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
591 (entry
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
592 (setq data entry)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
593 (setq last-data data)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
594 (throw 'myexit 'return))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
595 (t (throw 'myexit key)))))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
596
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
597 (defun reftex-select-mark (&optional separator)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
598 "Mark the entry."
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
599 (interactive)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
600 (let* ((data (get-text-property (point) :data))
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
601 boe eoe ovl)
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
602 (or data (error "No entry to mark at point"))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
603 (if (assq data reftex-select-marked)
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
604 (error "Entry is already marked"))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
605 (setq boe (or (previous-single-property-change (1+ (point)) :data)
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
606 (point-min))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
607 eoe (or (next-single-property-change (point) :data) (point-max)))
62467
35f6599373fc * textmodes/reftex-vars.el (reftex-cite-format-builtin): Support
Carsten Dominik <dominik@science.uva.nl>
parents: 59534
diff changeset
608 (setq ovl (reftex-make-overlay boe eoe))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
609 (push (list data ovl separator) reftex-select-marked)
62467
35f6599373fc * textmodes/reftex-vars.el (reftex-cite-format-builtin): Support
Carsten Dominik <dominik@science.uva.nl>
parents: 59534
diff changeset
610 (reftex-overlay-put ovl 'face reftex-select-mark-face)
35f6599373fc * textmodes/reftex-vars.el (reftex-cite-format-builtin): Support
Carsten Dominik <dominik@science.uva.nl>
parents: 59534
diff changeset
611 (reftex-overlay-put ovl 'before-string
35f6599373fc * textmodes/reftex-vars.el (reftex-cite-format-builtin): Support
Carsten Dominik <dominik@science.uva.nl>
parents: 59534
diff changeset
612 (if separator
35f6599373fc * textmodes/reftex-vars.el (reftex-cite-format-builtin): Support
Carsten Dominik <dominik@science.uva.nl>
parents: 59534
diff changeset
613 (format "*%c%d* " separator
35f6599373fc * textmodes/reftex-vars.el (reftex-cite-format-builtin): Support
Carsten Dominik <dominik@science.uva.nl>
parents: 59534
diff changeset
614 (length reftex-select-marked))
35f6599373fc * textmodes/reftex-vars.el (reftex-cite-format-builtin): Support
Carsten Dominik <dominik@science.uva.nl>
parents: 59534
diff changeset
615 (format "*%d* " (length reftex-select-marked))))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
616 (message "Entry has mark no. %d" (length reftex-select-marked))))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
617
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
618 (defun reftex-select-mark-comma ()
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
619 "Mark the entry and store the `comma' separator."
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
620 (interactive)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
621 (reftex-select-mark ?,))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
622 (defun reftex-select-mark-to ()
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
623 "Mark the entry and store the `to' separator."
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
624 (interactive)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
625 (reftex-select-mark ?-))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
626 (defun reftex-select-mark-and ()
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
627 "Mark the entry and store `and' to separator."
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
628 (interactive)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
629 (reftex-select-mark ?+))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
630
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
631 (defun reftex-select-unmark ()
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
632 "Unmark the entry."
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
633 (interactive)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
634 (let* ((data (get-text-property (point) :data))
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
635 (cell (assq data reftex-select-marked))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
636 (ovl (nth 1 cell))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
637 (cnt 0)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
638 sep)
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
639 (unless cell
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
640 (error "No marked entry at point"))
62467
35f6599373fc * textmodes/reftex-vars.el (reftex-cite-format-builtin): Support
Carsten Dominik <dominik@science.uva.nl>
parents: 59534
diff changeset
641 (and ovl (reftex-delete-overlay ovl))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
642 (setq reftex-select-marked (delq cell reftex-select-marked))
62467
35f6599373fc * textmodes/reftex-vars.el (reftex-cite-format-builtin): Support
Carsten Dominik <dominik@science.uva.nl>
parents: 59534
diff changeset
643 (setq cnt (1+ (length reftex-select-marked)))
35f6599373fc * textmodes/reftex-vars.el (reftex-cite-format-builtin): Support
Carsten Dominik <dominik@science.uva.nl>
parents: 59534
diff changeset
644 (mapcar (lambda (c)
35f6599373fc * textmodes/reftex-vars.el (reftex-cite-format-builtin): Support
Carsten Dominik <dominik@science.uva.nl>
parents: 59534
diff changeset
645 (setq sep (nth 2 c))
35f6599373fc * textmodes/reftex-vars.el (reftex-cite-format-builtin): Support
Carsten Dominik <dominik@science.uva.nl>
parents: 59534
diff changeset
646 (reftex-overlay-put (nth 1 c) 'before-string
35f6599373fc * textmodes/reftex-vars.el (reftex-cite-format-builtin): Support
Carsten Dominik <dominik@science.uva.nl>
parents: 59534
diff changeset
647 (if sep
35f6599373fc * textmodes/reftex-vars.el (reftex-cite-format-builtin): Support
Carsten Dominik <dominik@science.uva.nl>
parents: 59534
diff changeset
648 (format "*%c%d* " sep (decf cnt))
35f6599373fc * textmodes/reftex-vars.el (reftex-cite-format-builtin): Support
Carsten Dominik <dominik@science.uva.nl>
parents: 59534
diff changeset
649 (format "*%d* " (decf cnt)))))
35f6599373fc * textmodes/reftex-vars.el (reftex-cite-format-builtin): Support
Carsten Dominik <dominik@science.uva.nl>
parents: 59534
diff changeset
650 reftex-select-marked)
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
651 (message "Entry no longer marked")))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
652
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
653 (defun reftex-select-help ()
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
654 "Display a summary of the special key bindings."
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
655 (interactive)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
656 (with-output-to-temp-buffer "*RefTeX Help*"
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
657 (princ help-string))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
658 (reftex-enlarge-to-fit "*RefTeX Help*" t))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
659
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
660 ;; Common bindings in reftex-select-label-map and reftex-select-bib-map
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
661 (let ((map (make-sparse-keymap)))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
662 (substitute-key-definition
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
663 'next-line 'reftex-select-next map global-map)
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
664 (substitute-key-definition
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
665 'previous-line 'reftex-select-previous map global-map)
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
666 (substitute-key-definition
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
667 'keyboard-quit 'reftex-select-keyboard-quit map global-map)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
668 (substitute-key-definition
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
669 'newline 'reftex-select-accept map global-map)
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
670
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
671 (loop for x in
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
672 '((" " . reftex-select-callback)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
673 ("n" . reftex-select-next)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
674 ([(down)] . reftex-select-next)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
675 ("p" . reftex-select-previous)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
676 ([(up)] . reftex-select-previous)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
677 ("f" . reftex-select-toggle-follow)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
678 ("\C-m" . reftex-select-accept)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
679 ([(return)] . reftex-select-accept)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
680 ("q" . reftex-select-quit)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
681 ("." . reftex-select-show-insertion-point)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
682 ("?" . reftex-select-help))
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
683 do (define-key map (car x) (cdr x)))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
684
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
685 ;; The mouse-2 binding
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
686 (if (featurep 'xemacs)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
687 (define-key map [(button2)] 'reftex-select-mouse-accept)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
688 (define-key map [(mouse-2)] 'reftex-select-mouse-accept))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
689
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
690 ;; Digit arguments
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
691 (loop for key across "0123456789" do
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
692 (define-key map (vector (list key)) 'digit-argument))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
693 (define-key map "-" 'negative-argument)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
694
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
695 ;; Make two maps
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
696 (setq reftex-select-label-map map)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
697 (setq reftex-select-bib-map (copy-keymap map)))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
698
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
699 ;; Specific bindings in reftex-select-label-map
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
700 (loop for key across "aAcgFlrRstx#%" do
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
701 (define-key reftex-select-label-map (vector (list key))
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
702 (list 'lambda '()
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
703 "Press `?' during selection to find out about this key."
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
704 '(interactive) (list 'throw '(quote myexit) key))))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
705
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
706 (loop for x in
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
707 '(("b" . reftex-select-jump-to-previous)
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
708 ("z" . reftex-select-jump)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
709 ("v" . reftex-select-toggle-varioref)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
710 ("V" . reftex-select-toggle-fancyref)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
711 ("m" . reftex-select-mark)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
712 ("u" . reftex-select-unmark)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
713 ("," . reftex-select-mark-comma)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
714 ("-" . reftex-select-mark-to)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
715 ("+" . reftex-select-mark-and)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
716 ([(tab)] . reftex-select-read-label)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
717 ("\C-i" . reftex-select-read-label)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
718 ("\C-c\C-n" . reftex-select-next-heading)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
719 ("\C-c\C-p" . reftex-select-previous-heading))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
720 do
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
721 (define-key reftex-select-label-map (car x) (cdr x)))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
722
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
723 ;; Specific bindings in reftex-select-bib-map
59534
9bad65481674 2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents: 52401
diff changeset
724 (loop for key across "grRaAeE" do
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
725 (define-key reftex-select-bib-map (vector (list key))
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
726 (list 'lambda '()
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
727 "Press `?' during selection to find out about this key."
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
728 '(interactive) (list 'throw '(quote myexit) key))))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
729
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
730 (loop for x in
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
731 '(("\C-i" . reftex-select-read-cite)
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
732 ([(tab)] . reftex-select-read-cite)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
733 ("m" . reftex-select-mark)
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
734 ("u" . reftex-select-unmark))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
735 do (define-key reftex-select-bib-map (car x) (cdr x)))
52170
27340819ef07 Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents: 49599
diff changeset
736
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
737
52401
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 52170
diff changeset
738 ;;; arch-tag: 842078ff-0586-4e0b-957e-536e08218464
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
739 ;;; reftex-sel.el ends here