diff --git a/lisp/comint.el b/lisp/comint.el index c5589324a14..89c35149022 100644 --- a/lisp/comint.el +++ b/lisp/comint.el @@ -2377,7 +2377,7 @@ comint-get-old-input-default "Default for `comint-get-old-input'. If `comint-use-prompt-regexp' is nil, then either return the current input field, if point is on an input field, or the -current line, if point is on an output field. +current line, with continuation lines, if point is on an output field. If `comint-use-prompt-regexp' is non-nil, then return the current line with any initial string matching the regexp `comint-prompt-regexp' removed." @@ -2388,11 +2388,18 @@ comint-get-old-input-default (setq bof (field-beginning)) 'field)))) (field-string-no-properties bof) (comint-bol) - (buffer-substring-no-properties (point) - (if (or comint-use-prompt-regexp - (eq field-prop 'output)) - (line-end-position) - (field-end)))))) + (let ((start (point))) + (cond ((or comint-use-prompt-regexp + (eq field-prop 'output)) + (goto-char (line-end-position)) + ;; Include continuation lines as long as the current + ;; line ends with a backslash. + (while (and (not (eobp)) + (= (char-before) ?\\)) + (goto-char (line-end-position 2)))) + (t + (goto-char (field-end)))) + (buffer-substring-no-properties start (point)))))) (defun comint-copy-old-input () "Insert after prompt old input at point as new input to be edited.