]>
code.delx.au - gnu-emacs-elpa/commit
Add :columns option for hydra body
* hydra.el (hydra-key-doc-function): New defvar.
(hydra-key-doc-function-default): New defun.
(hydra--hint): Add a new branch for the case :columns is specified; when
there are no columns, move the final dot here from `hydra--format'.
(hydra--format): Move final dot.
* hydra-test.el (hydra-format-1):
(hydra-format-2):
(hydra-format-with-sexp-1):
(hydra-format-with-sexp-2): Move final dot.
(hydra-columns-1): Add test.
See the code in `hydra-columns-1' test for a new approach to defining
hydras with 2D docstrings. Compared to doing it by-hand, the new method
is more flexible in one place (heads and head hints can be updated
easily) and less flexible in other (the method of joining head hints is
fixed), but very simple and short.
Example:
(defhydra hydra-info (:color blue
:columns 3)
"Info-mode"
("?" Info-summary "summary")
("]" Info-forward-node "forward")
("[" Info-backward-node "backward")
("<" Info-top-node "top node")
(">" Info-final-node "final node")
("h" Info-help "help")
("d" Info-directory "info dir")
("f" Info-follow-reference "follow ref")
("g" Info-goto-node "goto node")
("l" Info-history-back "hist back")
("r" Info-history-forward "hist forward")
("i" Info-index "index")
("I" Info-virtual-index "virtual index")
("L" Info-history "hist")
("n" Info-next "next")
("p" Info-prev "previous")
("s" Info-search "search")
("S" Info-search-case-sensitively "case-search")
("T" Info-toc "TOC")
("u" Info-up "up")
("m" Info-menu "menu"))
Similar one done by-hand:
(defhydra hydra-info (:color blue :hint nil)
"
Info-mode:
[_?_] summary [_[_] forward [_g_] goto node
[_<_] top node [_]_] backward [_s_] search
[_>_] final node [_f_] follow ref [_S_] case-search
[_d_] info dir [_l_] hist back [_m_] menu
[_i_] index [_r_] hist forward [_h_] help
[_I_] virtual index [_n_] next
[_L_] hist [_p_] previous
[_T_] TOC [_u_] up
"
("?" Info-summary)
("]" Info-forward-node)
("[" Info-backward-node)
("<" Info-top-node)
(">" Info-final-node)
("h" Info-help)
("d" Info-directory)
("f" Info-follow-reference)
("g" Info-goto-node)
("l" Info-history-back)
("r" Info-history-forward)
("i" Info-index)
("I" Info-virtual-index)
("L" Info-history)
("n" Info-next)
("p" Info-prev)
("s" Info-search)
("S" Info-search-case-sensitively)
("T" Info-toc)
("u" Info-up)
("m" Info-menu))
Fixes #140