;;; reftex-sel.el --- the selection modes for RefTeX
;; Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
-;; 2006, 2007 Free Software Foundation, Inc.
+;; 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
;; Author: Carsten Dominik <dominik@science.uva.nl>
;; Maintainer: auctex-devel@gnu.org
;; This file is part of GNU Emacs.
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2, or (at your option)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING. If not, write to the
-;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
+;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
(defun reftex-select-label-mode ()
"Major mode for selecting a label in a LaTeX document.
This buffer was created with RefTeX.
-It only has a meaningful keymap when you are in the middle of a
+It only has a meaningful keymap when you are in the middle of a
selection process.
To select a label, move the cursor to it and press RET.
Press `?' for a summary of important key bindings.
(defun reftex-select-bib-mode ()
"Major mode for selecting a citation key in a LaTeX document.
This buffer was created with RefTeX.
-It only has a meaningful keymap when you are in the middle of a
+It only has a meaningful keymap when you are in the middle of a
selection process.
In order to select a citation, move the cursor to it and press RET.
Press `?' for a summary of important key bindings.
;; We do not set a local map - reftex-select-item does this.
(run-hooks 'reftex-select-bib-mode-hook))
-;;; (defun reftex-get-offset (buf here-am-I &optional typekey toc index file)
-;;; ;; Find the correct offset data, like insert-docstruct would, but faster.
-;;; ;; Buffer BUF knows the correct docstruct to use.
-;;; ;; Basically this finds the first docstruct entry after HERE-I-AM which
-;;; ;; is of allowed type. The optional arguments specify what is allowed.
-;;; (catch 'exit
-;;; (save-excursion
-;;; (set-buffer buf)
-;;; (reftex-access-scan-info)
-;;; (let* ((rest (memq here-am-I (symbol-value reftex-docstruct-symbol)))
-;;; entry)
-;;; (while (setq entry (pop rest))
-;;; (if (or (and typekey
-;;; (stringp (car entry))
-;;; (or (equal typekey " ")
-;;; (equal typekey (nth 1 entry))))
-;;; (and toc (eq (car entry) 'toc))
-;;; (and index (eq (car entry) 'index))
-;;; (and file
-;;; (memq (car entry) '(bof eof file-error))))
-;;; (throw 'exit entry)))
-;;; nil))))
+;; (defun reftex-get-offset (buf here-am-I &optional typekey toc index file)
+;; ;; Find the correct offset data, like insert-docstruct would, but faster.
+;; ;; Buffer BUF knows the correct docstruct to use.
+;; ;; Basically this finds the first docstruct entry after HERE-I-AM which
+;; ;; is of allowed type. The optional arguments specify what is allowed.
+;; (catch 'exit
+;; (with-current-buffer buf
+;; (reftex-access-scan-info)
+;; (let* ((rest (memq here-am-I (symbol-value reftex-docstruct-symbol)))
+;; entry)
+;; (while (setq entry (pop rest))
+;; (if (or (and typekey
+;; (stringp (car entry))
+;; (or (equal typekey " ")
+;; (equal typekey (nth 1 entry))))
+;; (and toc (eq (car entry) 'toc))
+;; (and index (eq (car entry) 'index))
+;; (and file
+;; (memq (car entry) '(bof eof file-error))))
+;; (throw 'exit entry)))
+;; nil))))
(defun reftex-get-offset (buf here-am-I &optional typekey toc index file)
;; Find the correct offset data, like insert-docstruct would, but faster.
;; Basically this finds the first docstruct entry before HERE-I-AM which
;; is of allowed type. The optional arguments specify what is allowed.
(catch 'exit
- (save-excursion
- (set-buffer buf)
+ (with-current-buffer buf
(reftex-access-scan-info)
(let* ((rest (symbol-value reftex-docstruct-symbol))
lastentry entry)
prev-inserted offset from to index-tag docstruct-symbol)
;; Pop to buffer buf to get the correct buffer-local variables
- (save-excursion
- (set-buffer buf)
+ (with-current-buffer buf
;; Ensure access to scanning info
(reftex-access-scan-info)
note (nth 5 cell))
(when (and labels
- (or (eq labels t)
+ (or (eq labels t)
(string= typekey labels)
(string= labels " "))
(or show-commented (null comment)))
(put-text-property from to :data cell)
(when mouse-face
(put-text-property from (1- to)
- 'mouse-face mouse-face))
+ 'mouse-face mouse-face))
(goto-char to)))
((eq (car cell) 'index)
(when font
(setq to (point))
- (put-text-property
+ (put-text-property
(- (point) (length (nth 7 cell))) to
'face index-face)
(goto-char to))
(put-text-property from to :data cell)
(when mouse-face
(put-text-property from (1- to)
- 'mouse-face mouse-face))
+ 'mouse-face mouse-face))
(goto-char to))))
- (if (eq cell here-I-am)
+ (if (eq cell here-I-am)
(setq offset 'attention))
(if (and prev-inserted (eq offset 'attention))
(setq offset prev-inserted))
((listp loc)
(setq pos (text-property-any (point-min) (point-max) :data loc))
(when pos
- (goto-char pos)
+ (goto-char pos)
(throw 'exit t)))
((integerp loc)
(when (<= loc (count-lines (point-min) (point-max)))
- (goto-line loc)
+ (goto-char (point-min))
+ (forward-line (1- loc))
(throw 'exit t)))))
(goto-char fallback))))
(setq truncate-lines t)
;; Find a good starting point
- (reftex-find-start-point
+ (reftex-find-start-point
(point-min) offset reftex-last-data reftex-last-line)
(beginning-of-line 1)
(set (make-local-variable 'reftex-last-follow-point) (point))
(recursive-edit))
(set-marker reftex-recursive-edit-marker nil)
- (save-excursion
- (set-buffer selection-buffer)
+ (with-current-buffer selection-buffer
(use-local-map nil)
(remove-hook 'pre-command-hook 'reftex-select-pre-command-hook t)
- (remove-hook 'post-command-hook
+ (remove-hook 'post-command-hook
'reftex-select-post-command-hook t))
;; Kill the mark overlays
- (mapcar (lambda (c) (reftex-delete-overlay (nth 1 c)))
- reftex-select-marked)))))
+ (mapc (lambda (c) (reftex-delete-overlay (nth 1 c)))
+ reftex-select-marked)))))
(set (make-local-variable 'reftex-last-line)
(+ (count-lines (point-min) (point)) (if (bolp) 1 0)))
(let (b e)
(setq data (get-text-property (point) :data))
(setq last-data (or data last-data))
-
+
(when (and data cb-flag
(not (equal reftex-last-follow-point (point))))
(setq reftex-last-follow-point (point))
- (funcall call-back data reftex-callback-fwd
+ (funcall call-back data reftex-callback-fwd
(not reftex-revisit-to-follow)))
(if data
(setq b (or (previous-single-property-change
(goto-char pos))
((and (local-variable-p 'reftex-last-line (current-buffer))
(integerp reftex-last-line))
- (goto-line reftex-last-line))
+ (goto-char (point-min))
+ (forward-line (1- reftex-last-line)))
(t (ding)))))
(defun reftex-select-toggle-follow ()
"Toggle follow mode: Other window follows with full context."
(defun reftex-select-read-label ()
"Use minibuffer to read a label to reference, with completion."
(interactive)
- (let ((label (completing-read
+ (let ((label (completing-read
"Label: " (symbol-value reftex-docstruct-symbol)
nil nil reftex-prefix)))
(unless (or (equal label "") (equal label reftex-prefix))
(and ovl (reftex-delete-overlay ovl))
(setq reftex-select-marked (delq cell reftex-select-marked))
(setq cnt (1+ (length reftex-select-marked)))
- (mapcar (lambda (c)
- (setq sep (nth 2 c))
- (reftex-overlay-put (nth 1 c) 'before-string
- (if sep
- (format "*%c%d* " sep (decf cnt))
- (format "*%d* " (decf cnt)))))
+ (mapc (lambda (c)
+ (setq sep (nth 2 c))
+ (reftex-overlay-put (nth 1 c) 'before-string
+ (if sep
+ (format "*%c%d* " sep (decf cnt))
+ (format "*%d* " (decf cnt)))))
reftex-select-marked)
(message "Entry no longer marked")))
([(up)] . reftex-select-previous)
("f" . reftex-select-toggle-follow)
("\C-m" . reftex-select-accept)
- ([(return)] . reftex-select-accept)
+ ([(return)] . reftex-select-accept)
("q" . reftex-select-quit)
("." . reftex-select-show-insertion-point)
("?" . reftex-select-help))
(define-key map [(button2)] 'reftex-select-mouse-accept)
(define-key map [(mouse-2)] 'reftex-select-mouse-accept)
(define-key map [follow-link] 'mouse-face))
-
+
;; Digit arguments
(loop for key across "0123456789" do
;; Specific bindings in reftex-select-label-map
(loop for key across "aAcgFlrRstx#%" do
(define-key reftex-select-label-map (vector (list key))
- (list 'lambda '()
+ (list 'lambda '()
"Press `?' during selection to find out about this key."
'(interactive) (list 'throw '(quote myexit) key))))
;; Specific bindings in reftex-select-bib-map
(loop for key across "grRaAeE" do
(define-key reftex-select-bib-map (vector (list key))
- (list 'lambda '()
+ (list 'lambda '()
"Press `?' during selection to find out about this key."
'(interactive) (list 'throw '(quote myexit) key))))
("m" . reftex-select-mark)
("u" . reftex-select-unmark))
do (define-key reftex-select-bib-map (car x) (cdr x)))
-
-;;; arch-tag: 842078ff-0586-4e0b-957e-536e08218464
+
+;; arch-tag: 842078ff-0586-4e0b-957e-536e08218464
;;; reftex-sel.el ends here