JeanK
JeanK

Reputation: 1775

How to create a layer keybinding to execute a shell command in Spacemacs

I want to add a keybinding in dotspacemacs/user-config, to execute and external "elm-format" command, in the elm-layer, with some parameters:

elm-format --yes current-file.elm

I couldn't find how to do it, what I found on how to define keybindings is:

(define-key elm-mode-map (kbd "f") 'elm-format)

So I'm not sure about somethings here:

  1. How do I know which keymap should I be adding a keybinding to? It wasn't clear by just reading the elm layer code [1]
  2. Reading the elm layer code, the way they define what the keybinding should is with a single quote prefix " 'elm-package-refresh ", but that's not a command at all so I guess it's referencing something external? How should I put a command there?

Let me know if you need any further clarifications.

[1] https://github.com/syl20bnr/spacemacs/tree/master/layers/%2Blang/elm

Upvotes: 1

Views: 688

Answers (1)

Amos
Amos

Reputation: 3276

How do I know which keymap should I be adding a keybinding to?

If you use emacs 25 or later, you can use SPC h k d to describe elm related keys in elm-mode and the keymap information is contained along with the key description.

How should I put a command there?

You can always write a command wrapper for this kind of stuff.

Upvotes: 0

Related Questions