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

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

bug#42862: 28.0.50; {previous,next}-line-or-history-element ignores line


From: Michael Welsh Duggan
Subject: bug#42862: 28.0.50; {previous,next}-line-or-history-element ignores line-move-visual
Date: Sat, 15 Aug 2020 23:16:12 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Tags: patch

Here is a patch I threw together that seems to address this.  (In
testing I found that this did not really affect
`next-line-or-history-element'.)  I marked it as a small change, since
it's only two lines if you don't consider whitespace and comment
re-flowing changes.

>From ca17ee22f54a89cefa26108d5f7b3fbbd431ddd1 Mon Sep 17 00:00:00 2001
From: Michael Welsh Duggan <mwd@md5i.com>
Date: Sat, 15 Aug 2020 23:04:14 -0400
Subject: [PATCH] Consider `visual-line-mode' when switching minibuffer history

Put the cursor at the end of the logical line when `visual-line-mode'
is nil (Bug#42862).
* lisp/simple.el (previous-line-or-history-element): Point movement
behavior depends on `visual-line-mode'.

Copyright-paperwork-exempt: yes
---
 lisp/simple.el | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/lisp/simple.el b/lisp/simple.el
index 1cb93c5722..6689e73cf0 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -2410,15 +2410,21 @@ previous-line-or-history-element
                                    (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.
+
+         (if visual-line-mode
+             (progn
+               ;; 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)))))))
+               (unless (eolp) (backward-char 1)))
+           (end-of-line)))))))
 
 (defun next-complete-history-element (n)
   "Get next history element that completes the minibuffer before the point.
-- 
2.28.0

-- 
Michael Welsh Duggan
(md5i@md5i.com)

reply via email to

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