hydra icon indicating copy to clipboard operation
hydra copied to clipboard

Groups of bindings in a column

Open ambihelical opened this issue 7 years ago • 3 comments

When creating a hydra for a mode with a lot of bindings, it is sometimes necessary to put two more different kinds of bindings in the same column so that the number of columns doesn't get out of hand. For reference, see the hydra in #269.

Currently, as far as I can tell, a column has one heading at the top, and that is it. It would be great if there was a way to have multiple headings in a column. In this way any physical column can have a heading for each group of bindings in the column. Lacking this, just the ability to add a horizontal line between bindings in a column would be useful.

I know I could draw this out with ascii-art like many hydras do, but I like the automatic formatting that the :column feature provides.

ambihelical avatar Nov 20 '17 05:11 ambihelical

Please provide an example: source code and the docstring that you expect to be produced.

abo-abo avatar Nov 20 '17 12:11 abo-abo

(defhydra example-hydra (:hint nil)
   "Example"
  ("a" fn-a "Do a" :column "Column 1" )   ;; ex: as before
  ("b" fn-b "Do b")
  ("c" fn-c "Do c" :heading "C stuff")  ;; ex grouping
  ("d" "fn-d" "Do d" :column "Column 2")
  ("e" "fn-e" "Do e" :heading "E stuff")
  ("f" "fn-f"  "Do f" :heading nil)       ;; ex:just a line
  ("g" "fn-g" "Do g"))

Column 1   | Column 2
-----------|--------------
   a: Do a |    d: Do d
   b: Do b | E stuff       
C Stuff    |--------------
-----------|    e: Do e
   c: Do c |--------------
           |    g: Do g

In a perfect world, I could just define groupings aka headings and hydra would figure out the number of columns to fit the window, but that sounds like a big change.

ambihelical avatar Nov 20 '17 20:11 ambihelical

I also like something better than my hack, which is separating headings by an empty head, ("" nil ""). This will display only a colon, optionally also a description. For example:

(defhydra example-hydra (:hint nil)
   "Example"
  ("a" foo "foo" :column "Column heading")
  ("b" bar "bar")
  ("" nil)
  ("" nil "subhead 1")
  ("c" baz " baz))

results in a hydra like:

Example
head 1          | head 2
----------------|------------
a: foo          | d: blah
b: bar          |
  :             |
  : subhead 1   |
c: baz          |

E3D3 avatar Sep 17 '24 22:09 E3D3