Function: reftex-index-selection-or-word
reftex-index-selection-or-word is an autoloaded, interactive and
byte-compiled function defined in reftex-index.el.gz.
Signature
(reftex-index-selection-or-word &optional ARG PHRASE)
Documentation
Put selection or the word near point into the default index macro.
This uses the information in reftex-index-default-macro to make an index
entry. The phrase indexed is the current selection or the word near point.
When called with one C-u (universal-argument) prefix, let the user have a chance to edit the
index entry. When called with 2 C-u (universal-argument) as prefix, also ask for the index
macro and other stuff.
When called inside TeX math mode as determined by the texmathp.el library
which is part of AUCTeX, the string is first processed with the
reftex-index-math-format, which see.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/textmodes/reftex-index.el.gz
;;;###autoload
(defun reftex-index-selection-or-word (&optional arg phrase)
"Put selection or the word near point into the default index macro.
This uses the information in `reftex-index-default-macro' to make an index
entry. The phrase indexed is the current selection or the word near point.
When called with one \\[universal-argument] prefix, let the user have a chance to edit the
index entry. When called with 2 \\[universal-argument] as prefix, also ask for the index
macro and other stuff.
When called inside TeX math mode as determined by the `texmathp.el' library
which is part of AUCTeX, the string is first processed with the
`reftex-index-math-format', which see."
(interactive "P")
(let* ((use-default (not (equal arg '(16)))) ; check for double prefix
;; check if we have an active selection
(active (region-active-p))
(beg (if active
(region-beginning)
(save-excursion
(skip-syntax-backward "w\\") (point))))
(end (if active
(region-end)
(save-excursion
(skip-syntax-forward "w\\") (point))))
(sel (buffer-substring beg end))
(mathp (condition-case nil (texmathp) (error nil)))
(current-prefix-arg nil) ; we want to call reftex-index without prefix.
key def-char def-tag full-entry)
(if phrase
(progn
(reftex-index-visit-phrases-buffer)
(reftex-index-new-phrase sel))
(if (equal sel "")
;; Nothing selected, no word, so use full reftex-index command
(reftex-index)
;; OK, we have something to index here.
;; Add the dollars when necessary
(setq key (if mathp
(format reftex-index-math-format sel)
sel))
;; Get info from `reftex-index-default-macro'
(setq def-char (if use-default (car reftex-index-default-macro)))
(setq def-tag (if use-default (nth 1 reftex-index-default-macro)))
;; Does the user want to edit the entry?
(setq full-entry (if arg
(reftex-index-complete-key
def-tag nil (cons key 0))
key))
;; Delete what is in the buffer and make the index entry
(delete-region beg end)
(reftex-index def-char full-entry def-tag sel)))))