Function: eshell-history-isearch-search

eshell-history-isearch-search is a byte-compiled function defined in em-hist.el.gz.

Signature

(eshell-history-isearch-search)

Documentation

Return search function for Isearch in input history.

Source Code

;; Defined in /usr/src/emacs/lisp/eshell/em-hist.el.gz
(defun eshell-history-isearch-search ()
  "Return search function for Isearch in input history."
  (lambda (string bound noerror)
    (let ((search-fun (isearch-search-fun-default))
          (found nil))
      ;; Avoid highlighting matches in and before the last prompt
      (when (and bound isearch-forward
                 (< (point) eshell-last-output-end))
        (goto-char eshell-last-output-end))
      (or
       ;; First search in the initial input
       (funcall search-fun string
                (if isearch-forward bound eshell-last-output-end)
                noerror)
       ;; Then search in the input history: put next/previous history
       ;; element in the command line successively, then search the
       ;; string in the command line.  Do this only when not
       ;; lazy-highlighting (`bound' is nil).
       (unless bound
         (condition-case nil
             (progn
               (while (not found)
                 (cond (isearch-forward
                        ;; Signal an error explicitly to break
                        (when (or (null eshell-history-index)
                                  (eq eshell-history-index 0))
                          (error "End of history; no next item"))
                        (eshell-next-input 1)
                        (goto-char eshell-last-output-end))
                       (t
                        ;; Signal an error explicitly to break
                        (when (eq eshell-history-index
                                  (1- (ring-length eshell-history-ring)))
                          (error "Beginning of history; no preceding item"))
                        (eshell-previous-input 1)
                        (goto-char (point-max))))
                 (setq isearch-barrier (point)
                       isearch-opoint (point))
                 ;; After putting an history element in the command
                 ;; line, search the string in them.
                 (setq found (funcall search-fun string
                                      (unless isearch-forward
                                        eshell-last-output-end)
                                      noerror)))
               (point))
           ;; Return when no next/preceding element error signaled
           (error nil)))))))