Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to integrate consult-dir (or find-file) with consult-buffer #24

Open
vspinu opened this issue Dec 18, 2022 · 3 comments
Open

How to integrate consult-dir (or find-file) with consult-buffer #24

vspinu opened this issue Dec 18, 2022 · 3 comments

Comments

@vspinu
Copy link

vspinu commented Dec 18, 2022

This is what I would like to achieve:

  1. From consult-buffer invoke consult-dir
  2. Select directory
  3. Select file
  4. 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?

@vspinu
Copy link
Author

vspinu commented Dec 18, 2022

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.

@karthink
Copy link
Owner

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.

@ramblehead
Copy link

ramblehead commented Mar 14, 2024

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants