0

I am writing my own Emacs config coming from doom-emacs and Spacemacs. One thing I really miss is the ability to split windows using split-window-below and split-window-right using S-w s s and S-w s v. I am trying to add this to my config and saw that doom-emacs use hydra for this, however, how they do it is like this:

(defhydra +hydra/window-nav (:hint nil)
  ...
  ("s" split-window-below)
  ("v" split-window-right)
  ...)

Can see the source implementation here. I do not understand how it is connected. I tried to just copy their implementation like this:

(defhydra +hydra/window-nav (:hint nil)
  ("s" split-window-below)
  ("v" split-window-right))

But it is not working and did not expect that it would work, since we never bind space for example.. Anyone who could help me?

2 Answers 2

0

To understand hydra you should start at the original source page.

For a complete example of window management including your two keys see its wiki entry

You are missing the docstring - ie the menu displayed to the user.

As for binding space - I suspect that is done by Doom's macros which extent the original hydra's ones. In the example quit is done by the head ("q" nil)

I prefer to have the macro for a key binding generate the prompt in most cases so I use pretty hydra

-1

Doom and Spacemacs use those keybindings 'directly', no hydra involved. The pop-up window showing the keybindings is provided by the package which-key.

Although you can define all those keybindings directly, I would advise you to start with using either the general.el or the bind-map package.

You can find a minimal example for how to setup a Spacemacs like setup from scratch, using bind-map, here. You can download the README.org file, visit it in Emacs and then do M-x org-babel-tangle to create the init.el file.

B.t.w. in Emacs conventions S-w means Shift+w, but I guess that you mean SPC w.

3

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.