major-mode-hydra.el icon indicating copy to clipboard operation
major-mode-hydra.el copied to clipboard

Customize line below heading between columns.

Open hubisan opened this issue 5 years ago • 5 comments

Thx for your package. Used to use a hackish solution before.

What I'm missing from my solutions is to be able to customize the separator between the column headings. In my case it was two spaces:

image

This somehow helps me to visually see the columns better.

Is this already possible or can this be implemented?

hubisan avatar Jul 15 '19 13:07 hubisan

No it's not possible currently but it seems nice to have. I'll have a think about it.

jerrypnz avatar Jul 15 '19 20:07 jerrypnz

Had a look at the code. Something like this should do it:

Handle :separator different if it is a list like ("-" " ") and use the cdr as the separator between columns like so:

  1. Change pretty-hydra--gen-heads-docstring https://github.com/jerrypnz/major-mode-hydra.el/blob/d9fb688dae3e134bb1ff7f35474c58f33a5bb992/pretty-hydra.el#L133 Add this to let of the function:

    (separator (or (and (listp separator) (car separator)) separator))
    

    And change the line above to this:

    (s-pad-right width separator "^^"))
    

    (Note: with the old code the separator is as it looks actually too wide. Is this on purpose?)

  2. Change pretty-hydra--gen-heads-docstring https://github.com/jerrypnz/major-mode-hydra.el/blob/d9fb688dae3e134bb1ff7f35474c58f33a5bb992/pretty-hydra.el#L153 Add this to let of the function:

    (separator (or (and (listp separator) (cadr separator)) separator))
    (col-separator (s-pad-right (length separator) " " ""))
    

    And change that line to:

    (s-join (if (= i 1) separator col-separator)
    

Like this one can even use a separator longer than one character :separator ("─" " │ "):

image

What you think? I can make a pull request. Would this also affect the tests?

hubisan avatar Aug 21 '19 15:08 hubisan

Oh I thought you'd want the column separator to appear on every row, not just the separator row. If this is really what you want, your proposed solution sounds good to me (otherwise I'd probably introduce a separate property :col-separator).

A PR is definitely welcome!

jerrypnz avatar Aug 21 '19 20:08 jerrypnz

had time to work on this: https://github.com/hubisan/major-mode-hydra.el/tree/feature/col-separator

:col-separator a string or a list of two strings used to separate the columns. If it is a list, the second string is used as column separator at the separator line. If the strings in the list are of unequal length the shorter string is centered by adding spaces.

So this accepts " │ " or '(" │ " "───"). If a list the effect is the following, using '("x│x" "=X="):

image

Added a .travis.yml for automated testing against emacs 25 and 26. Test in 25 unfortunately fail, caadr and caaddr (used in pretty-hydra--normalize-args) were introduced in emacs 26. Can you change this on develop? Will rebase, add some tests for the :col-separator and make the pull request.

hubisan avatar Sep 08 '19 11:09 hubisan

@hubisan That's awesome! Looking forward to your PR.

jerrypnz avatar Sep 08 '19 20:09 jerrypnz