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