comparison lisp/comint.el @ 38971:478f11ee1d4c

(comint-get-old-input-default): Don't signal an error if point is not on an input field; instead, return the current line (using `comint-bol' to skip any prompt, in case we're not using fields at all).
author Miles Bader <miles@gnu.org>
date Mon, 27 Aug 2001 12:59:39 +0000
parents 43b2b9e04c57
children 3037adea8353
comparison
equal deleted inserted replaced
38970:e144797b4ece 38971:478f11ee1d4c
1370 The values of `comint-get-old-input', `comint-input-filter-functions', and 1370 The values of `comint-get-old-input', `comint-input-filter-functions', and
1371 `comint-input-filter' are chosen according to the command interpreter running 1371 `comint-input-filter' are chosen according to the command interpreter running
1372 in the buffer. E.g., 1372 in the buffer. E.g.,
1373 1373
1374 If the interpreter is the csh, 1374 If the interpreter is the csh,
1375 comint-get-old-input is the default: either return the current 1375 comint-get-old-input is the default:
1376 field, or take the current line and discard any 1376 If `comint-use-prompt-regexp-instead-of-fields' is nil, then
1377 initial string matching regexp `comint-prompt-regexp', depending 1377 either return the current input field, if point is on an input
1378 on the value of `comint-use-prompt-regexp-instead-of-fields'. 1378 field, or the current line, if point is on an output field.
1379 If `comint-use-prompt-regexp-instead-of-fields' is non-nil, then
1380 return the current line with any initial string matching the
1381 regexp `comint-prompt-regexp' removed.
1379 comint-input-filter-functions monitors input for \"cd\", \"pushd\", and 1382 comint-input-filter-functions monitors input for \"cd\", \"pushd\", and
1380 \"popd\" commands. When it sees one, it cd's the buffer. 1383 \"popd\" commands. When it sees one, it cd's the buffer.
1381 comint-input-filter is the default: returns t if the input isn't all white 1384 comint-input-filter is the default: returns t if the input isn't all white
1382 space. 1385 space.
1383 1386
1751 (goto-char (point-max)) 1754 (goto-char (point-max))
1752 (recenter -1)) 1755 (recenter -1))
1753 1756
1754 (defun comint-get-old-input-default () 1757 (defun comint-get-old-input-default ()
1755 "Default for `comint-get-old-input'. 1758 "Default for `comint-get-old-input'.
1756 Returns either the current field, or the current line with any initial 1759 If `comint-use-prompt-regexp-instead-of-fields' is nil, then either
1757 text matching `comint-prompt-regexp' stripped off, depending on the 1760 return the current input field, if point is on an input field, or the
1758 value of `comint-use-prompt-regexp-instead-of-fields'." 1761 current line, if point is on an output field.
1759 (if comint-use-prompt-regexp-instead-of-fields 1762 If `comint-use-prompt-regexp-instead-of-fields' is non-nil, then return
1760 (save-excursion 1763 the current line with any initial string matching the regexp
1761 (beginning-of-line) 1764 `comint-prompt-regexp' removed."
1762 (comint-skip-prompt) 1765 (let ((bof (field-beginning)))
1763 (let ((beg (point))) 1766 (if (eq (get-char-property bof 'field) 'input)
1764 (end-of-line) 1767 (field-string bof)
1765 (buffer-substring beg (point)))) 1768 (comint-bol)
1766 ;; Return the contents of the field at the current point. 1769 (buffer-substring (point) (line-end-position)))))
1767 (let ((pos (field-beginning (point))))
1768 (unless (eq (get-char-property pos 'field) 'input)
1769 (error "Not an input field"))
1770 (field-string pos))))
1771 1770
1772 (defun comint-copy-old-input () 1771 (defun comint-copy-old-input ()
1773 "Insert after prompt old input at point as new input to be edited. 1772 "Insert after prompt old input at point as new input to be edited.
1774 Calls `comint-get-old-input' to get old input." 1773 Calls `comint-get-old-input' to get old input."
1775 (interactive) 1774 (interactive)