4

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)))))
1

1 Answer 1

4

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))
2
  • 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. :) Commented Mar 18, 2016 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. Commented Mar 18, 2016 at 14:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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