GNU bug report logs - #25028
26.0.50; comint-get-old-input-default: behavior follows docstring

Previous Next

Package: emacs;

Reported by: Dima Kogan <dima <at> secretsauce.net>

Date: Fri, 25 Nov 2016 21:23:02 UTC

Severity: minor

Tags: fixed, patch

Found in versions 26.0.50, 24.5

Fixed in version 26.2

Done: Noam Postavsky <npostavs <at> gmail.com>

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 25028 in the body.
You can then email your comments to 25028 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#25028; Package emacs. (Fri, 25 Nov 2016 21:23:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Dima Kogan <dima <at> secretsauce.net>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 25 Nov 2016 21:23:02 GMT) Full text and rfc822 format available.

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

From: Dima Kogan <dima <at> secretsauce.net>
To: bug-gnu-emacs <at> gnu.org
Subject: 26.0.50; comint-get-old-input-default: behavior follows docstring
Date: Fri, 25 Nov 2016 13:22:05 -0800
[Message part 1 (text/plain, inline)]
Here's a simple patch to tweak the behavior of
(comint-get-old-input-default) to do what the docstring says it should
do. Example:

1. emacs -Q
2. M-x shell
3. seq 5 [RET]
   This produces the output

   1
   2
   3
   4
   5

4. Move point to "3"
5. (comint-get-old-input-default)

According to the docstring, this should return the current line; i.e.
"3". Instead it returns "3\n4\n5\n" + the next prompt. This behavior can
produce lots of unwanted commands executing accidentally, and it goes
against what the docstring says.

[0001-comint-get-old-input-default-behavior-follows-docstr.patch (text/x-diff, inline)]
From 8af07631226f0dafc90c7d481085c2d08b37a710 Mon Sep 17 00:00:00 2001
From: Dima Kogan <dima <at> secretsauce.net>
Date: Fri, 25 Nov 2016 13:15:12 -0800
Subject: [PATCH] comint-get-old-input-default: behavior follows docstring

lisp/comint.el (comint-get-old-input-default): Modify behavior to follow
docstring: if `comint-use-prompt-regexp' is nil, then return the CURRENT LINE,
if point is on an output field.
---
 lisp/comint.el | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/lisp/comint.el b/lisp/comint.el
index b9c65b0..0288157 100644
--- a/lisp/comint.el
+++ b/lisp/comint.el
@@ -2239,10 +2239,7 @@ comint-get-old-input-default
              (null (get-char-property (setq bof (field-beginning)) 'field)))
 	(field-string-no-properties bof)
       (comint-bol)
-      (buffer-substring-no-properties (point)
-				      (if comint-use-prompt-regexp
-					  (line-end-position)
-					(field-end))))))
+      (buffer-substring-no-properties (point) (line-end-position)))))
 
 (defun comint-copy-old-input ()
   "Insert after prompt old input at point as new input to be edited.
-- 
2.8.0.rc3


Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#25028; Package emacs. (Fri, 11 May 2018 11:12:02 GMT) Full text and rfc822 format available.

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

From: Noam Postavsky <npostavs <at> gmail.com>
To: Dima Kogan <dima <at> secretsauce.net>
Cc: 25028 <at> debbugs.gnu.org
Subject: Re: bug#25028: 26.0.50;
 comint-get-old-input-default: behavior follows docstring
Date: Fri, 11 May 2018 07:11:49 -0400
[Message part 1 (text/plain, inline)]
Dima Kogan <dima <at> secretsauce.net> writes:

> lisp/comint.el (comint-get-old-input-default): Modify behavior to follow
> docstring: if `comint-use-prompt-regexp' is nil, then return the CURRENT LINE,
> if point is on an output field.

That patch returns current line when point is on an output field even if
comint-use-prompt-regexp is non-nil.  I think it should rather go like
this:

[0001-Fix-comint-get-old-input-default-for-output-field-ca.patch (text/x-diff, inline)]
From 8f1c83af6b69c0d6007b4afe68f2d61eb1bb98f2 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs <at> gmail.com>
Date: Fri, 11 May 2018 07:05:53 -0400
Subject: [PATCH] Fix comint-get-old-input-default for output field case
 (Bug#25028)

* lisp/comint.el (comint-get-old-input-default): Don't return whole
field when point was on an output field.
---
 lisp/comint.el | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/lisp/comint.el b/lisp/comint.el
index e81f739849..5c1918ffad 100644
--- a/lisp/comint.el
+++ b/lisp/comint.el
@@ -2262,16 +2262,18 @@ comint-get-old-input-default
 If `comint-use-prompt-regexp' is non-nil, then return
 the current line with any initial string matching the regexp
 `comint-prompt-regexp' removed."
-  (let (bof)
+  (let (field-prop bof)
     (if (and (not comint-use-prompt-regexp)
              ;; Make sure we're in an input rather than output field.
-             (null (get-char-property (setq bof (field-beginning)) 'field)))
+             (not (setq field-prop (get-char-property
+                                    (setq bof (field-beginning)) 'field))))
 	(field-string-no-properties bof)
       (comint-bol)
-      (buffer-substring-no-properties (point)
-				      (if comint-use-prompt-regexp
-					  (line-end-position)
-					(field-end))))))
+      (buffer-substring-no-properties
+       (point)
+       (if (or comint-use-prompt-regexp (eq field-prop 'output))
+           (line-end-position)
+         (field-end))))))
 
 (defun comint-copy-old-input ()
   "Insert after prompt old input at point as new input to be edited.
-- 
2.11.0


Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#25028; Package emacs. (Tue, 05 Jun 2018 00:39:03 GMT) Full text and rfc822 format available.

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

From: Noam Postavsky <npostavs <at> gmail.com>
To: Dima Kogan <dima <at> secretsauce.net>
Cc: 25028 <at> debbugs.gnu.org
Subject: Re: bug#25028: 26.0.50;
 comint-get-old-input-default: behavior follows docstring
Date: Mon, 04 Jun 2018 20:38:25 -0400
# it was a regression in 24.5
found 25028 24.5
tags 25028 fixed
close 25028 26.2
quit

Noam Postavsky <npostavs <at> gmail.com> writes:

> Subject: [PATCH] Fix comint-get-old-input-default for output field case
>  (Bug#25028)
>
> * lisp/comint.el (comint-get-old-input-default): Don't return whole
> field when point was on an output field.

Pushed to emacs-26.

[1: 55c9bb9f3c]: 2018-06-04 19:42:22 -0400
  Fix comint-get-old-input-default for output field case (Bug#25028)
  https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=55c9bb9f3c2971e347caeea1402f97fb603c4210




bug Marked as found in versions 24.5. Request was from Noam Postavsky <npostavs <at> gmail.com> to control <at> debbugs.gnu.org. (Tue, 05 Jun 2018 00:39:03 GMT) Full text and rfc822 format available.

Added tag(s) fixed. Request was from Noam Postavsky <npostavs <at> gmail.com> to control <at> debbugs.gnu.org. (Tue, 05 Jun 2018 00:39:03 GMT) Full text and rfc822 format available.

bug marked as fixed in version 26.2, send any further explanations to 25028 <at> debbugs.gnu.org and Dima Kogan <dima <at> secretsauce.net> Request was from Noam Postavsky <npostavs <at> gmail.com> to control <at> debbugs.gnu.org. (Tue, 05 Jun 2018 00:39:03 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. (Tue, 03 Jul 2018 11:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 6 years and 349 days ago.

Previous Next


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