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

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

bug#24580: 25.2.50; query-replace history doesn't work


From: Mark Oteiza
Subject: bug#24580: 25.2.50; query-replace history doesn't work
Date: Mon, 3 Oct 2016 20:24:51 -0400
User-agent: Mutt/1.7+23 (87911ba95dae) (2016-08-17)

On 03/10/16 at 10:16am, Eli Zaretskii wrote:
> > Date: Sun, 2 Oct 2016 21:08:43 -0400
> > From: Mark Oteiza <mvoteiza@udel.edu>
> > Cc: mbork@mbork.pl, 24580@debbugs.gnu.org
> > 
> > > > > The problem lies (at least) in query-replace-read-from, where
> > > > > query-replace-from-to is let bound, and later read-from-minibuffer
> > > > > refers to the symbol 'query-replace-from-to.  At first sight, it looks
> > > > > like it could be fixed by putting some of the setup done by these
> > > > > bindings into the minibuffer setup hook.
> > > > 
> > > > Isn't there a less intrusive change to fix this?  A significant change
> > > > like the one you propose is more risky, but if there's no safer one, I
> > > > guess we should take it.
> > > 
> > > Perhaps just adding a (defvar query-replace-from-to-history …) will be
> > > sufficient.  That read-from-minibuffer and friends' HIST argument can
> > > only be a symbol is a bit frustrating.
> > 
> > Surely there is a better way.
> 
> Isn't this exactly the minibuffer setup hook method that I wanted to
> avoid?

Yes

> Does a simple defvar you suggested before not work?

No, unless I erred somehow, which is likely, because what I tried first
(binding minibuffer-history) didn't appear to work either.  However, the
following does appear to solve the issue.

diff --git a/lisp/replace.el b/lisp/replace.el
index 4256751..4fc48d4 100644
--- a/lisp/replace.el
+++ b/lisp/replace.el
@@ -174,7 +174,7 @@ query-replace-read-from
              (propertize "\0"
                          'display query-replace-from-to-separator
                          'separator t)))
-          (query-replace-from-to-history
+          (minibuffer-history
            (append
             (when separator
               (mapcar (lambda (from-to)
@@ -186,7 +186,7 @@ query-replace-read-from
           (minibuffer-allow-text-properties t) ; separator uses text-properties
           (prompt
            (if (and query-replace-defaults separator)
-               (format "%s (default %s): " prompt (car 
query-replace-from-to-history))
+               (format "%s (default %s): " prompt (car minibuffer-history))
              (format "%s: " prompt)))
           (from
            ;; The save-excursion here is in case the user marks and copies
@@ -198,9 +198,9 @@ query-replace-read-from
                     (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-regexp prompt)
                   (read-from-minibuffer
-                   prompt nil nil nil 'query-replace-from-to-history
+                   prompt nil nil nil nil
                    (car (if regexp-flag regexp-search-ring search-ring)) t)))))
            (to))
       (if (and (zerop (length from)) query-replace-defaults)





reply via email to

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