reddit / emacs

Defer loading of corfu with use-package?

zoliky · 2022-08-14 12:23
Hello, the use-package documentation says that when any of the following keywords are used: `:commands, :bind, :bind*, :bind-keymap, :bind-keymap*, :mode, :interpreter, or :hook` the packages get deferred automatically. I have `corfu` and `cape` and none of them contain any of those keywords: (use-package corfu :init (global-corfu-mode) :custom (corfu-auto t) (corfu-cycle t) (corfu-auto-prefix 1) (corfu-auto-delay 0.1) (corfu-quit-no-match 'separator) (corfu-excluded-modes '(org-mode mu4e-compose-mode))) (use-package cape :init (add-to-list 'completion-at-point-functions #'cape-dabbrev) (add-to-list 'completion-at-point-functions #'cape-file)) I don't think `corfu` is something I need right when Emacs starts up so I think it is safe to defer both `corfu` and `cape` manually with `:defer t` right?
TrepidTurtle · 2022-08-14 13:33
Yes. But why not try it and find out? If something breaks then you’ll know you shouldn’t.
zoliky · 2022-08-14 13:34
Thank you.
MonsieurPi · 2022-08-14 13:44
I may be wrong but if you put corfu-global-mode as an :init parameter it will load immediately, no? Try to put it as a :config parameter
igorepst · 2022-08-14 15:25
It won't load then at all, because there is nothing to trigger it, like hook or binding
SasukeUchiha231 · 2022-08-14 17:20
Them maybe something like :hook (after-init . corfu-global-mode) should work.
pathemata · 2022-08-14 19:44
I use `:defer 1` for my corfu config.
tangonov · 2022-08-15 04:11
When are you expecting to use Corfu? If you're not going to load it during, or after init automatically, you will need to tell it when to load. Corfu already comes with autoloads for a few functions, such as the `corfu-mode` minor mode (see corfu.el) ;;;###autoload (define-minor-mode corfu-mode "Completion Overlay Region FUnction." ;; lots of code ) Avoid calling (global-corfu-mode) if you don't want it autoloaded the minute you execute that function. The reset of use package doesn't really matter in this context. Use-package uses keywords to create auto-loads where they don't already exist to protect your init from slowing down. Many modern packages already have autoloads.