consult-dir
consult-dir copied to clipboard
How to integrate `consult-dir` (or `find-file`) with `consult-buffer`
This is what I would like to achieve:
- From
consult-buffer
invokeconsult-dir
- Select directory
- Select file
- Open file directly, don't drop back to
consult-buffer
.
So basically I want consult-dir
not to return to the original completion system but perform its normal action.
Maybe this can be achieved by default. It doesn't make much sense to insert the full path into consult-buffer
interface. WDYT?
BTW, if I invoke find-file
from inside the consult-buffer
I do get the file opened but the consult-buffer interface stays open, which is not ideal either.
If you use Embark, the cleanest way to do this is to add consult-dir
to embark-file+buffer-map
and switch to consult-dir
from consult-buffer
using embark-become
.
Besides the Embark approach I'm not sure of how to do this. consult-buffer
and consult-dir
are fundamentally different, incommensurate commands.
This is a small quick hack that works for me:
(defvar rh-consult-dir--source-recentf
`(:name "Directory"
:narrow ?d
:category file
:face consult-file
:history file-name-history
:action ,#'dired
:state ,#'consult--file-preview
:enabled ,(lambda () recentf-mode)
:items ,#'consult-dir--recentf-dirs)
"Recentf directory source for `consult-buffer-sources'.")
(add-to-list 'consult-buffer-sources 'rh-consult-dir--source-recentf t)