Function: xref-query-replace-in-results
xref-query-replace-in-results is an interactive and byte-compiled
function defined in xref.el.gz.
Signature
(xref-query-replace-in-results FROM TO)
Documentation
Perform interactive replacement of FROM with TO in all displayed xrefs.
This function interactively replaces FROM with TO in the names of the references displayed in the current *xref* buffer.
When called interactively, it uses '.*' as FROM, which means replace the whole name, and prompts the user for TO. If invoked with prefix argument, it prompts the user for both FROM and TO.
As each match is found, the user must type a character saying
what to do with it. Type SPC or y to replace the match,
DEL or n to skip and go to the next match. For more directions,
type <f1> (help-command) at that time.
Note that this function cannot be used in *xref* buffers that show
a partial list of all references, such as the *xref* buffer created
by M-. (xref-find-definitions) and its variants, since those list only
some of the references to the identifiers.
Probably introduced at or before Emacs version 25.1.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/xref.el.gz
(defun xref-query-replace-in-results (from to)
"Perform interactive replacement of FROM with TO in all displayed xrefs.
This function interactively replaces FROM with TO in the names of the
references displayed in the current *xref* buffer.
When called interactively, it uses '.*' as FROM, which means replace
the whole name, and prompts the user for TO.
If invoked with prefix argument, it prompts the user for both FROM and TO.
As each match is found, the user must type a character saying
what to do with it. Type SPC or `y' to replace the match,
DEL or `n' to skip and go to the next match. For more directions,
type \\[help-command] at that time.
Note that this function cannot be used in *xref* buffers that show
a partial list of all references, such as the *xref* buffer created
by \\[xref-find-definitions] and its variants, since those list only
some of the references to the identifiers."
(interactive
(let* ((fr
(if current-prefix-arg
(read-regexp "Query-replace (regexp)" ".*")
".*"))
(prompt (if current-prefix-arg
(format "Query-replace (regexp) %s with: " fr)
"Query-replace all matches with: ")))
(list fr (read-regexp prompt))))
(let* (item xrefs iter)
(save-excursion
(while (setq item (xref--search-property 'xref-item))
(when (xref-match-length item)
(push item xrefs))))
(unwind-protect
(progn
(goto-char (point-min))
(setq iter (xref--buf-pairs-iterator (nreverse xrefs)))
(xref--query-replace-1 from to iter))
(funcall iter :cleanup))))