Function: eshell-previous-matching-input

eshell-previous-matching-input is an interactive and byte-compiled function defined in em-hist.el.gz.

Signature

(eshell-previous-matching-input REGEXP ARG)

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/eshell/em-hist.el.gz
(defun eshell-previous-matching-input (regexp arg)
  "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 (eshell-regexp-arg "Previous input matching (regexp): "))
  (setq arg (eshell-search-arg arg))
  (if (> eshell-last-output-end (point))
      (error "Point not located after prompt"))
  (let ((pos (eshell-previous-matching-input-string-position regexp arg)))
    ;; Has a match been found?
    (if (null pos)
	(error "Not found")
      (eshell-goto-history pos)
      (unless (or (minibuffer-window-active-p (selected-window))
                  ;; No messages for Isearch because it will show the
                  ;; same messages (and more).
                  isearch-mode)
	(message "History item: %d" (- (ring-length eshell-history-ring) pos))))))