Function: xref-find-references-and-replace

xref-find-references-and-replace is an interactive and byte-compiled function defined in xref.el.gz.

Signature

(xref-find-references-and-replace FROM TO)

Documentation

Replace all references to identifier FROM with TO.

View in manual

Probably introduced at or before Emacs version 29.1.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/xref.el.gz
(defun xref-find-references-and-replace (from to)
  "Replace all references to identifier FROM with TO."
  (interactive
   (let* ((query-replace-read-from-default
           (lambda () (xref-backend-identifier-at-point (xref-find-backend))))
          (common
           (query-replace-read-args "Query replace identifier" nil)))
     (list (nth 0 common) (nth 1 common))))
  (require 'xref)
  (with-current-buffer
      (let ((xref-show-xrefs-function
             ;; Some future-proofing (bug#44905).
             (custom--standard-value 'xref-show-xrefs-function))
            ;; Disable auto-jumping, it will mess up replacement logic.
            xref-auto-jump-to-first-xref)
        (xref-find-references from))
    (xref-query-replace-in-results ".*" to)))