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