consult-dir
consult-dir copied to clipboard
Add eshell source
Hi Karthik,
I tried to improve my eshell experience a little bit yesterday. What about including the eshell directory source from your post by default?
(defvar eshell-last-dir-ring)
(declare-function ring-elements "ring")
(defvar consult-dir--source-eshell
(list :name "Eshell"
:narrow ?e
:category 'file
:face 'consult-file
:enabled
(lambda ()
(and (bound-and-true-p eshell-last-dir-ring)
(not (ring-empty-p eshell-last-dir-ring))))
:items
(lambda ()
(delete-dups
(mapcar #'abbreviate-file-name
(ring-elements eshell-last-dir-ring))))))
Furthermore if the buffer is an eshell buffer, the selected directory could be passed directly to cd? Or do you think it is better to use consult-dir-default-command
in that case, set buffer-locally in the eshell?
(setq-local consult-dir-default-command
(lambda ()
(interactive)
(insert "cd " (eshell-escape-arg default-directory))
(eshell-send-input)))
I just saw that @oantolin already proposed this a while ago on reddit: https://www.reddit.com/r/emacs/comments/q4as4c/jumping_directories_in_eshell/
@minad Sorry for the delay. This would be useful to folks who use both Eshell and consult-dir, which includes you, me and @oantolin. But I'm guessing most consult-dir users don't use Eshell, since both packages are quite niche. Do you think it makes sense to add an eshell-specific feature to consult-dir from a composability perspective?
You may be right that eshell is a little niche, but you can editorialize: encourage your users to use it by providing the source. I think any package that comes with Emacs is fair game for that. (Although, some really are too obscure: I have commands to add or remove email addresses from ecomplete's adressbook, but I wouldn't add them to Embark because ecomplete is practically unknown.)
A good compromise is too add the source to consult-dir but not have it on by default, consider that option too. Also, does shell
also track directories? Maybe the source can be expanded to include directories from both, which makes it useful for more people.