X-Git-Url: https://git.hcoop.net/bpt/emacs.git/blobdiff_plain/7b1019e2781472c793d0bf74e2b9ee17894270b8..cf38dd429888fc992408716922ecab1c39242944:/lisp/textmodes/reftex.el diff --git a/lisp/textmodes/reftex.el b/lisp/textmodes/reftex.el index 47c25a1566..2a2e725e92 100644 --- a/lisp/textmodes/reftex.el +++ b/lisp/textmodes/reftex.el @@ -1,6 +1,6 @@ ;;; reftex.el --- minor mode for doing \label, \ref, \cite, \index in LaTeX ;; Copyright (C) 1997, 1998, 1999, 2000, 2003, 2004, 2005, -;; 2006, 2007, 2008 Free Software Foundation, Inc. +;; 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. ;; Author: Carsten Dominik ;; Maintainer: auctex-devel@gnu.org @@ -305,10 +305,6 @@ (defconst reftex-version "RefTeX version 4.31" "Version string for RefTeX.") -(defvar reftex-mode nil - "Determines if RefTeX mode is active.") -(make-variable-buffer-local 'reftex-mode) - (defvar reftex-mode-map (make-sparse-keymap) "Keymap for RefTeX mode.") @@ -431,7 +427,7 @@ ;;; Index support (autoload 'reftex-index "reftex-index" - "Query for an index macro and insert it along with its argments." t) + "Query for an index macro and insert it along with its arguments." t) (autoload 'reftex-index-selection-or-word "reftex-index" "Put selection or the word near point into the default index macro." t) (autoload 'reftex-index-phrase-selection-or-word "reftex-index" @@ -504,8 +500,10 @@ "Turn on RefTeX mode." (reftex-mode t)) +(put 'reftex-mode :included '(memq major-mode '(latex-mode tex-mode))) +(put 'reftex-mode :menu-tag "RefTeX Mode") ;;;###autoload -(defun reftex-mode (&optional arg) +(define-minor-mode reftex-mode "Minor mode with distinct support for \\label, \\ref and \\cite in LaTeX. \\A Table of Contents of the entire (multifile) document with browsing @@ -535,11 +533,7 @@ Under X, these and other functions will also be available as `Ref' menu on the menu bar. ------------------------------------------------------------------------------" - - (interactive "P") - (setq reftex-mode (not (or (and (null arg) reftex-mode) - (<= (prefix-numeric-value arg) 0)))) - + :lighter " Ref" :keymap reftex-mode-map (if reftex-mode (progn ;; Mode was turned on @@ -565,24 +559,10 @@ on the menu bar. (modify-syntax-entry ?\' "." reftex-syntax-table-for-bib) (modify-syntax-entry ?\" "." reftex-syntax-table-for-bib) (modify-syntax-entry ?\[ "." reftex-syntax-table-for-bib) - (modify-syntax-entry ?\] "." reftex-syntax-table-for-bib) - - (run-hooks 'reftex-mode-hook)) + (modify-syntax-entry ?\] "." reftex-syntax-table-for-bib)) ;; Mode was turned off (easy-menu-remove reftex-mode-menu))) -(if (fboundp 'add-minor-mode) - ;; Use it so that we get the extras - (progn - (put 'reftex-mode :included '(memq major-mode '(latex-mode tex-mode))) - (put 'reftex-mode :menu-tag "RefTeX Mode") - (add-minor-mode 'reftex-mode " Ref" reftex-mode-map)) - ;; The standard way - (unless (assoc 'reftex-mode minor-mode-alist) - (push '(reftex-mode " Ref") minor-mode-alist)) - (unless (assoc 'reftex-mode minor-mode-map-alist) - (push (cons 'reftex-mode reftex-mode-map) minor-mode-map-alist))) - (defvar reftex-docstruct-symbol) (defun reftex-kill-buffer-hook () "Save RefTeX's parse file for this buffer if the information has changed." @@ -619,17 +599,16 @@ on the menu bar. (defvar font-lock-mode) (defvar font-lock-keywords) (defvar font-lock-fontify-region-function) -(defvar font-lock-syntactic-keywords) ;;; ========================================================================= ;;; ;;; Multibuffer Variables ;;; -;;; Technical notes: These work as follows: We keep just one list -;;; of labels for each master file - this can save a lot of memory. -;;; `reftex-master-index-list' is an alist which connects the true file name -;;; of each master file with the symbols holding the information on that -;;; document. Each buffer has local variables which point to these symbols. +;; Technical notes: These work as follows: We keep just one list +;; of labels for each master file - this can save a lot of memory. +;; `reftex-master-index-list' is an alist which connects the true file name +;; of each master file with the symbols holding the information on that +;; document. Each buffer has local variables which point to these symbols. ;; List of variables which handle the multifile stuff. ;; This list is used to tie, untie, and reset these symbols. @@ -1822,9 +1801,8 @@ When DIE is non-nil, throw an error if file not found." (let ((buffer-read-only nil)) (erase-buffer))) ((setq buffer (get-buffer buffer)) ;; buffer exists - (save-excursion - (set-buffer buffer) - (let ((buffer-read-only nil)) (erase-buffer)))))) + (with-current-buffer buffer + (let ((inhibit-read-only t)) (erase-buffer)))))) (defun reftex-this-word (&optional class) ;; Grab the word around point. @@ -2063,17 +2041,16 @@ When DIE is non-nil, throw an error if file not found." ;; with limited Magic ;; The magic goes away - (let ((format-alist nil) - (auto-mode-alist (reftex-auto-mode-alist)) - (default-major-mode 'fundamental-mode) - (enable-local-variables nil) - (after-insert-file-functions nil)) + (letf ((format-alist nil) + (auto-mode-alist (reftex-auto-mode-alist)) + ((default-value 'major-mode) 'fundamental-mode) + (enable-local-variables nil) + (after-insert-file-functions nil)) (setq buf (find-file-noselect file))) ;; Is there a hook to run? (when (listp reftex-initialize-temporary-buffers) - (save-excursion - (set-buffer buf) + (with-current-buffer buf (run-hooks 'reftex-initialize-temporary-buffers)))) ;; Lets see if we got a license to kill :-| @@ -2100,8 +2077,7 @@ When DIE is non-nil, throw an error if file not found." (and (buffer-modified-p buffer) (y-or-n-p (format "Save file %s? " (buffer-file-name buffer))) - (save-excursion - (set-buffer buffer) + (with-current-buffer buffer (save-buffer))) (kill-buffer buffer)) (pop reftex-buffers-to-kill))))) @@ -2406,16 +2382,23 @@ IGNORE-WORDS List of words which should be removed from the string." ;; Setting `reftex-extra-bindings' really is only there to spare users ;; the hassle of defining bindings in the user space themselves. This ;; is why they violate the key binding recommendations. +(defvar reftex-extra-bindings-map + (let ((map (make-sparse-keymap))) + (define-key map "t" 'reftex-toc) + (define-key map "l" 'reftex-label) + (define-key map "r" 'reftex-reference) + (define-key map "c" 'reftex-citation) + (define-key map "v" 'reftex-view-crossref) + (define-key map "g" 'reftex-grep-document) + (define-key map "s" 'reftex-search-document) + map) + "Reftex extra bindings map") + (when reftex-extra-bindings - (loop for x in - '(("\C-ct" . reftex-toc) - ("\C-cl" . reftex-label) - ("\C-cr" . reftex-reference) - ("\C-cc" . reftex-citation) - ("\C-cv" . reftex-view-crossref) - ("\C-cg" . reftex-grep-document) - ("\C-cs" . reftex-search-document)) - do (define-key reftex-mode-map (car x) (cdr x)))) + (define-key reftex-mode-map + reftex-extra-bindings-prefix + reftex-extra-bindings-map)) + ;;; ========================================================================= ;;;