Function: comint-backward-matching-input
comint-backward-matching-input is an interactive and byte-compiled
function defined in comint.el.gz.
Signature
(comint-backward-matching-input REGEXP N)
Documentation
Search backward through buffer for input fields that match REGEXP.
If comint-use-prompt-regexp is non-nil, then input fields are identified
by lines that match comint-prompt-regexp.
With prefix argument N, search for Nth previous match. If N is negative, find the next or Nth next match.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/comint.el.gz
(defun comint-backward-matching-input (regexp n)
"Search backward through buffer for input fields that match REGEXP.
If `comint-use-prompt-regexp' is non-nil, then input fields are identified
by lines that match `comint-prompt-regexp'.
With prefix argument N, search for Nth previous match.
If N is negative, find the next or Nth next match."
(interactive (comint-regexp-arg "Backward input matching (regexp): ") comint-mode)
(if comint-use-prompt-regexp
;; Use comint-prompt-regexp
(let* ((re (concat comint-prompt-regexp ".*" regexp))
(pos (save-excursion (end-of-line (if (> n 0) 0 1))
(if (re-search-backward re nil t n)
(point)))))
(if (null pos)
(progn (message "Not found")
(ding))
(goto-char pos)
(comint-bol nil)))
;; Use input fields
(let* ((dir (if (< n 0) -1 1))
(pos
(save-excursion
(while (/= n 0)
(unless (re-search-backward regexp nil t dir)
(user-error "Not found"))
(unless (get-char-property (point) 'field)
(setq n (- n dir))))
(field-beginning))))
(goto-char pos))))