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

swiper-isearch-toggle #2061

Closed
Ergus opened this issue May 13, 2019 · 5 comments
Closed

swiper-isearch-toggle #2061

Ergus opened this issue May 13, 2019 · 5 comments

Comments

@Ergus
Copy link
Contributor

@Ergus Ergus commented May 13, 2019

Hi:

I was trying to write a function to toggle between isearch and swiper-isearch. This can be added to swiper-map and to isearch-mode-map with the same binding in order to toggle between swiper and isearch.

(defun swiper-isearch-toggle ()
  "Invoke `swiper-isearch' -> isearch toggle."
  (interactive)
  (if isearch-mode
      (let ((query (if isearch-regexp
                       isearch-string
                     (regexp-quote isearch-string))))
        (isearch-exit)
        (swiper-isearch query))
    (ivy-exit-with-action
     (lambda (_)
       (isearch-mode t nil nil nil 'isearch-symbol-regexp)
       (unless (string= ivy-text "")
	 (isearch-yank-string ivy-text))))))

The only drawback I see in this implementation is that the point moves to the next candidate when toggling. But if anyone can improve this a little bit, I think it will be a good addition to swiper.

@abo-abo
Copy link
Owner

@abo-abo abo-abo commented May 13, 2019

Can you describe a use case for this? swiper-isearch aims to be an isearch replacement, if something's still missing, we can add it.

@Ergus
Copy link
Contributor Author

@Ergus Ergus commented May 13, 2019

There is nothing missing in swiper or swiper-isearch. It is the opposite. I still use isearch sometimes because sometimes I don't want to have the ivy minibuffer opening. Or I just want to see what is in my current screen, but swiper produces some scrolling or hides some candidates opening or closing ivy.

@Ergus Ergus closed this May 13, 2019
@Ergus Ergus reopened this May 13, 2019
@abo-abo abo-abo closed this in 10755b2 May 15, 2019
@abo-abo
Copy link
Owner

@abo-abo abo-abo commented May 15, 2019

Thanks. I fixed the point move issue. Please test.

@Ergus
Copy link
Contributor Author

@Ergus Ergus commented May 15, 2019

Hi Abo-abo:
It works pretty fine for me, thanks!

Any way.
Sometimes there is a jump to a different candidate when going from isearch to swiper (sometimes there is a scroll to go there). It doesn't happen always, but it is something very frequent for me. I have not found yet how to reproduce it or a pattern for when it happens. But it you give a look it will be very nice if this small issue goes away. (in the mean time I can live with it, so I won't complain (or create an issue) to no bother you too much).

Any way, again very thanks for that.

@abo-abo
Copy link
Owner

@abo-abo abo-abo commented May 16, 2019

I think the only thing where something could be broken is (isearch-exit) (goto-char (match-beginning 0)). Here we have to go to the beginning of the match. We assume that the match data from isearch is still valid. Which it is in all the times I tested.

astoff added a commit to astoff/swiper that referenced this issue Jan 1, 2021
astoff added a commit to astoff/swiper that referenced this issue Jan 1, 2021
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