2

I am currently using emacs out of prelude and with helm-projectile enabled in my setup.

Recently I added helm-ls-git to my stack too and noticed that the function helm-browse-project is more interesting for me than the one I've been using previously helm-projectile-find-file (from helm-projectile) bound to C-c p f.

Under my config/personal.el I've added the following line and thought it should do the trick:

(global-set-key (kbd "C-c p f") 'helm-browse-project)

This is not working, but if I switch to another unused key binding such as C-c p 0 for instance, it works perfectly fine.

So, why can't I override it and what should I do in order to make that happen?

roomworoof
  • 394
  • 2
  • 9
Rigotti
  • 153
  • 6

3 Answers3

1

If you(or prelude maker) set it up as explained on the projectile(wrapped by helm-projectile) home(github.com), you'll bind the internal projectile-command-map to this minor-mode's projectile-mode-map with the prefix key C-c p in your Emacs config like this:

(define-key projectile-mode-map (kbd "C-c p") 'projectile-command-map)

In this case the target map to change for your own binding is neither global-map you first tried nor projectile-mode-map just for defining the prefix key to call the command map, but the command map itself is what should be changed and the following code will do the trick:

;; overwrite the command map for the key "f" (after the prefix key "C-c p")
(define-key projectile-command-map (kbd "f") 'helm-browse-project)
roomworoof
  • 394
  • 2
  • 9
0

Load order matters. The latest global-set-key overrides the former ones. Make sure yours is evaluated after the one you want to override.

Damien Cassou
  • 877
  • 4
  • 14
0

There are several different keymaps active for any Emacs buffer: the major-mode, any minor-modes, a buffer-local keymap, and the global keymap. The global keymap has the lowest priority - if a keybinding is defined in any of the other active keymaps, that's the binding that will be applied when you hit those keys.

In your case, C-c p f is bound in the keymap for a minor or major mode, so binding that key in the global keymap doesn't do anything useful. You can see a list of all the active keybindings for a buffer with the C-h b. Scroll through that to find the keymap where that sequence is bound. That's the one you need to modify, not the global keymap.

Tyler
  • 21,719
  • 1
  • 52
  • 92