[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master b2cc03d572 1/2: Steamline xref-query-replace-in-results
From: |
Dmitry Gutov |
Subject: |
master b2cc03d572 1/2: Steamline xref-query-replace-in-results |
Date: |
Thu, 13 Jan 2022 21:40:50 -0500 (EST) |
branch: master
commit b2cc03d572aa4ef591b38e461b0ecb68837cbfc5
Author: Dmitry Gutov <dgutov@yandex.ru>
Commit: Dmitry Gutov <dgutov@yandex.ru>
Steamline xref-query-replace-in-results
* lisp/progmodes/xref.el (xref-query-replace-in-results):
Steamline the most common scenario
(https://lists.gnu.org/archive/html/emacs-devel/2022-01/msg00864.html).
---
etc/NEWS | 4 ++++
lisp/progmodes/xref.el | 17 +++++++++++++----
2 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/etc/NEWS b/etc/NEWS
index 06a6886ebf..8fd717cfc8 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -594,6 +594,10 @@ to enable the display of the buffer list.
It is bound to 'C-M-,' and jumps to the location where 'xref-go-back'
('M-,', also known as 'xref-pop-marker-stack') was invoked previously.
+*** 'xref-query-replace-in-results' only prompts for TO when called
+without prefix argument, to make the most common case faster:
+replacing all matches entirely.
+
** File notifications
+++
diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index 9ce63a8f8a..06faf16a31 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -738,11 +738,20 @@ quit the *xref* buffer."
"Perform interactive replacement of FROM with TO in all displayed xrefs.
This command interactively replaces FROM with TO in the names of the
-references displayed in the current *xref* buffer."
+references displayed in the current *xref* buffer.
+
+When called interactively, it uses '.*' as FROM, which means
+replace the whole name. Unless called with prefix argument, in
+which case the user is prompted for both FROM and TO."
(interactive
- (let ((fr (read-regexp "Xref query-replace (regexp)" ".*")))
- (list fr
- (read-regexp (format "Xref query-replace (regexp) %s with: " fr)))))
+ (let* ((fr
+ (if prefix-arg
+ (read-regexp "Query-replace (regexp)" ".*")
+ ".*"))
+ (prompt (if 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))