diff --git a/lisp/comint.el b/lisp/comint.el index b4fbfc8..22fbe06 100644 --- a/lisp/comint.el +++ b/lisp/comint.el @@ -1448,17 +1448,18 @@ comint-history-isearch-message-overlay (defun comint-history-isearch-setup () "Set up a comint for using Isearch to search the input history. Intended to be added to `isearch-mode-hook' in `comint-mode'." - (when (and (get-buffer-process (current-buffer)) + (when (and + ;; Prompt is not empty like in Async Shell Command buffers + ;; or in inactive shells + (not (eq (save-excursion + (goto-char (comint-line-beginning-position)) + (forward-line 0) + (point)) + (comint-line-beginning-position))) (or (eq comint-history-isearch t) (and (eq comint-history-isearch 'dwim) ;; Point is at command line. - (comint-after-pmark-p) - ;; Prompt is not empty like in Async Shell Command buffers - (not (eq (save-excursion - (goto-char (comint-line-beginning-position)) - (forward-line 0) - (point)) - (comint-line-beginning-position)))))) + (comint-after-pmark-p)))) (setq isearch-message-prefix-add "history ") (setq-local isearch-search-fun-function #'comint-history-isearch-search) @@ -2288,8 +2289,10 @@ comint-skip-prompt (defun comint-after-pmark-p () "Return t if point is after the process output marker." - (let ((pmark (process-mark (get-buffer-process (current-buffer))))) - (<= (marker-position pmark) (point)))) + (let ((process (get-buffer-process (current-buffer)))) + (when process + (let ((pmark (process-mark process))) + (<= (marker-position pmark) (point)))))) (defun comint-simple-send (proc string) "Default function for sending to PROC input STRING.