unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#25028: 26.0.50; comint-get-old-input-default: behavior follows docstring
@ 2016-11-25 21:22 Dima Kogan
  2018-05-11 11:11 ` Noam Postavsky
  0 siblings, 1 reply; 3+ messages in thread
From: Dima Kogan @ 2016-11-25 21:22 UTC (permalink / raw)
  To: 25028

[-- Attachment #1: Type: text/plain, Size: 530 bytes --]

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.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-comint-get-old-input-default-behavior-follows-docstr.patch --]
[-- Type: text/x-diff, Size: 1118 bytes --]

From 8af07631226f0dafc90c7d481085c2d08b37a710 Mon Sep 17 00:00:00 2001
From: Dima Kogan <dima@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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* bug#25028: 26.0.50; comint-get-old-input-default: behavior follows docstring
  2016-11-25 21:22 bug#25028: 26.0.50; comint-get-old-input-default: behavior follows docstring Dima Kogan
@ 2018-05-11 11:11 ` Noam Postavsky
  2018-06-05  0:38   ` Noam Postavsky
  0 siblings, 1 reply; 3+ messages in thread
From: Noam Postavsky @ 2018-05-11 11:11 UTC (permalink / raw)
  To: Dima Kogan; +Cc: 25028

[-- Attachment #1: Type: text/plain, Size: 385 bytes --]

Dima Kogan <dima@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:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch --]
[-- Type: text/x-diff, Size: 1618 bytes --]

From 8f1c83af6b69c0d6007b4afe68f2d61eb1bb98f2 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs@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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* bug#25028: 26.0.50; comint-get-old-input-default: behavior follows docstring
  2018-05-11 11:11 ` Noam Postavsky
@ 2018-06-05  0:38   ` Noam Postavsky
  0 siblings, 0 replies; 3+ messages in thread
From: Noam Postavsky @ 2018-06-05  0:38 UTC (permalink / raw)
  To: Dima Kogan; +Cc: 25028

# it was a regression in 24.5
found 25028 24.5
tags 25028 fixed
close 25028 26.2
quit

Noam Postavsky <npostavs@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





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-06-05  0:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-25 21:22 bug#25028: 26.0.50; comint-get-old-input-default: behavior follows docstring Dima Kogan
2018-05-11 11:11 ` Noam Postavsky
2018-06-05  0:38   ` Noam Postavsky

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).