Subject: Re: bug#74287: [PATCH] Rework history Isearch for Eshell

From: James Thomas <[email-masked]>
Date: Mon, 11 Nov 2024 05:10:06 +0530

Pengji Zhang wrote:

> Hello,
>
> This patch brings a comint-like interface for history Isearch to Eshell.
> To try it, type 'M-r' in Eshell, and search through the input history
> ring incrementally.
>
> Compared to the existing implementation, this patch integrates with
> Isearch properly, like what we do for the minibuffer and comint modes.
>
> There are relevant discussions (thank you all for the feedback!) in the
> mailing list:
>
>     https://lists.gnu.org/archive/html/emacs-devel/2024-11/msg00069.html
>
> For Jim's concern, I do not think this implementation closes the door
> for a history completion interface, as shown by Sean and Juri.

Just wanna add a POC to the alternatives suggested. WDYT? Does not use
regexps for now, and C-. and C-, for cycling (rather than C-r and C-s):

(setq icomplete-in-buffer t)
(icomplete-mode 1)

(defun my/eshell-history-complete nil
  (interactive)
  (let ((icomplete-compute-delay 0)
	(completion-at-point-functions
	 '((lambda nil
	     `(,eshell-last-output-end ,(point) ,(append (cddr eshell-history-ring) nil) . nil)))))
    (completion-at-point)))

(define-key eshell-hist-mode-map (kbd "M-r") #'my/eshell-history-complete)

--