;;; reftex-index.el --- index support with RefTeX
-;; Copyright (c) 1997, 1998, 1999, 2000, 2003 Free Software Foundation, Inc.
+;; Copyright (c) 1997, 1998, 1999, 2000, 2003, 2004, 2005
+;; Free Software Foundation, Inc.
;; Author: Carsten Dominik <dominik@science.uva.nl>
-;; Version: 4.21
+;; Version: VERSIONTAG
;; This file is part of GNU Emacs.
;; 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., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
;;; Commentary:
(defvar mark-active)
(defvar zmacs-regions)
(defvar transient-mark-mode)
+(defvar TeX-master)
;; END remove for XEmacs release
(defun reftex-index-selection-or-word (&optional arg phrase)
"Put selection or the word near point into the default index macro.
;; OPT-ARGS is a list of optional argument indices, as given by
;; `reftex-parse-args'.
(let* ((opt (and (integerp itag) (member itag opt-args)))
- (index-tags (cdr (assq 'index-tags
- (symbol-value reftex-docstruct-symbol))))
- (default (reftex-default-index))
- (prompt (concat "Index tag"
- (if default (format " (default: %s)" default) "")
- (if opt " (optional)" "") ": "))
- (tag (completing-read prompt (mapcar 'list index-tags))))
+ (index-tags (cdr (assq 'index-tags
+ (symbol-value reftex-docstruct-symbol))))
+ (default (reftex-default-index))
+ (prompt (concat "Index tag"
+ (if (or opt default)
+ (format " (%s): "
+ (concat
+ (if opt "optional" "")
+ (if default
+ (concat (if opt ", " "")
+ (format "default %s" default))
+ "")))
+ ": ")))
+ (tag (completing-read prompt (mapcar 'list index-tags))))
(if (and default (equal tag "")) (setq tag default))
(reftex-update-default-index tag)
tag))
(reftex-highlight 0 (match-beginning 0) (match-end 0) (current-buffer)))
match))
-(defun reftex-display-index (&optional tag overriding-restriction
+(defun reftex-display-index (&optional tag overriding-restriction redo
&rest locations)
"Display a buffer with an index compiled from the current document.
When the document has multiple indices, first prompts for the correct one.
(calling-file (buffer-file-name))
(restriction
(or overriding-restriction
- (and (interactive-p)
+ (and (not redo)
(reftex-get-restriction current-prefix-arg docstruct))))
(locations
;; See if we are on an index macro as initial position
(if restriction
(setq reftex-index-restriction-indicator (car restriction)
reftex-index-restriction-data (cdr restriction))
- (if (interactive-p)
+ (if (not redo)
(setq reftex-index-restriction-indicator nil
reftex-index-restriction-data nil)))
(when (= (buffer-size) 0)
(error "Don't know which file to rescan. Try `C-u r'")
(switch-to-buffer (reftex-get-file-buffer-force file))
(setq current-prefix-arg '(4))
- (reftex-display-index index-tag nil line)))
+ (reftex-display-index index-tag nil 'redo line)))
(reftex-index-Rescan))
(reftex-kill-temporary-buffers)))
(defun reftex-index-Rescan (&rest ignore)
(switch-to-buffer
(reftex-get-file-buffer-force reftex-last-index-file))
(setq current-prefix-arg '(16))
- (reftex-display-index index-tag nil line)))
+ (reftex-display-index index-tag nil 'redo line)))
(defun reftex-index-revert (&rest ignore)
"Regenerate the *Index* from the internal lists. No reparsing os done."
(interactive)
(reftex-erase-buffer buf)
(setq current-prefix-arg nil
reftex-last-follow-point 1)
- (reftex-display-index index-tag nil data line)))
+ (reftex-display-index index-tag nil 'redo data line)))
(defun reftex-index-switch-index-tag (&rest ignore)
"Switch to a different index of the same document."
(interactive)
(switch-to-buffer
(reftex-get-file-buffer-force reftex-last-index-file))
(setq current-prefix-arg nil)
- (reftex-display-index))
+ (reftex-display-index nil nil 'redo))
(defun reftex-index-restrict-to-section (&optional force)
"Restrict index to entries defined in same document sect. as entry at point."
(error "Not changed"))
((string= npart "")
(if dont-allow-empty
- (error "Illegal value")
+ (error "Invalid value")
(setf (nth n analyze) npart)))
(t (setf (nth n analyze) (concat initial npart))))
(setq new (apply 'concat analyze))
(reftex-insert-index (list data) reftex-index-tag t
"EDITED")))
(setq reftex-last-follow-point 1)
- (and message (message message))))
+ (and message (message "%s" message))))
;; Index map
(define-key reftex-index-map (if (featurep 'xemacs) [(button2)] [(mouse-2)])
(set-marker reftex-index-return-marker (point))
(reftex-index-selection-or-word arg 'phrase)
(if (eq major-mode 'reftex-index-phrases-mode)
- (message
+ (message "%s"
(substitute-command-keys
"Return to LaTeX with \\[reftex-index-phrases-save-and-return]"))))
(defvar reftex-index-phrases-menu)
+(defvar reftex-index-phrases-marker)
(defvar reftex-index-phrases-restrict-file nil)
;;;###autoload
(defun reftex-index-phrases-mode ()
reftex-index-phrases-font-lock-defaults) ; XEmacs
)
-(defvar reftex-index-phrases-marker)
(defun reftex-index-next-phrase (&optional arg)
"Index the next ARG phrases in the phrases buffer."
(interactive "p")
(if (re-search-forward reftex-index-phrases-phrase-regexp12 nil t)
(progn
(goto-char (match-beginning 0))
- (reftex-index-this-phrase))
+ (reftex-index-this-phrase 'slave))
(error "No more phrase lines after point"))))
-(defun reftex-index-this-phrase ()
+(defun reftex-index-this-phrase (&optional slave)
"Index the phrase in the current line.
Does a global search and replace in the entire document. At each
match, the user will be asked to confirm the replacement."
(interactive)
- (if (interactive-p) (reftex-index-phrases-parse-header t))
+ (if (not slave) (reftex-index-phrases-parse-header t))
(save-excursion
(beginning-of-line)
(cond ((looking-at reftex-index-phrases-comment-regexp)
- (if (interactive-p) (error "Comment line")))
+ (if (not slave) (error "Comment line")))
((looking-at "^[ \t]*$")
- (if (interactive-p) (error "Empty line")))
+ (if (not slave) (error "Empty line")))
((looking-at reftex-index-phrases-macrodef-regexp)
- (if (interactive-p) (error "Macro definition line")))
+ (if (not slave) (error "Macro definition line")))
((looking-at reftex-index-phrases-phrase-regexp12)
;; This is a phrase
(let* ((char (if (not (equal (match-string 1) ""))
(file-regular-p reftex-index-phrases-restrict-file))
(list reftex-index-phrases-restrict-file))
((stringp reftex-index-phrases-restrict-file)
- (error "Illegal restriction file %s"
+ (error "Invalid restriction file %s"
reftex-index-phrases-restrict-file))
(t reftex-index-phrases-files)))
(as-words reftex-index-phrases-search-whole-words))
(goto-char beg)
(while (not (or (eobp)
(>= (point) end)))
- (save-excursion (reftex-index-this-phrase))
+ (save-excursion (reftex-index-this-phrase 'slave))
(beginning-of-line 2)))
(defun reftex-index-phrases-parse-header (&optional get-files)
"\\([ \t]*\\(\n[ \t]*\\)?\\|[ \t]\\)"
"\\([ \t]+\\)")))
(concat (if (and as-words (string-match "\\`\\w" (car words)))
- "\\<" "")
- (mapconcat (lambda (w) (regexp-quote (downcase w)))
+ "\\(\\<\\|[`']\\)" "")
+ (mapconcat (lambda (w) (regexp-quote
+ (if reftex-index-phrases-case-fold-search
+ (downcase w)
+ w)))
words space-re)
(if (and as-words
(string-match "\\w\\'" (nth (1- (length words)) words)))
- "\\>" ""))))
+ "\\(\\>\\|'\\)" ""))))
(defun reftex-index-simplify-phrase (phrase)
"Make phrase single spaces and single line."
(nkeys (length index-keys))
(ckey (nth 0 index-keys))
(all-yes nil)
- match rpl char beg end mathp)
+ match rpl char (beg (make-marker)) (end (make-marker)) mathp)
+ (move-marker beg 1)
+ (move-marker end 1)
(unwind-protect
(while (re-search-forward re nil t)
(catch 'next-match
+ (if (reftex-in-comment)
+ (throw 'next-match nil))
(if (and (fboundp reftex-index-verify-function)
(not (funcall reftex-index-verify-function)))
(throw 'next-match nil))
(setq mathp
(save-match-data
(condition-case nil (texmathp) (error nil))))
- (setq beg (car (match-data))
- end (nth 1 (match-data)))
+ (setq beg (move-marker beg (match-beginning 0))
+ end (move-marker end (match-end 0)))
(if (and reftex-index-phrases-skip-indexed-matches
(save-match-data
(reftex-index-phrase-match-is-indexed beg
;; Recursive edit
(save-match-data
(save-excursion
- (message
+ (message "%s"
(substitute-command-keys
"Recursive edit. Resume with \\[exit-recursive-edit]"))
(recursive-edit))))
(t (ding)))
nil)))))
(message "")
+ (move-marker beg nil)
+ (move-marker end nil)
(setq all-yes nil)
(reftex-unhighlight 0))))
(defun reftex-index-phrase-match-is-indexed (beg end)
- ;; CHeck if match is in an argument of an index macro, or if an
+ ;; Check if match is in an argument of an index macro, or if an
;; index macro is directly attached to the match.
(save-excursion
(goto-char end)
(let* ((all-macros (reftex-what-macro t))
- (this-macro (car (car all-macros)))
+; (this-macro (car (car all-macros)))
(before-macro
(and (> beg 2)
(goto-char (1- beg))
["Save and Return" reftex-index-phrases-save-and-return t]))
+;;; arch-tag: 4b2362af-c156-42c1-8932-ea2823e205c1
;;; reftex-index.el ends here