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-hydra, ivy-resume and ivy-dispatching-done #2195

Closed
gusbrs opened this issue Aug 10, 2019 · 5 comments
Closed

ivy-hydra, ivy-resume and ivy-dispatching-done #2195

gusbrs opened this issue Aug 10, 2019 · 5 comments

Comments

@gusbrs
Copy link
Contributor

@gusbrs gusbrs commented Aug 10, 2019

When adding a new action to an Ivy command, and when using ivy-hydra, calling ivy-resume will set the last selected action in ivy-dispatching-done as default action.

Start with emacs -Q, and perform some basic setup:

(package-initialize)
(require 'ivy-hydra)
(ivy-mode)
(ivy-add-actions
 'ivy-switch-buffer
 '(("n"
    (lambda (x)
      (message "Oh, man!"))
    "do nothing")))
(global-set-key (kbd "C-c C-r") 'ivy-resume)

Call ivy-switch-buffer with "C-x C-b", call ivy-dispatching-done with "M-o". The hydra is then:

Selection_001

Select action "n", to "do nothing". Now call ivy-resume with "C-c C-r", and then again ivy-dispatching-done with "M-o". As shown, the new action is set as the default action, in this case. Hitting "n" works, and hitting "o" will perform "do nothing".

Selection_002

I’m not really sure this is not expected behavior. I can indeed rationalize it as ivy-resume also "resuming" the last action, similar to ivy-dispatching-call. But, the same behavior does not occur when ivy-hydra is not in use. In this case, calling "do nothing", then ivy-resume and then calling "M-o o" will switch to the selected buffer, and not "do nothing". So, this behavior might be unexpected, thus the report. If it is expected, just close this.

Note: I wrote this assuming the effect resulted from my custom action. Further testing showed me it also happens for the default actions in ivy-switch-buffer (I haven’t tested, but possibly in other ivy commands). But the replication steps are already circumscribed enough for you to isolate the described behavior, I think.

Environment: Emacs 26.2, ivy-20190809.1551, ivy-hydra-20190731.1602.

@abo-abo abo-abo closed this in e6171e2 Aug 29, 2019
@abo-abo
Copy link
Owner

@abo-abo abo-abo commented Aug 29, 2019

Thanks, please test.

@gusbrs
Copy link
Contributor Author

@gusbrs gusbrs commented Aug 29, 2019

Tested, and it's working nicely. Thank you very much.

@gusbrs
Copy link
Contributor Author

@gusbrs gusbrs commented Sep 3, 2019

@abo-abo Let me check one thing with you about this issue. I was not sure about what the expected behavior was for ivy-resume regarding the default action. (I didn't find anything explicit in the docs, but I might well have missed it). However, the resolution you gave here suggests the default action should not be restored when calling ivy-resume.

If this presumption is correct, this is working fine, as reported, for ivy-dispatching-done, with or without ivy-hydra.

However, the behavior of ivy-done ("RET") still uses a changed default action, when calling ivy-resume. So that when calling ivy-resume "RET" behaves different from "M-o o". Is this expected? If not, would you prefer I extend the report here, or open a new issue?

@abo-abo
Copy link
Owner

@abo-abo abo-abo commented Oct 13, 2019

I think it's working fine right now. One major application of ivy-resume is to fix typos, e.g. you select not the candidate you meant but the one really close. So you do C-c C-r C-n RET to fix.

The same applies when you select a wrong candidate with an action different than default. It's more ergonomic to fix it with C-c C-r C-n RET than to choose the same action again via M-o.

Finally, supposing you really want to change the action in ivy-resume, you can do it with M-o.

@gusbrs
Copy link
Contributor Author

@gusbrs gusbrs commented Oct 13, 2019

I see. It does make sense indeed. Considering this the main envisaged use case, I get including why ivy-done keeps the previous action after ivy-resume while ivy-dispatching-done does not, the latter being equivalent of the behavior of ivy-dispatching-call for which the current action reverts to the default one after it's called. Thank you for considering and answering. Cheers!

astoff added a commit to astoff/swiper that referenced this issue Jan 1, 2021
Modify the action list non-destructively, by just chaning the initial
index. This way, when `ivy-resume' is called, the action list has the
same functions.

Fixes abo-abo#2195
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 pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants