3

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)
        "dired-open"
        ("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

1

1 Answer 1

3

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"
  :doc
  "\n[_j_/_k_] down/up [_h_/_l_] left/right [_q_] quit"
  :bindings
  ("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"
   'spacemacs/dired-open-item-other-window-transient-state/body)

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.