GNU bug report logs -
#19824
25.0.50; Support goal column in multi-line minibuffer
Previous Next
Reported by: Juri Linkov <juri <at> linkov.net>
Date: Tue, 10 Feb 2015 00:50:01 UTC
Severity: normal
Tags: patch
Found in version 25.0.50
Done: Juri Linkov <juri <at> linkov.net>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 19824 in the body.
You can then email your comments to 19824 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#19824
; Package
emacs
.
(Tue, 10 Feb 2015 00:50:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Juri Linkov <juri <at> linkov.net>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Tue, 10 Feb 2015 00:50:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
Tags: patch
In the single-line minibuffer the goal column was handled by using the point's
absolute position that is the same as the column on the single line.
However, this doesn't work on the multi-line minibuffer. This patch adds
support for the goal column on multi-line input in the minibuffer:
diff --git a/lisp/simple.el b/lisp/simple.el
index 25293ed..58b4870 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -1990,7 +1990,14 @@ (defun next-line-or-history-element (&optional arg)
next element of the minibuffer history in the minibuffer."
(interactive "^p")
(or arg (setq arg 1))
- (let ((old-point (point)))
+ (let* ((old-point (point))
+ ;; Remember the original goal column of possibly multi-line input
+ ;; excluding the length of the prompt on the first line.
+ (prompt-end (minibuffer-prompt-end))
+ (old-column (unless (and (eolp) (> (point) prompt-end))
+ (if (= (line-number-at-pos) 1)
+ (max (- (current-column) (1- prompt-end)) 0)
+ (current-column)))))
(condition-case nil
(with-no-warnings
(next-line arg))
@@ -1998,7 +2005,14 @@ (defun next-line-or-history-element (&optional arg)
;; Restore old position since `line-move-visual' moves point to
;; the end of the line when it fails to go to the next line.
(goto-char old-point)
- (next-history-element arg)))))
+ (next-history-element arg)
+ ;; Restore the original goal column on the last line
+ ;; of possibly multi-line input.
+ (goto-char (point-max))
+ (when old-column
+ (if (= (line-number-at-pos) 1)
+ (move-to-column (+ old-column (1- (minibuffer-prompt-end))))
+ (move-to-column old-column)))))))
(defun previous-line-or-history-element (&optional arg)
"Move cursor vertically up ARG lines, or to the previous history element.
@@ -2006,7 +2020,14 @@ (defun previous-line-or-history-element (&optional arg)
previous element of the minibuffer history in the minibuffer."
(interactive "^p")
(or arg (setq arg 1))
- (let ((old-point (point)))
+ (let* ((old-point (point))
+ ;; Remember the original goal column of possibly multi-line input
+ ;; excluding the length of the prompt on the first line.
+ (prompt-end (minibuffer-prompt-end))
+ (old-column (unless (and (eolp) (> (point) prompt-end))
+ (if (= (line-number-at-pos) 1)
+ (max (- (current-column) (1- prompt-end)) 0)
+ (current-column)))))
(condition-case nil
(with-no-warnings
(previous-line arg))
@@ -2014,7 +2035,15 @@ (defun previous-line-or-history-element (&optional arg)
;; Restore old position since `line-move-visual' moves point to
;; the beginning of the line when it fails to go to the previous line.
(goto-char old-point)
- (previous-history-element arg)))))
+ (previous-history-element arg)
+ ;; Restore the original goal column on the first line
+ ;; of possibly multi-line input.
+ (goto-char (minibuffer-prompt-end))
+ (if old-column
+ (if (= (line-number-at-pos) 1)
+ (move-to-column (+ old-column (1- (minibuffer-prompt-end))))
+ (move-to-column old-column))
+ (goto-char (line-end-position)))))))
(defun next-complete-history-element (n)
"Get next history element which completes the minibuffer before the point.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#19824
; Package
emacs
.
(Tue, 10 Feb 2015 15:58:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 19824 <at> debbugs.gnu.org (full text, mbox):
> From: Juri Linkov <juri <at> linkov.net>
> Date: Tue, 10 Feb 2015 02:45:33 +0200
>
> In the single-line minibuffer the goal column was handled by using the point's
> absolute position that is the same as the column on the single line.
> However, this doesn't work on the multi-line minibuffer. This patch adds
> support for the goal column on multi-line input in the minibuffer:
Thanks.
> - (let ((old-point (point)))
> + (let* ((old-point (point))
> + ;; Remember the original goal column of possibly multi-line input
> + ;; excluding the length of the prompt on the first line.
> + (prompt-end (minibuffer-prompt-end))
> + (old-column (unless (and (eolp) (> (point) prompt-end))
> + (if (= (line-number-at-pos) 1)
> + (max (- (current-column) (1- prompt-end)) 0)
> + (current-column)))))
Why do you use current-column and move-to-column here, instead of
using the line-move-visual methods we use by default in any other
buffer? Is there some technical problem to use visual-line movement
in the minibuffer? If not, I think we should do that for consistency
of the user experience.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#19824
; Package
emacs
.
(Tue, 10 Feb 2015 23:44:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 19824 <at> debbugs.gnu.org (full text, mbox):
> Why do you use current-column and move-to-column here, instead of
> using the line-move-visual methods we use by default in any other
> buffer? Is there some technical problem to use visual-line movement
> in the minibuffer? If not, I think we should do that for consistency
> of the user experience.
line-move-visual is still used while moving point inside the minibuffer,
but when moving to another history element, the whole contents of the
minibuffer is erased, and new text is inserted, in which the column
should be positioned correctly.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#19824
; Package
emacs
.
(Wed, 11 Feb 2015 15:40:02 GMT)
Full text and
rfc822 format available.
Message #14 received at 19824 <at> debbugs.gnu.org (full text, mbox):
> From: Juri Linkov <juri <at> linkov.net>
> Cc: 19824 <at> debbugs.gnu.org
> Date: Wed, 11 Feb 2015 01:38:03 +0200
>
> > Why do you use current-column and move-to-column here, instead of
> > using the line-move-visual methods we use by default in any other
> > buffer? Is there some technical problem to use visual-line movement
> > in the minibuffer? If not, I think we should do that for consistency
> > of the user experience.
>
> line-move-visual is still used while moving point inside the minibuffer,
> but when moving to another history element, the whole contents of the
> minibuffer is erased, and new text is inserted, in which the column
> should be positioned correctly.
Right, sorry. So I guess now I don't understand why we try keeping
the horizontal position across history elements. Why not reset the
position to just after the prompt? There's nothing in common between
the history elements, in general.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#19824
; Package
emacs
.
(Thu, 12 Feb 2015 01:18:01 GMT)
Full text and
rfc822 format available.
Message #17 received at 19824 <at> debbugs.gnu.org (full text, mbox):
> Right, sorry. So I guess now I don't understand why we try keeping
> the horizontal position across history elements. Why not reset the
> position to just after the prompt? There's nothing in common between
> the history elements, in general.
This is for backward-compatibility with the traditional behavior
that existed from the beginning that kept the horizontal position
for single-line history elements. And it's really convenient
when the history is navigated the same way as a normal buffer
where line-move-visual keeps the column.
Reply sent
to
Juri Linkov <juri <at> linkov.net>
:
You have taken responsibility.
(Thu, 12 Mar 2015 20:28:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
Juri Linkov <juri <at> linkov.net>
:
bug acknowledged by developer.
(Thu, 12 Mar 2015 20:28:02 GMT)
Full text and
rfc822 format available.
Message #22 received at 19824-done <at> debbugs.gnu.org (full text, mbox):
Done.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Fri, 10 Apr 2015 11:24:03 GMT)
Full text and
rfc822 format available.
This bug report was last modified 10 years and 77 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.