Function: term-previous-matching-input
term-previous-matching-input is an interactive and byte-compiled
function defined in term.el.gz.
Signature
(term-previous-matching-input REGEXP N)
Documentation
Search backwards through input history for match for REGEXP.
(Previous history elements are earlier commands.)
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/term.el.gz
(defun term-previous-matching-input (regexp n)
"Search backwards through input history for match for REGEXP.
\(Previous history elements are earlier commands.)
With prefix argument N, search for Nth previous match.
If N is negative, find the next or Nth next match."
(interactive (term-regexp-arg "Previous input matching (regexp): "))
(setq n (term-search-arg n))
(let ((pos (term-previous-matching-input-string-position regexp n)))
;; Has a match been found?
(if (null pos)
(error "Not found")
(setq term-input-ring-index pos)
(message "History item: %d" (1+ pos))
(delete-region
;; Can't use kill-region as it sets this-command
(process-mark (get-buffer-process (current-buffer))) (point))
(insert (ring-ref term-input-ring pos)))))