[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Comint-like history search for Eshell?
From: |
Juri Linkov |
Subject: |
Re: Comint-like history search for Eshell? |
Date: |
Mon, 04 Nov 2024 09:40:32 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/31.0.50 (x86_64-pc-linux-gnu) |
> Just some general thoughts before I do a more-thorough review: as I see it,
> there are two competing ideas for how a user might look up a prior command:
> using Isearch (as in this patch) or using completion. Both have some
> similarities, but the latter has the advantage of letting you use the
> various completion frameworks for filtering/displaying the results.
>
> I don't know if one or the other is "better" overall; I imagine which one
> a user would prefer just depends on individual preference. (That said,
> I think I'd probably use a completion-based command history if I had the
> option.)
>
> For this patch in particular, I think it would probably make sense to at
> least see about leaving the door open for a completion-based history lookup
> in Eshell. I haven't thought very hard about what that would look like yet
> though...
The standard features that correspond to these two ways are
incremental search with 'C-s' (implemented in the proposed patch)
and occur with 'M-s o' (there is no occur-like interface for Eshell
history AFAIK, it exists only for the minibuffer history, and
in shell with 'comint-dynamic-list-input-ring'). However, having
a completion UI would be nice too. For example, for shell I use:
```
(defun comint-complete-input-ring ()
"Complete the input history as far as possible.
Like `minibuffer-complete-history' but completes on the comint history items."
(interactive)
(let* ((completions
(if (and (ring-p comint-input-ring)
(not (ring-empty-p comint-input-ring)))
(ring-elements comint-input-ring)
(user-error "No history available")))
(capf (lambda ()
(list (save-excursion (move-beginning-of-line 1) (point))
(point-max)
(lambda (string pred action)
(if (eq action 'metadata)
'(metadata (display-sort-function . identity)
(cycle-sort-function . identity))
(complete-with-action action completions string
pred))))))
(completion-at-point-functions (list capf)))
(completion-at-point)))
(define-key comint-mode-map [?\C-x up] 'comint-complete-input-ring)
```
So Eshell could have both as well: incremental search and completion.