0

I'm trying to put together a config of my own after having used Spacemacs for a few years. To customize keybindings, and make them a bit Spacemacs-like, I'm trying out general.el. So far it seems to work rather well, except for one thing where the integration with which-key isn't quite as I'd hoped. On the other hand, I might just be doing it wrong.

In order to get multi-key bindings, like SPC E y to visit my yasnippet files, I've first created a "definer" with SPC as the leader key

(general-create-definer mes/leader-def
  :keymaps '(normal insert visual emacs)
  :prefix "SPC"
  :non-normal-prefix "M-SPC")

using that I then define the next level, E in this case

(mes/leader-def
  :infix "E"
  "" '(:ignore t :wk "Emacs")
  "y" '(:keymap mes-yasnippet-map :wk "yasnippet"))

The definition of 'mes-yasnippet-map looks like this (I did a bit of reading on keybindings/keymaps and this seems to be a reasonable way of doing it)

(define-prefix-command 'mes-yasnippet-map)
(general-def :keymaps 'mes-yasnippet-map
  "v" '(yas-visit-snippet-file :wk "visit snippet"))

When pressing SPC I'll first see "E -> Emacs", then pressing E I'll see "y -> yasnippet", then pressing y I expected to see "v -> visit snippet" but instead I see "v -> yas-visit-snippet-file".

First of all, is this a good way of defining Spacemacs-like keybindings using general.el, or is there a better way?

Second, if this is a good way, how do I get which-key to show what I want on all levels?

4
  • I'm too busy to write a formal answer in the following two weeks, you can refer to my configuration, general.el and which-key work very well together. Commented Feb 25, 2023 at 14:08
  • Please don't ask "Is this a good way...?" or "Is there a better way...?" - encourages opinion-based answers. And please don't pose multiple questions in the same post - one per post, please. Thx.
    – Drew
    Commented Feb 25, 2023 at 16:45
  • Thanks Tianshu Wang, your config looks like a very good resource indeed.
    – Magnus
    Commented Feb 26, 2023 at 18:41
  • Drew, thanks for reminding me why I stopped asking questions on exchanges.
    – Magnus
    Commented Feb 26, 2023 at 18:42

1 Answer 1

0

Tianshu Wang's setup pointed out something that I didn't think of myself. I don't need to create a separate keymap for the binding with multiple keys. So what I ended up with was this a single definition of my keybindings

(mes/leader-def
 :infix "E"
 "" '(:ignore t :wk "Emacs")
 "y" '(:ignore t :wk "yasnippet))
 "yv" '(yas-visit-snippet-file :wk "visit-snippet"))

I've since also adopted more of the setup I found in Tianshu's setup, in particular the tyrant-def and despot-def. Doing that actually solved some other issues I had in setting up my keybindings with general.el.

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.