Function: shell-get-old-input
shell-get-old-input is a byte-compiled function defined in
shell.el.gz.
Signature
(shell-get-old-input)
Documentation
Default for comint-get-old-input in shell-mode.
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).
If comint-use-prompt-regexp is non-nil, then return
the current line, with any initial string matching the regexp
comint-prompt-regexp removed.
In either case, if shell-get-old-input-include-continuation-lines
is non-nil and the current line ends with a backslash, the next
line is also included and examined for a backslash, ending with a
final line without a backslash.
Probably introduced at or before Emacs version 30.1.
Source Code
;; Defined in /usr/src/emacs/lisp/shell.el.gz
(defun shell-get-old-input ()
"Default for `comint-get-old-input' in `shell-mode'.
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).
If `comint-use-prompt-regexp' is non-nil, then return
the current line, with any initial string matching the regexp
`comint-prompt-regexp' removed.
In either case, if `shell-get-old-input-include-continuation-lines'
is non-nil and the current line ends with a backslash, the next
line is also included and examined for a backslash, ending with a
final line without a backslash."
(let (field-prop bof)
(if (and (not comint-use-prompt-regexp)
;; Make sure we're in an input rather than output field.
(not (setq field-prop (get-char-property
(setq bof (field-beginning)) 'field))))
(field-string-no-properties bof)
(comint-bol)
(let ((start (point)))
(cond ((or comint-use-prompt-regexp
(eq field-prop 'output))
(goto-char (line-end-position))
(when shell-get-old-input-include-continuation-lines
;; 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))))))