after setting projectile-keymap-prefix, that prefix now launches projectile commands and the default prefix no longer does.
setting projectile-keymap-prefix has no effect whatsoever.
set projectile-keymap-prefix, either with setq as described in the README, or via customize. Currently I have the following like in my init.el, produced by customize
'(projectile-keymap-prefix (kbd "M-p"))
I've also tried a couple other variants - (kbd "C-c C-p"), "M-p", "C-c C-p". None have any effect
This is what I see when I run C-h v projectile-keymap-prefix
projectile-keymap-prefix is a variable defined in `projectile.el'.
Its value is (kbd "M-p")
Original value was "p"
Documentation:
Projectile keymap prefix.
You can customize this variable.
[back]
Projectile version: 0.13.0
GNU Emacs 24.5.2 (x86_64-unknown-linux-gnu, GTK+ Version 2.24.29)
Linux, distro is NixOS
Same problem here.
For me project's README example with projectile-keymap-prefix doesn't work as well, so after numerous attempts I'm using a workaround:
(define-key projectile-mode-map (kbd "s-p") 'projectile-command-map)
And this does what projectile-keymap-prefix is supposed to do: now I can use Projectile like s-p f and s-p s g
setting projectile-keymap-prefix has no effect whatsoever.
AFAIU, you need to set this variable _before_ projectile is required/loaded in order for the change to take effect.
When projectile.el is loaded, the definition of projectile-mode-map is evaluated. It defines a single entry which uses the value of projectile-keymap-prefix to point to projectile-command-map. If you set projectile-keymap-prefix later, it won't change the existing keybinding in projectile-mode-map.
So you basically have two options if you want projectile's commands to have a different prefix key:
projectile-keymap-prefix _before_ requiring/loading projectile:elisp
(setq projectile-keymap-prefix (kbd "C-c C-p"))
(require 'projectile)
projectile-command-map as @stunpix suggested (you may also want to unbind projectile-keymap-prefix if you're going to reuse C-c p for other keybindings):elisp
(require 'projectile)
(define-key projectile-mode-map projectile-keymap-prefix nil)
(define-key projectile-mode-map (kbd "C-c C-p") #'projectile-command-map)
There was a similar issue in projectile-rails: asok/projectile-rails#34.
cc @bbatsov if my reasoning is correct, can you add a note to the docs which clears this issue?
cc @bbatsov if my reasoning is correct, can you add a note to the docs which clears this issue?
Your reasoning is correct. Doc improvement PRs are always welcome. :-)
I managed to solve my issue! Make sure projectile-mode is enabled when trying the above
~~I'm still facing problems with this even after the fix suggested above.
This is what I see when I run C-h v projectile-keymap-prefix
projectile-keymap-prefix is a variable defined in ‘projectile.el’.
Its value is "C-c C-p"
Original value was "p"
Documentation:
Projectile keymap prefix.
You can customize this variable.
Everything in my init.el related to projectile
(require 'projectile)
(define-key projectile-mode-map projectile-keymap-prefix nil)
(define-key projectile-mode-map (kbd "C-c C-p") #'projectile-command-map)
(setq projectile-switch-project-action 'venv-projectile-auto-workon)
(require 'helm-projectile)
(helm-projectile-on)
~~
Most helpful comment
AFAIU, you need to set this variable _before_ projectile is required/loaded in order for the change to take effect.
When
projectile.elis loaded, the definition ofprojectile-mode-mapis evaluated. It defines a single entry which uses the value ofprojectile-keymap-prefixto point toprojectile-command-map. If you setprojectile-keymap-prefixlater, it won't change the existing keybinding inprojectile-mode-map.So you basically have two options if you want projectile's commands to have a different prefix key:
projectile-keymap-prefix_before_ requiring/loading projectile:elisp (setq projectile-keymap-prefix (kbd "C-c C-p")) (require 'projectile)projectile-command-mapas @stunpix suggested (you may also want to unbindprojectile-keymap-prefixif you're going to reuse C-c p for other keybindings):elisp (require 'projectile) (define-key projectile-mode-map projectile-keymap-prefix nil) (define-key projectile-mode-map (kbd "C-c C-p") #'projectile-command-map)There was a similar issue in projectile-rails: asok/projectile-rails#34.
cc @bbatsov if my reasoning is correct, can you add a note to the docs which clears this issue?