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

From: Noam Postavsky <[email-masked]>
Date: Fri, 11 May 2018 07:11:49 -0400

Dima Kogan <[email-masked]> 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:

>From 8f1c83af6b69c0d6007b4afe68f2d61eb1bb98f2 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <[email-masked]>
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