Function: reftex-index-this-phrase
reftex-index-this-phrase is an interactive and byte-compiled function
defined in reftex-index.el.gz.
Signature
(reftex-index-this-phrase &optional SLAVE)
Documentation
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.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/textmodes/reftex-index.el.gz
(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 (not slave) (reftex-index-phrases-parse-header t))
(save-excursion
(beginning-of-line)
(cond ((looking-at reftex-index-phrases-comment-regexp)
(if (not slave) (error "Comment line")))
((looking-at "^[ \t]*$")
(if (not slave) (error "Empty line")))
((looking-at reftex-index-phrases-macrodef-regexp)
(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) ""))
(string-to-char (match-string 1))))
(phrase (match-string 3))
(index-key (match-string 6))
(macro-data (cdr (if (null char)
(car reftex-index-phrases-macro-data)
(assoc char reftex-index-phrases-macro-data))))
(macro-fmt (car macro-data))
(repeat (nth 1 macro-data))
(files
(cond ((and (stringp reftex-index-phrases-restrict-file)
(file-regular-p reftex-index-phrases-restrict-file))
(list reftex-index-phrases-restrict-file))
((stringp reftex-index-phrases-restrict-file)
(error "Invalid restriction file %s"
reftex-index-phrases-restrict-file))
(t reftex-index-phrases-files)))
(as-words reftex-index-phrases-search-whole-words))
(unless macro-data
(error "No macro associated with key %c" char))
(unwind-protect
(let ((overlay-arrow-string "=>")
(overlay-arrow-position
reftex-index-phrases-marker)
(replace-count 0))
;; Show the overlay arrow
(move-marker reftex-index-phrases-marker
(match-beginning 0) (current-buffer))
;; Start the query-replace
(reftex-query-index-phrase-globally
files phrase macro-fmt
index-key repeat as-words)
(message "%s replaced"
(reftex-number replace-count "occurrence"))))))
(t (error "Cannot parse this line")))))