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-resume
and ivy-next-line
to achieve this, but it didn't work — it always resumed with the originally selected item still pre-selected.
Original Post:
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.)
Notes:
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.
Software versions
- swiper 20200220.1026
- ivy 20200220.1043
- Emacs 26.3
- MacOS 10.15.3