On Tue, Dec 12, 2017 at 3:20 PM Eric Abrahamsen <address@hidden
Hydra definitely sounds nice, but unless I'm misunderstanding how it
works, it can't be a replacement for either Org's export interface, or
Magit's popups. Both of those can set various state variables before
choosing an actual action -- Hydra can't do that, can it?
hydra can do anything you can do in elisp before/after the action.
For example, here's a hydra I use for rectangle actions:
(defhydra hydra-rectangle (:body-pre (rectangle-mark-mode 1)
^_p_^ _d_ delete _s_tring _c_/_C_ (delete/kill) and replace with space
_b_ _f_ _k_ cut _r_eset _o_pen (create blank rectangle and push text in region to the right)
^_n_^ _w_ copy e_x_change _X_ delete whitespace starting from the left edge of the rectangle
^^^^ _y_ paste _e_xtend Prefix rectangle lines with _N_umbers
("d" delete-rectangle :color blue)
("k" kill-rectangle :color blue)
("w" copy-rectangle-as-kill :color blue)
("y" yank-rectangle :color blue)
("s" string-rectangle :color blue)
("t" string-rectangle :color blue)
("r" (if (region-active-p)
("C" modi/kill-rectangle-replace-with-space :color blue)
("o" open-rectangle :color blue)
("X" delete-whitespace-rectangle :color blue)
("N" rectangle-number-lines :color blue)
("q" nil "cancel" :color blue))
But this email wasn't to propose replace the matured popups like magit and org export with hydra. The proposal is to integrate hydra into emacs, so that many packages that self-implement these popups can do the same using hydra more easily. Dired, ibuffer can make use of hydra and make all the bindings more discoverable and memorable. In future, may be hydra can be use for the org template insertion piece.
I can talk of verilog-mode as I use it everyday. In verilog-mode.el, there is this code:
(let ((map (make-sparse-keymap)))
(define-key map "a" 'verilog-sk-always)
(define-key map "b" 'verilog-sk-begin)
(define-key map "D" 'verilog-sk-define-signal)
"Keymap used in Verilog mode for smart template operations.")
In my config, I replace the same with hydra and it looks like this:
(defhydra hydra-verilog-template (:color blue
_i_nitial _?_ if _j_ fork _A_ssign _uc_ uvm-component
_b_egin _:_ else-if _m_odule _I_nput _uo_ uvm-object
_a_lways _f_or _g_enerate _O_utput
^^ _w_hile _p_rimitive _=_ inout
^^ _r_epeat _s_pecify _S_tate-machine _h_eader
^^ _c_ase _t_ask _W_ire _/_ comment
^^ case_x_ _F_unction _R_eg
^^ case_z_ ^^ _D_efine-signal
("q" nil nil :color blue)
("C-g" nil nil :color blue))
Which gives in these interface which makes the bindings much more memorable and accessible:
There are so many places like this that can get a facelift from hydra.
Did I hear that Magit was breaking its popup interface out into a
separate library? If so, that would also be a nice thing.
That would be great too. We are basically missing a configurable library to bind temporary key maps, that can make the bindings present in a discoverable way to the user. So far hydra.el fits the bill.