diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index c812f28c1b..c58c05bc71 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el @@ -1072,9 +1072,10 @@ project-query-replace-regexp If you exit the `query-replace', you can later continue the `query-replace' loop using the command \\[fileloop-continue]." (interactive - (pcase-let ((`(,from ,to) - (query-replace-read-args "Query replace (regexp)" t t))) - (list from to))) + (let ((read-regexp-defaults-function 'find-tag-default-as-regexp)) + (pcase-let ((`(,from ,to) + (query-replace-read-args "Query replace (regexp)" t t))) + (list from to)))) (fileloop-initialize-replace from to (project-files (project-current t)) 'default) (fileloop-continue)) diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el index 37e2159782..640c8745db 100644 --- a/lisp/progmodes/xref.el +++ b/lisp/progmodes/xref.el @@ -1481,8 +1481,9 @@ xref-find-references (defun xref-find-references-and-replace (from to) "Replace all references to identifier FROM with TO." (interactive - (let ((common - (query-replace-read-args "Query replace identifier" nil))) + (let* ((read-regexp-defaults-function 'find-tag-default-as-regexp) + (common + (query-replace-read-args "Query replace identifier" nil))) (list (nth 0 common) (nth 1 common)))) (require 'xref) (with-current-buffer diff --git a/lisp/replace.el b/lisp/replace.el index 60e507c642..9c7680a563 100644 --- a/lisp/replace.el +++ b/lisp/replace.el @@ -234,7 +234,8 @@ query-replace-read-from (symbol-value query-replace-from-history-variable))) (minibuffer-allow-text-properties t) ; separator uses text-properties (prompt - (cond ((and query-replace-defaults separator) + (cond ((and regexp-flag read-regexp-defaults-function) prompt) + ((and query-replace-defaults separator) (format-prompt prompt (car minibuffer-history))) (query-replace-defaults (format-prompt @@ -255,7 +256,10 @@ query-replace-read-from (append '((separator . t) (face . t)) text-property-default-nonsticky))) (if regexp-flag - (read-regexp prompt nil 'minibuffer-history) + (read-regexp + (if read-regexp-defaults-function (string-remove-suffix ": " prompt)) + read-regexp-defaults-function + 'minibuffer-history) (read-from-minibuffer prompt nil nil nil nil (query-replace-read-from-suggestions) t)))))