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

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

bug#46033: up arrow in query replace should not step into the prompt


From: Juri Linkov
Subject: bug#46033: up arrow in query replace should not step into the prompt
Date: Wed, 27 Jan 2021 20:10:14 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu)

>>> This is exactly what the patch does. Have you really tried it?
>>
>> Yes, I don't know what happened (I applied it manually), but I
>> must have made an error, because it didn't work.
>>
>> Then I checked the original code and I came up with the same
>> solution you did.
>>
>> So, yes, it does work. Thanks, and sorry for the confusion.
>
> Thanks for confirming, now this is fixed.

Actually, this is not so simple.  Currently this doesn't work with
multi-line minibuffer.  When there is non-prompt text on the previous line,
it should move point to the editable portion of that line.  So I pushed
this patch that supports not only multi-line minibuffer contents,
but also multi-line prompts.

diff --git a/lisp/simple.el b/lisp/simple.el
index c878fdab92..680bfd7f43 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -2472,14 +2472,24 @@ previous-line-or-history-element
                                   (save-excursion
                                     (goto-char (1- prompt-end))
                                     (current-column)))
-                               0)
+                               1)
                         (current-column)))))
     (condition-case nil
        (with-no-warnings
          (previous-line arg)
           ;; Avoid moving point to the prompt
           (when (< (point) (minibuffer-prompt-end))
-            (signal 'beginning-of-buffer nil)))
+            ;; If there is minibuffer contents on the same line
+            (if (<= (minibuffer-prompt-end)
+                    (save-excursion
+                      (if (or truncate-lines (not line-move-visual))
+                          (end-of-line)
+                        (end-of-visual-line))
+                      (point)))
+                ;; Move to the beginning of minibuffer contents
+                (goto-char (minibuffer-prompt-end))
+              ;; Otherwise, go to the previous history element
+              (signal 'beginning-of-buffer nil))))
       (beginning-of-buffer
        ;; Restore old position since `line-move-visual' moves point to
        ;; the beginning of the line when it fails to go to the previous line.

reply via email to

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