diff --git a/lisp/replace.el b/lisp/replace.el index 69092c16f9..a5a5200df7 100644 --- a/lisp/replace.el +++ b/lisp/replace.el @@ -227,7 +227,16 @@ query-replace-read-from (if regexp-flag (read-regexp prompt nil 'minibuffer-history) (read-from-minibuffer - prompt nil nil nil nil (car search-ring) t))))) + prompt nil nil nil nil + (delq nil + (list + (when (use-region-p) + (buffer-substring-no-properties + (region-beginning) (region-end))) + (find-tag-default) + (car search-ring) + (car (symbol-value query-replace-from-history-variable)))) + t))))) (to)) (if (and (zerop (length from)) query-replace-defaults) (cons (caar query-replace-defaults) @@ -798,6 +807,9 @@ read-regexp-suggestions appends the list returned by this function to the end of values available via \\\\[next-history-element]." (list + (when (use-region-p) + (buffer-substring-no-properties + (region-beginning) (region-end))) (find-tag-default-as-regexp) (find-tag-default-as-symbol-regexp) (car regexp-search-ring)