I use persp-mode and projectile both of which are installed using the use-package package and both want to prefix their keymaps with C-c p. The projectile readme says that you can define a custom keymap prefix with the projectile-keymap-prefix variable. (Similar is true for persp-mode.)
Whether or not I set this variable within the use-package directive or outside, the actual prefix does not change even though describe-variable shows the value as "^C^P". I still have to access projectile commands via C-c p. (The same is also true for persp-mode if i set the persp-keymap-prefix var to something other than C-c p.)
Why does the actual prefix that needs pushed never update with the custom prefix, and how do I fix this?
Here is the relevant code. For both libraries I still have to access their keymap actions via C-c p despite setting their keymap-prefix vars:
(add-hook 'after-init-hook (lambda () (progn (use-package persp-mode :config (setq persp-keymap-prefix (kbd "C-c o")) (setq persp-nil-name "Home") (persp-mode 1)) (use-package projectile :diminish projectile-mode :config (setq projectile-keymap-prefix (kbd "C-c C-p")) (projectile-global-mode)))))- Maybe related togithub.com/bbatsov/projectile/issues/1264folq– folq2024-06-21 15:23:00 +00:00CommentedJun 21, 2024 at 15:23
1 Answer1
It looks like defining the keymap var in the :init fixes it. I have a hunch (the keymaps are defined when the package is loaded), but I'd still be interested to know why this fixes it, and if this is generally how variables should be set with use-package. (FWIW, :init is run before the package is loaded and :config executes after)
(use-package projectile :diminish projectile-mode :init (setq projectile-keymap-prefix (kbd "C-c C-p")) :config (projectile-global-mode))- From what I understand,
setq*'s should live in your:config.setq*'s set values: doesn't make much sense to set package's values before it is loaded. :)Mathieu Marques– Mathieu Marques2016-03-18 14:50:56 +00:00CommentedMar 18, 2016 at 14:50 - You can take a look atmy own setup configuration. I use
use-packagea lot (50'ish packages, includinghelmandprojectile) and recently got it to start under 1 second.Mathieu Marques– Mathieu Marques2016-03-18 14:53:34 +00:00CommentedMar 18, 2016 at 14:53
Explore related questions
See similar questions with these tags.