What I'm trying to do is have
swiper-isearch resume the last search with the next element selected. The definition of next is the next element from where my cursor currently is.
You can read my original post below for how I was trying to use
ivy-next-line to achieve this, but it didn't work — it always resumed with the originally selected item still pre-selected.
How can I resume ivy with the next line selected?
I want to issue a keyboard command that resumes the last ivy listing, but instead of resuming at the line it left off at, I want to resume with the next line selected. I thought this would be simple enough if I did the following:
(defun my-ivy-resume-with-next-line () "Resume the last completion and move current line down one." (interactive) (ivy-resume) (ivy-next-line)) (global-set-key (kbd "s-g") 'my-ivy-resume-with-next-line)
When I hit my keyboard command, ivy resumes right where it left off — it does not go to the next line. I'm not sure if there's some simple elisp functionality that I should know to fix this, or if
ivy-resume is doing something weird. My guess would be that maybe
ivy-next-line is being called in my main buffer and not the newly created minibuffer from
ivy-resume. (If that's the case, then this is a question of how to call that command in the context of the minibuffer.)
I have also tried various variations of the following for the message body per suggestions in the comments:
(minibuffer-with-setup-hook (:append #'ivy-next-line) (ivy-resume))
Nothing seemed to work for me in my testing. However, after hearing they were working for others, I changed which function I was using to create the initial ivy listing and it worked. So the minibuffer hook is working for me when ivy has been called using
counsel-find-file but not when using
swiper-isearch. My primary use case for this is to resume swiper and go to the next found item, so I still need help.
- swiper 20200220.1026
- ivy 20200220.1043
- Emacs 26.3
- MacOS 10.15.3
ivy-resumedoes not return until after the minibuffer completion session has ended, by which point it is too late to call
ivy-next-line, which you want called as soon as the minibuffer completion session starts. You can achieve this via
(minibuffer-with-setup-hook (:append #'ivy-next-line) (ivy-resume)).
my-ivy-resume-with-next-linewith its new definition, e.g. using
C-M-x? When facing an issue in general, please update your question with a detailed set of steps to reproduce the issue, explaining what you expect and what you actually get at each stage, and which version of Emacs you are using; otherwise it is difficult to guess what is going wrong. Thanks.