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

From: reporter <[email-masked]>
Date: Sat, 23 Jan 2021 17:46:18 +0000

>
> Thanks for the well justified request. This patch avoids moving point
> to the prompt on the rightful assumption that most of the time the users
> would not want to edit read-only text:

This breaks the history retrieval feature with up arrow.

With the current implementation up arrow takes you into the prompt, but if
you are in the top line of the prompt and press up arrow again then up
arrow retrieves history.

In the case I described going into the prompt is useless, so up arrow
should retrieve history immediately, without having to go to the top
line of the prompt first.

diff --git a/lisp/simple.el b/lisp/simple.el
index 0355ac863a..f5fe366f69 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -2476,7 +2476,10 @@ previous-line-or-history-element
 			 (current-column)))))
     (condition-case nil
 	(with-no-warnings
-	  (previous-line arg))
+	  (previous-line arg)
+          ;; Avoid moving point to the prompt
+          (when (< (point) (minibuffer-prompt-end))
+            (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.