Subject: bug#25028: 26.0.50; comint-get-old-input-default: behavior follows docstring

From: Dima Kogan <[email-masked]>
Date: Fri, 25 Nov 2016 13:22:05 -0800

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.

>From 8af07631226f0dafc90c7d481085c2d08b37a710 Mon Sep 17 00:00:00 2001
From: Dima Kogan <[email-masked]>
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