Function: comint-history-isearch-search
comint-history-isearch-search is a byte-compiled function defined in
comint.el.gz.
Signature
(comint-history-isearch-search)
Documentation
Return the proper search function, for Isearch in input history.
Source Code
;; Defined in /usr/src/emacs/lisp/comint.el.gz
(defun comint-history-isearch-search ()
"Return the proper search function, for Isearch in input history."
(lambda (string bound noerror)
(let ((search-fun
;; Use standard functions to search within comint text
(isearch-search-fun-default))
found)
;; Avoid lazy-highlighting matches in the comint prompt and in the
;; output when searching forward. Lazy-highlight calls this lambda
;; with the bound arg, so skip the prompt and the output.
(if (and bound isearch-forward (not (comint-after-pmark-p)))
(goto-char (process-mark (get-buffer-process (current-buffer)))))
(or
;; 1. First try searching in the initial comint text
(funcall search-fun string
(if isearch-forward bound (comint-line-beginning-position))
noerror)
;; 2. If the above search fails, start putting next/prev history
;; elements in the comint successively, and search the string
;; in them. Do this only when bound is nil (i.e. not while
;; lazy-highlighting search strings in the current comint text).
(unless bound
(condition-case nil
(progn
(while (not found)
(cond (isearch-forward
;; Signal an error here explicitly, because
;; `comint-next-input' doesn't signal an error.
(when (null comint-input-ring-index)
(error "End of history; no next item"))
(comint-next-input 1)
(goto-char (comint-line-beginning-position)))
(t
;; Signal an error here explicitly, because
;; `comint-previous-input' doesn't signal an error.
(when (eq comint-input-ring-index
(1- (ring-length comint-input-ring)))
(error "Beginning of history; no preceding item"))
(comint-previous-input 1)
(goto-char (point-max))))
(setq isearch-barrier (point) isearch-opoint (point))
;; After putting the next/prev history element, search
;; the string in them again, until comint-next-input
;; or comint-previous-input raises an error at the
;; beginning/end of history.
(setq found (funcall search-fun string
(unless isearch-forward
;; For backward search, don't search
;; in the comint prompt
(comint-line-beginning-position))
noerror)))
;; Return point of the new search result
(point))
;; Return nil on the error "no next/preceding item"
(error nil)))))))