fix(vertico): ensure recentf-mode for consult-buffer

`consult-buffer` uses `recentf` to populate file candidates. It is not
uncommon to use `consult-buffer` as a single entry point to buffers,
bookmarks and recent files, effectively replacing `recentf` and
`consult-recent-file`.

To improve startup performance, Doom enables `recentf-mode` after the
first file is opened (0e851ace9b). When executing `consult-buffer` at
startup, `recentf-mode` won’t be enabled yet. Add it to the
`consult-recent-file` advice to ensure that can’t happen.

Unlike `consult-recent-file`, `consult-buffer` does have significant
functionality without `recentf-mode`, but for the tiny fraction of Doom
users that disable `recentf-mode`, this is easy enough to
`advice-remove`.

Fix: https://github.com/doomemacs/doomemacs/issues/7461
This commit is contained in:
Liam Hupfer 2023-09-26 20:58:38 -05:00 committed by Henrik Lissner
parent 8eebab4f97
commit 2497d58e9a

View file

@ -136,9 +136,10 @@ orderless."
[remap yank-pop] #'consult-yank-pop
[remap persp-switch-to-buffer] #'+vertico/switch-workspace-buffer)
:config
(defadvice! +vertico--consult-recent-file-a (&rest _args)
"`consult-recent-file' needs to have `recentf-mode' on to work correctly"
:before #'consult-recent-file
(defadvice! +vertico--consult-recentf-a (&rest _args)
"`consult-recent-file' needs to have `recentf-mode' on to work correctly.
`consult-buffer' needs `recentf-mode' to show file candidates."
:before (list #'consult-recent-file #'consult-buffer)
(recentf-mode +1))
(setq consult-project-root-function #'doom-project-root