I need a hydra with four "heads", each of should exit the hydra when its function is executed. The hydra intended to be used in dired-mode and direx:direx-mode and pop-up when O pressed. This is what I got so far:

(defhydra dired-open (dired-mode-map "O" :exit t)
        ("j" dired-find-file-other-window-below "below")
        ("k" dired-find-file-other-window-above "above")
        ("h" dired-find-file-other-windowd-left "left")
        ("l" dired-find-file-other-window-right "left”))

it kinda works, but:

  • it's a bit ugly - I would like to learn how to make "proper" hydras, like in magit

  • it works only dired mode, I don't know how to properly bind it for both modes

upd: apparently Spacemacs has builtin function for introducing transient states. I'm gonna add Spacemacs tag, since I'm using it


Oh. wow. Spacemacs's define-transient-state is really nice:

(spacemacs|define-transient-state dired-open-item-other-window
  :title "Open item in other window"
  "\n[_j_/_k_] down/up [_h_/_l_] left/right [_q_] quit"
  ("j" dired-find-file-other-window-below :exit t)
  ("k" dired-find-file-other-window-above :exit t)
  ("h" dired-find-file-other-window-left :exit t)
  ("l" dired-find-file-other-window-right :exit t)
  ("q" nil :exit t))

(evil-define-key 'normal dired-mode-map "O"
| improve this answer | |

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.