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

How can I append actions to a command #470

Closed
DamienCassou opened this issue Apr 8, 2016 · 4 comments
Closed

How can I append actions to a command #470

DamienCassou opened this issue Apr 8, 2016 · 4 comments

Comments

@DamienCassou
Copy link
Contributor

I would like, from my init.el, to add an action to counsel-find-file. Currently, ivy only proposes to set actions, which replaces the existing actions I want to keep.

@abo-abo
Copy link
Owner

abo-abo commented Apr 8, 2016

Like this:

(ivy-set-actions
 'counsel-find-file
 (append
  '(("t" (lambda (x) (message "test: %S" x)) "test"))
  (plist-get ivy--actions-list 'counsel-find-file)))

But I prefer to keep everything in one place. Must easier to experiment.

@DamienCassou
Copy link
Contributor Author

I should I have been more explicit sorry: I meant "is it possible for ivy to provide a new function that would ease adding new actions to a command?". If I understand your last sentence properly, does it mean you don't expect users to add actions to existing commands such as swiper or counsel-find-file?

@abo-abo
Copy link
Owner

abo-abo commented Apr 8, 2016

you don't expect users to add actions to existing commands such as swiper or counsel-find-file

I do, but the idea is for the user to first copy the default ivy-set-actions for a particular command from counsel.el and then customize it. This way, if you mess them up (I do it often when e.g. testing code for issues) you can reset all of them to your preferred state with a single key in a single place.

But if you really want to PR with ivy-add-actions, I don't mind. Just don't forget to delete-dups.

@abo-abo abo-abo closed this as completed in 778c615 May 3, 2016
@abo-abo
Copy link
Owner

abo-abo commented May 3, 2016

I've added the new function. But it's a real pain to use, at least for me. The major problem is that if you add a bad action, there's no easy way to remove it. So I'd need to have this code around in *scratch*, so that I can reset if I mess up:

(ivy-set-actions t nil)
(ivy-add-actions t '(("f" (lambda (x) (message "foobar")) "foobar")))

One advantage of ivy-set-actions is that it automatically resets when I mess up.

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

No branches or pull requests

2 participants