From: Juri Linkov Date: Wed, 27 Jan 2021 18:08:43 +0000 (+0200) Subject: Support multi-line prompt and contents in previous-line-or-history-element. X-Git-Tag: emacs-28.0.90~4091 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=85f8b575001ec8c3503d7e8746862e49c0c7a3bf;p=emacs.git Support multi-line prompt and contents in previous-line-or-history-element. * lisp/simple.el (previous-line-or-history-element): Move to the beginning of minibuffer contents if there is editable minibuffer contents on the same line after moving point to the prompt (bug#46033). Fix minimal old-column from 0 to 1 to put point at the beginning of minibuffer contents after going to the previous history element. --- diff --git a/lisp/simple.el b/lisp/simple.el index c878fdab921..e82b138b0da 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -2472,14 +2472,24 @@ previous element of the minibuffer history in the minibuffer." (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.