bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#23418: 25.1.50; next-history-element no longer works in query-replac


From: Juri Linkov
Subject: bug#23418: 25.1.50; next-history-element no longer works in query-replace
Date: Tue, 03 May 2016 23:28:18 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.93 (x86_64-pc-linux-gnu)

>> 1. emacs -q
>> 2. Go to the scratch buffer and place point on a word.
>> 3. M-x query-replace-regexp (or query-replace)
>> 4. M-n
>> 5. Emacs will say: “End of history; no default available”.
>>
>> Until recently, this would try to “guess” what you want to replace by
>> inserting the word at point on the prompt. If you kept hitting M-n it
>> would try other guesses like inserting the word surrounded in symbol
>> delimiters.
>
> I see the same bug caused by
> http://git.sv.gnu.org/cgit/emacs.git/commit/?h=emacs-25&id=f99b51295b86770e4b16d4717c0e73049191c4c5
> that breaks syntax for bounds-of-thing-at-point.

As pointed out by Stefan in
http://lists.gnu.org/archive/html/emacs-devel/2016-03/msg01504.html
http://lists.gnu.org/archive/html/emacs-devel/2016-03/msg01538.html
a proper fix for bug#23127 is to use minibuffer-with-setup-hook:

diff --git a/lisp/replace.el b/lisp/replace.el
index 801c605..26e5875 100644
--- a/lisp/replace.el
+++ b/lisp/replace.el
@@ -191,18 +191,15 @@ query-replace-read-from
            ;; a region in order to specify the minibuffer input.
            ;; That should not clobber the region for the query-replace itself.
            (save-excursion
-              ;; The `with-current-buffer' ensures that the binding
-              ;; for `text-property-default-nonsticky' isn't a buffer
-              ;; local binding in the current buffer, which
-              ;; `read-from-minibuffer' wouldn't see.
-              (with-current-buffer (window-buffer (minibuffer-window))
-                (let ((text-property-default-nonsticky
-                       (cons '(separator . t) 
text-property-default-nonsticky)))
-                  (if regexp-flag
-                      (read-regexp prompt nil 'query-replace-from-to-history)
-                    (read-from-minibuffer
-                     prompt nil nil nil 'query-replace-from-to-history
-                     (car (if regexp-flag regexp-search-ring search-ring)) 
t))))))
+              (minibuffer-with-setup-hook
+                  (lambda ()
+                    (setq-local text-property-default-nonsticky
+                                (cons '(separator . t) 
text-property-default-nonsticky)))
+                (if regexp-flag
+                    (read-regexp prompt nil 'query-replace-from-to-history)
+                  (read-from-minibuffer
+                   prompt nil nil nil 'query-replace-from-to-history
+                   (car (if regexp-flag regexp-search-ring search-ring)) t)))))
            (to))
       (if (and (zerop (length from)) query-replace-defaults)
          (cons (caar query-replace-defaults)





reply via email to

[Prev in Thread] Current Thread [Next in Thread]