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 ()
      (use-package persp-mode
       (setq persp-keymap-prefix (kbd "C-c o"))
       (setq persp-nil-name "Home")
       (persp-mode 1))

      (use-package projectile
       :diminish projectile-mode
       (setq projectile-keymap-prefix (kbd "C-c C-p"))

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
    (setq projectile-keymap-prefix (kbd "C-c C-p"))
| improve this answer | |
  • 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 Mar 18 '16 at 14:50
  • You can take a look at my own setup configuration. I use use-package a lot (50'ish packages, including helm and projectile) and recently got it to start under 1 second. – Mathieu Marques Mar 18 '16 at 14:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.