Skip to content

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

@gusbrs

Description

@gusbrs

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions