reddit / emacs

Why doesn’t persp-mode load on initialization?

vfsoraki · 2022-10-07 19:50
I have this piece in my `init.el` ``` (use-package persp-mode :ensure t :custom (persp-mode-prefix-key (kbd "C-c w" )) :bind ("C-x C-b" . persp-list-buffers) :config (persp-mode) (setq persp-autokill-buffer-on-remove 'kill-weak) (add-hook 'window-setup-hook #'(lambda () (persp-mode 1)))) ``` For some reason, persp-mode isn’t loaded on initialization. What’s more interesting is it doesn’t load if I run `persp-mode` after Emacs is loaded, I have to execute `persp-mode` _two_ times for it to work properly. Working properly for me means that `C-c w` prefix works. Any idea what I’m doing wrong? — UPDATE Fixed, thanks to the commenters. I checked `persp-mode` [document](https://github.com/Bad-ptr/persp-mode.el#keys) again and it seems the prefix variable is now called `persp-keymap-prefix` :facepalm: Anyway, I also used what people mentioned below and this is my final config that works. ``` (use-package persp-mode :ensure t :custom (persp-keymap-prefix (kbd "C-c w")) (persp-autokill-buffer-on-remove 'kill-weak) :bind ("C-x C-b" . persp-list-buffers) :demand t :config (persp-mode +1)) ```
lebensterben · 2022-10-07 20:09
:config is evaluated after the package is loaded...
vfsoraki · 2022-10-07 22:56
So? I'm calling \`(persp-mode)\` there so it should be ok? Sorry if it's a noob question.
lebensterben · 2022-10-07 23:11
move (persp-mode) to :init or better, write (persp-mode +1)
tmting · 2022-10-08 02:47
I might be wrong, but I believe that the :bind keyword automatically lazy loads the package. Try adding `:demand t`, as per [the docs](https://jwiegley.github.io/use-package/keywords/), so that it's loaded guaranteed.
vfsoraki · 2022-10-08 09:39
It wasn’t needed it seems. See my update in the post.
vfsoraki · 2022-10-08 09:40
Thanks for the info! It seems it was indeed needed to add `:demand t` too. I’ve updated the post with the final version that works for me.