From 4c5043c50b52e404c211c18da8cd59a2ee86253d Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Fri, 21 Aug 2020 02:21:26 +0300 Subject: [PATCH] * lisp/simple.el (previous-line-or-history-element): Handle logical lines. When 'line-move-visual' is nil, use 'end-of-line' to move point to the end of the first logical line (bug#42862) Thanks to Michael Welsh Duggan . --- lisp/simple.el | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/lisp/simple.el b/lisp/simple.el index f08015372af..b106d4b0ba7 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -2416,15 +2416,17 @@ previous element of the minibuffer history in the minibuffer." (goto-char (1- (minibuffer-prompt-end))) (current-column)))) (move-to-column old-column)) - ;; Put the cursor at the end of the visual line instead of the - ;; logical line, so the next `previous-line-or-history-element' - ;; would move to the previous history element, not to a possible upper - ;; visual line from the end of logical line in `line-move-visual' mode. - (end-of-visual-line) - ;; Since `end-of-visual-line' puts the cursor at the beginning - ;; of the next visual line, move it one char back to the end - ;; of the first visual line (bug#22544). - (unless (eolp) (backward-char 1))))))) + (if (not line-move-visual) ; Handle logical lines (bug#42862) + (end-of-line) + ;; Put the cursor at the end of the visual line instead of the + ;; logical line, so the next `previous-line-or-history-element' + ;; would move to the previous history element, not to a possible upper + ;; visual line from the end of logical line in `line-move-visual' mode. + (end-of-visual-line) + ;; Since `end-of-visual-line' puts the cursor at the beginning + ;; of the next visual line, move it one char back to the end + ;; of the first visual line (bug#22544). + (unless (eolp) (backward-char 1)))))))) (defun next-complete-history-element (n) "Get next history element that completes the minibuffer before the point. -- 2.39.2