Function: reftex-toc-rename-label

reftex-toc-rename-label is an interactive and byte-compiled function defined in reftex-toc.el.gz.

Signature

(reftex-toc-rename-label)

Documentation

Rename the currently selected label in the *toc* buffer.

This launches a global search and replace in order to rename a label. Renaming a label is hardly ever necessary - the only exception is after promotion/demotion in connection with a package like fancyref, where the label prefix determines the wording of a reference.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/textmodes/reftex-toc.el.gz
(defun reftex-toc-rename-label ()
  "Rename the currently selected label in the *toc* buffer.
This launches a global search and replace in order to rename a label.
Renaming a label is hardly ever necessary - the only exception is after
promotion/demotion in connection with a package like fancyref, where the
label prefix determines the wording of a reference."
  (interactive)
  (let* ((toc (get-text-property (point) :data))
         (label (car toc)) newlabel)
    (if (not (stringp label))
        (error "This is not a label entry"))
    (setq newlabel (read-string (format "Rename label \"%s\" to: " label)))
    (if (assoc newlabel (symbol-value reftex-docstruct-symbol))
        (if (not (y-or-n-p
                  (format-message "Label `%s' exists.  Use anyway? " newlabel)))
            (error "Abort")))
    (save-excursion
      (save-window-excursion
        (reftex-toc-visit-location t)
        (condition-case nil
            (reftex-query-replace-document
             (concat "{" (regexp-quote label) "}")
             (format "{%s}" newlabel))
          (error t))))
    (reftex-toc-rescan)))