Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ivy.el: hydra-style action prompt #469

Closed
wants to merge 2 commits into from
Closed

ivy.el: hydra-style action prompt #469

wants to merge 2 commits into from

Conversation

@ericdanan
Copy link
Contributor

@ericdanan ericdanan commented Apr 7, 2016

In case you find it useful (it is useful to me for ivy-read commands with many actions).

There is really just one commit, I probably did something wrong to end up with two identical ones. Let me know if you need me to make changes.

  • Add a custom variable ivy-action-display-style to optionally toggle
    the use of a hydra-style docstring as hint in the ivy-read-action
    minibuffer prompt.
  • Add a variable ivy--action-hints-lists and a command
    ivy-set-action-hint to customize this string globally or
    per command. This gives some flexibility to arrange the layout of the
    action prompt, which can be useful especially for commands with a large
    number of actions.
  • Add a function ivy-hydra--make-action-hint which is called by
    ivy-read-action to build the docstring when ivy-action-display-style
    is set to 'hydra. This function is defined in ivy-hydra.el since it
    depends on the hydra package, and is autoloaded in ivy.el.
ericdanan added 2 commits Apr 7, 2016
Add a custom variable `ivy-action-display-style' to optionally toggle
the use of a hydra-style docstring as hint in the `ivy-read-action'
minibuffer prompt.

Add a variable `ivy--action-hints-lists' and a command
`ivy-set-action-hint' to customize this string globally or
per command. This gives some flexibility to arrange the layout of the
action prompt, which can be useful especially for commands with a large
number of actions.

Add a function `ivy-hydra--make-action-hint' which is called by
`ivy-read-action' to build the docstring when `ivy-action-display-style'
is set to 'hydra. This function is defined in ivy-hydra.el since it
depends on the hydra package, and is autoloaded in ivy.el.
abo-abo added a commit that referenced this pull request Apr 8, 2016
Re #469
@abo-abo
Copy link
Owner

@abo-abo abo-abo commented Apr 8, 2016

Looks to me like a whole lot of complexity to customize a face. Or am I missing something?

@ericdanan
Copy link
Contributor Author

@ericdanan ericdanan commented Apr 8, 2016

Sorry, I think I was not clear. My purpose is not to change the font of the action key, it is be able to structure the layout of the actinos. For instance I have a counsel-projectile function with lots of actions (see #471) and I can then spread them on several columns, add column headers and so on.

But you may be right that it is too complex for a small benefit.

For the record, another possibility (this is what I first did) is to have a full-blown that not only generates the hint but also runs ivy-done or ivy-call, ie completely replaces ivy-dispatching-call and ivy-dispatching-done (we can have s single hydra replacing both). I think this also makes it possible to select actions with multiple letters, but I didn't use it because I don't have commands with that many actions. Then I tried to simplify things a bit by only using the hydra docstring, but it might still be too heavy.

@abo-abo
Copy link
Owner

@abo-abo abo-abo commented Apr 8, 2016

but it might still be too heavy.

I can just make this into a lambda:

(concat (if (eq this-command 'ivy-read-action)
                               "Select action: "
                             ivy--current)
                           "\n"
                           (mapconcat
                            (lambda (x)
                              (format "%s: %s"
                                      (propertize
                                       (car x)
                                       'face 'ivy-action)
                                      (nth 2 x)))
                            (cdr actions)
                            "\n")
                           "\n")

And let the user override it. Would that work for you?

@ericdanan
Copy link
Contributor Author

@ericdanan ericdanan commented Apr 8, 2016

Yes that would of course work for me by overriding the lambda. Thanks a lot.

@abo-abo abo-abo closed this in 3dcb07d Apr 8, 2016
@abo-abo
Copy link
Owner

@abo-abo abo-abo commented Apr 8, 2016

Have a look, hope it works for you.

@ericdanan
Copy link
Contributor Author

@ericdanan ericdanan commented Apr 8, 2016

Yes it works perfectly, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants