0

I recently switched from ivy to helm in spacemacs as my project search/management package.

In ivy, there is a keybinding for SPC p SPC that does a search for files in the project (by file name). There is a very similar method and binding for helm: helm-projectile-find-file, which is bound to SPC p f. I want to also bind this to SPC p SPC, like in ivy.

My attempt at adding the keybinding, distilled from my .spacemacs is this:

(defun dotspacemacs/user-config ()
  "add user config here"

  ; add ivy-like shortcut
  (spacemacs/set-leader-keys-for-minor-mode 'projectile-mode (kbd "p SPC") "helm-projectile-find-file"))

Unfortunately, when I attempt to invoke the keybinding, it does not exist.

Additional Context / Things I have tried.

I may be binding in the wrong minor mode. I tried it on 'helm-mode at first and that caused errors on startup. 'projectile-mode seems kind of wrong/weird, but I couldn't find a helm + projectile mode to bind on.

The key sequence in my code may be wrong. The spacemacs docs say "use a macro like kbd to determine the key sequence" so that's what I'm trying to do here. (kbd "p SPC") evaluates to ("p "). I have also tried using "p SPC" directly, with no call to kbd, with no luck.

6
  • Please ask only one question per question. Thx.
    – Drew
    Aug 31 '20 at 15:00
  • Ok, I can edit the question to remove the 2 subquestions. I added them as context for what I have tried and what might be wrong.
    – Yourpalal
    Aug 31 '20 at 15:23
  • Thanks for that. But the question is not clear. "not be achieving anything" and "not working" don't tell us what the problem or question is. To be a useful (acceptable) question here please clarify. Just what behavior do you want to achieve, what did you try, to achieve it, and what behavior did you get instead? A step-by-step recipe starting from emacs -Q is ideal, but any way you can make clear what you're asking will be better than what you have now. Thx.
    – Drew
    Aug 31 '20 at 15:44
  • Thanks for updating to clarify: the question is about a key binding that doesn't show up.
    – Drew
    Aug 31 '20 at 18:04
  • @Drew I tried again. The question has always included what I want to do and what I have tried and it still does. What I want to do is described in both the title and the body of the question. I don't understand why I would try to replicate this with emacs -Q. The behaviour I am trying to achieve ties into spacemacs, projectile, and helm, as shown in the question. Without this fairly large and complete environment, the issue would not make any sense.
    – Yourpalal
    Aug 31 '20 at 18:06
0

The provided example user-config almost works! Instead of set-leader-keys-for-minor-mode, I did this:

(defun dotspacemacs/user-config ()
  "add user config here"

  ; add ivy-like shortcut
  (spacemacs/set-leader-keys "p SPC" 'helm-projectile-find-file))

This fixes the following issues:

  1. (kbd "p SPC") was returning the wrong value.
  2. the function was being passed in as a string, instead of a quoted symbol

Finally, this binding is now active globally, not limited to a specific minor mode, like the original configuration was. This ensures it will be active at all times.

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.