Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Swiper from isearch #89
I'd like to share this snippet borrowed from
Sometimes I am searching for something using the regular
This snippet helps.. I bind it to
(defun swiper--from-isearch () "Invoke `swiper' from isearch. https://github.com/ShingoFukuyama/helm-swoop/blob/f67fa8a4fe3b968b7105f8264a96da61c948a6fd/helm-swoop.el#L657-668 " (interactive) (let (($query (if isearch-regexp isearch-string (regexp-quote isearch-string)))) (isearch-exit) (swiper $query)))
Actually, what could be an excellent idea would be to made an
@abo-abo is there any variable where that match keeps stored? then I think that I could make that happen in my config.
Well, as I told, I made my function to achieve that as following:
(defun joe-swiper () (interactive) (swiper) (add-to-list 'regexp-search-ring ivy-text))
Works fine, you make a
added a commit
Feb 9, 2016
to Evil users:
I also find the following makes Swiper much more natural to use:
(defun my-swiper-update-search-ring (&rest args) (add-to-list 'regexp-search-ring (ivy--regex ivy-text))) (advice-add 'ivy-next-line :after #'my-swiper-update-search-ring) (advice-add 'ivy-previous-line :after #'my-swiper-update-search-ring)
This updates the search ring when you hit C-n or C-p. For some reason I often C-g from a search to get back to where I was, and then after a while I use Evil search motions to quickly cycle through the matches of the previous search. Without these advices it doesn't work.
@lionel- If you press C-g,
Also, cycling matches after a search -
Hmm I'd rather not update the ring when I just cancel a search without moving through it.
By the way, this is not
In addition C-n and C-p should update the direction of the search, so here are updated advices for this use case:
(defun my-swiper-update-search-ring-forward (&rest args) (add-to-history 'regexp-search-ring (ivy--regex ivy-text)) (setq isearch-forward t)) (defun my-swiper-update-search-ring-backward (&rest args) (add-to-history 'regexp-search-ring (ivy--regex ivy-text)) (setq isearch-forward nil)) (advice-add 'ivy-next-line :after #'my-swiper-update-search-ring-forward) (advice-add 'ivy-previous-line :after #'my-swiper-update-search-ring-backward)