GNU bug report logs - #21737
24.5; Minor feature request: `comint-previous-matching-input-from-input' and point

Previous Next

Package: emacs;

Reported by: Eli Barzilay <eli <at> barzilay.org>

Date: Thu, 22 Oct 2015 20:30:05 UTC

Severity: wishlist

Found in version 24.5

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

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 21737 in the body.
You can then email your comments to 21737 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#21737; Package emacs. (Thu, 22 Oct 2015 20:30:05 GMT) Full text and rfc822 format available.

Acknowledgement sent to Eli Barzilay <eli <at> barzilay.org>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 22 Oct 2015 20:30:06 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Eli Barzilay <eli <at> barzilay.org>
To: bug-gnu-emacs <at> gnu.org
Cc: Chong Yidong <cyd <at> gnu.org>, Le Wang <l26wang <at> gmail.com>
Subject: 24.5;
 Minor feature request: `comint-previous-matching-input-from-input'
 and point
Date: Thu, 22 Oct 2015 16:29:15 -0400
`comint-previous-matching-input-from-input' used to insert a match and
leave the point at the end of the line.  I found that behavior much
better than zsh and bash since when recalling old commands I edit the
last part of the command much more often.  (In fact, I think that
comint used to leave the point where it was years ago, since I
remember having to tweak emacs to put it at the end.)

A few years ago, there was a bug & a patch reported by Le Wang about
keeping the point at the same place -- something that I find really
annoying...  The problem with this patch is that it has no option to
leave the point at the end, forcing me to duplicate the whole function
if I want that behavior.

So, this is a feature request to add such an option with a new custom
variable.

-- 
                    ((x=>x(x))(x=>x(x)))                   Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#21737; Package emacs. (Thu, 22 Oct 2015 20:43:01 GMT) Full text and rfc822 format available.

Message #8 received at 21737 <at> debbugs.gnu.org (full text, mbox):

From: Eli Barzilay <eli <at> barzilay.org>
To: 21737 <at> debbugs.gnu.org
Subject: Re: bug#21737: Acknowledgement (24.5; Minor feature request:
 `comint-previous-matching-input-from-input' and point)
Date: Thu, 22 Oct 2015 16:42:30 -0400
On Thu, Oct 22, 2015 at 4:30 PM, GNU bug Tracking System
<help-debbugs <at> gnu.org> wrote:
> If you wish to submit further information on this problem, please
> send it to 21737 <at> debbugs.gnu.org.

I forgot to also note that this bit from the mentioned bug report:

| The point should not be moved so that I can press M-p again to find
| the next match.

is wrong: `comint-previous-matching-input-from-input' already had that
functionality using `comint-matching-input-from-input-string' to keep
the same search string on consequent searches regardless of the point
position.

(I tend to think that because of this the default behavior should be
kept as it was, but in practice I'm guessing that most people expect the
zsh/bash thing.)

-- 
                    ((x=>x(x))(x=>x(x)))                   Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#21737; Package emacs. (Fri, 23 Oct 2015 06:27:02 GMT) Full text and rfc822 format available.

Message #11 received at 21737 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Eli Barzilay <eli <at> barzilay.org>
Cc: cyd <at> gnu.org, l26wang <at> gmail.com, 21737 <at> debbugs.gnu.org
Subject: Re: bug#21737: 24.5; Minor feature request:
 `comint-previous-matching-input-from-input'	and point
Date: Fri, 23 Oct 2015 09:26:04 +0300
> From: Eli Barzilay <eli <at> barzilay.org>
> Date: Thu, 22 Oct 2015 16:29:15 -0400
> Cc: Chong Yidong <cyd <at> gnu.org>, Le Wang <l26wang <at> gmail.com>
> 
> `comint-previous-matching-input-from-input' used to insert a match and
> leave the point at the end of the line.  I found that behavior much
> better than zsh and bash since when recalling old commands I edit the
> last part of the command much more often.  (In fact, I think that
> comint used to leave the point where it was years ago, since I
> remember having to tweak emacs to put it at the end.)
> 
> A few years ago, there was a bug & a patch reported by Le Wang about
> keeping the point at the same place -- something that I find really
> annoying...  The problem with this patch is that it has no option to
> leave the point at the end, forcing me to duplicate the whole function
> if I want that behavior.
> 
> So, this is a feature request to add such an option with a new custom
> variable.

Thanks.  Would you like to prepare a patch along these lines?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#21737; Package emacs. (Fri, 13 Nov 2015 22:43:02 GMT) Full text and rfc822 format available.

Message #14 received at 21737 <at> debbugs.gnu.org (full text, mbox):

From: Stephen Perry <stevoooo <at> gmail.com>
To: 21737 <at> debbugs.gnu.org
Subject: Re: bug#21737: Acknowledgement (24.5;
 Minor feature request: `comint-previous-matching-input-from-input'
 and point)
Date: Fri, 13 Nov 2015 22:30:45 +0000
How about this for a patch?  It’s my first so be kind :-)

diff --git a/lisp/comint.el b/lisp/comint.el
index e70fe88..8d61226 100644
--- a/lisp/comint.el
+++ b/lisp/comint.el
@@ -283,6 +283,14 @@ comint-move-point-for-output
 		 (const others))
   :group 'comint)
 
+(defcustom comint-move-point-to-end-on-match nil
+  "Controls whether point moves to the end of the matched input.
+If nil, then point remains in the current position.
+If t, point moves to the end of matched input."
+  :type '(choice (const :tag "off" nil)
+                 (const t))
+  :group 'comint)
+
 (defvaralias 'comint-scroll-to-bottom-on-output 'comint-move-point-for-output)
 
 (defcustom comint-scroll-show-maximum-output t
@@ -1220,7 +1228,8 @@ comint-previous-matching-input-from-input
     (comint-previous-matching-input
      (concat "^" (regexp-quote comint-matching-input-from-input-string))
      n)
-    (goto-char opoint)))
+    (unless comint-move-point-to-end-on-match
+      (goto-char opoint))))
 
 (defun comint-next-matching-input-from-input (n)
   "Search forwards through input history for match for current input.







Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#21737; Package emacs. (Mon, 16 Nov 2015 16:51:01 GMT) Full text and rfc822 format available.

Message #17 received at 21737 <at> debbugs.gnu.org (full text, mbox):

From: "John Wiegley" <jwiegley <at> gmail.com>
To: Stephen Perry <stevoooo <at> gmail.com>
Cc: 21737 <at> debbugs.gnu.org
Subject: Re: bug#21737: Acknowledgement (24.5;
 Minor feature request: `comint-previous-matching-input-from-input'
 and point)
Date: Mon, 16 Nov 2015 08:50:11 -0800
>>>>> Stephen Perry <stevoooo <at> gmail.com> writes:

> How about this for a patch?  It’s my first so be kind :-)

Hi Stephen,

I think that using ":type 'boolean" is better than specifiying a custom
version.

Otherwise, it looks good to me.

John




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#21737; Package emacs. (Mon, 16 Nov 2015 18:56:01 GMT) Full text and rfc822 format available.

Message #20 received at 21737 <at> debbugs.gnu.org (full text, mbox):

From: Stephen Perry <stevoooo <at> gmail.com>
To: John Wiegley <jwiegley <at> gmail.com>
Cc: 21737 <at> debbugs.gnu.org
Subject: Re: bug#21737: Acknowledgement (24.5;
 Minor feature request: `comint-previous-matching-input-from-input'
 and point)
Date: Mon, 16 Nov 2015 18:55:13 +0000
Updated patch:

diff --git a/lisp/comint.el b/lisp/comint.el
index e70fe88..b7a906e 100644
--- a/lisp/comint.el
+++ b/lisp/comint.el
@@ -283,6 +283,13 @@ comint-move-point-for-output
 		 (const others))
   :group 'comint)
 
+(defcustom comint-move-point-to-end-on-match nil
+  "Controls whether point moves to the end of the matched input.
+If nil, then point remains in the current position.
+If t, point moves to the end of matched input."
+  :type 'boolean
+  :group 'comint)
+
 (defvaralias 'comint-scroll-to-bottom-on-output 'comint-move-point-for-output)
 
 (defcustom comint-scroll-show-maximum-output t
@@ -1220,7 +1227,8 @@ comint-previous-matching-input-from-input
     (comint-previous-matching-input
      (concat "^" (regexp-quote comint-matching-input-from-input-string))
      n)
-    (goto-char opoint)))
+    (unless comint-move-point-to-end-on-match
+      (goto-char opoint))))
 
 (defun comint-next-matching-input-from-input (n)
   "Search forwards through input history for match for current input.






Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#21737; Package emacs. (Tue, 17 Nov 2015 01:17:02 GMT) Full text and rfc822 format available.

Message #23 received at 21737 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Stephen Perry <stevoooo <at> gmail.com>
Cc: John Wiegley <jwiegley <at> gmail.com>, 21737 <at> debbugs.gnu.org
Subject: Re: bug#21737: Acknowledgement (24.5;
 Minor feature request: `comint-previous-matching-input-from-input'
 and point)
Date: Tue, 17 Nov 2015 02:58:48 +0200
> +(defcustom comint-move-point-to-end-on-match nil
> +  "Controls whether point moves to the end of the matched input.
> +If nil, then point remains in the current position.
> +If t, point moves to the end of matched input."
> +  :type 'boolean
> +  :group 'comint)
> +
>  (defvaralias 'comint-scroll-to-bottom-on-output 'comint-move-point-for-output)
>
>  (defcustom comint-scroll-show-maximum-output t
> @@ -1220,7 +1227,8 @@ comint-previous-matching-input-from-input
>      (comint-previous-matching-input
>       (concat "^" (regexp-quote comint-matching-input-from-input-string))
>       n)
> -    (goto-char opoint)))
> +    (unless comint-move-point-to-end-on-match
> +      (goto-char opoint))))

I wonder could we use the logic of 'track-eol' here?  This means that going
to the previous command lines starting at the end of the command line will
keep to the ends of command lines.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#21737; Package emacs. (Tue, 17 Nov 2015 13:09:02 GMT) Full text and rfc822 format available.

Message #26 received at 21737 <at> debbugs.gnu.org (full text, mbox):

From: Stephen Perry <stevoooo <at> gmail.com>
To: Juri Linkov <juri <at> linkov.net>
Cc: John Wiegley <jwiegley <at> gmail.com>, 21737 <at> debbugs.gnu.org
Subject: Re: bug#21737: Acknowledgement (24.5;
 Minor feature request: `comint-previous-matching-input-from-input'
 and point)
Date: Tue, 17 Nov 2015 13:08:29 +0000
> On 17 Nov 2015, at 00:58, Juri Linkov <juri <at> linkov.net> wrote:
> 
>> +(defcustom comint-move-point-to-end-on-match nil
>> +  "Controls whether point moves to the end of the matched input.
>> +If nil, then point remains in the current position.
>> +If t, point moves to the end of matched input."
>> +  :type 'boolean
>> +  :group 'comint)
>> +
>> (defvaralias 'comint-scroll-to-bottom-on-output 'comint-move-point-for-output)
>> 
>> (defcustom comint-scroll-show-maximum-output t
>> @@ -1220,7 +1227,8 @@ comint-previous-matching-input-from-input
>>     (comint-previous-matching-input
>>      (concat "^" (regexp-quote comint-matching-input-from-input-string))
>>      n)
>> -    (goto-char opoint)))
>> +    (unless comint-move-point-to-end-on-match
>> +      (goto-char opoint))))
> 
> I wonder could we use the logic of 'track-eol' here?  This means that going
> to the previous command lines starting at the end of the command line will
> keep to the ends of command lines.

It’s a trivial change to make, but I’m not sure if having it do
the same thing will be annoying for people who don’t want
track-eol turned on everywhere?





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#21737; Package emacs. (Thu, 19 Nov 2015 01:08:02 GMT) Full text and rfc822 format available.

Message #29 received at 21737 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Stephen Perry <stevoooo <at> gmail.com>
Cc: John Wiegley <jwiegley <at> gmail.com>, 21737 <at> debbugs.gnu.org
Subject: Re: bug#21737: Acknowledgement (24.5;
 Minor feature request: `comint-previous-matching-input-from-input'
 and point)
Date: Thu, 19 Nov 2015 02:33:32 +0200
>> I wonder could we use the logic of 'track-eol' here?  This means that going
>> to the previous command lines starting at the end of the command line will
>> keep to the ends of command lines.
>
> It’s a trivial change to make, but I’m not sure if having it do
> the same thing will be annoying for people who don’t want
> track-eol turned on everywhere?

We have it working this way in navigating the minibuffer's history,
so users are already accustomed to this behavior.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#21737; Package emacs. (Thu, 17 Sep 2020 17:43:01 GMT) Full text and rfc822 format available.

Message #32 received at 21737 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Stephen Perry <stevoooo <at> gmail.com>
Cc: John Wiegley <jwiegley <at> gmail.com>, 21737 <at> debbugs.gnu.org
Subject: Re: bug#21737: Acknowledgement (24.5; Minor feature request:
 `comint-previous-matching-input-from-input' and point)
Date: Thu, 17 Sep 2020 19:42:22 +0200
Stephen Perry <stevoooo <at> gmail.com> writes:

> +(defcustom comint-move-point-to-end-on-match nil
> +  "Controls whether point moves to the end of the matched input.
> +If nil, then point remains in the current position.
> +If t, point moves to the end of matched input."
> +  :type 'boolean
> +  :group 'comint)

It seems like this was fixed by a somewhat similar patch the year
after, so I'm closing this bug report:


commit afe2997119a5e6b108851f2e236037da1d4acef2
Author:     Philipp Stephani <phst <at> google.com>
AuthorDate: Thu Oct 27 00:28:34 2016 +0200

    Comint: new user option for C-c M-r and C-c M-s
    
    This option allows the user to specify where to place point after these
    commands.
    
    * comint.el (comint-move-point-for-matching-input): New user option.
    (comint-previous-matching-input-from-input): Use user option.


-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




bug closed, send any further explanations to 21737 <at> debbugs.gnu.org and Eli Barzilay <eli <at> barzilay.org> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Thu, 17 Sep 2020 17:43:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 16 Oct 2020 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 3 years and 185 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.