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 and outlines #2119

Closed
gusbrs opened this issue Jul 3, 2019 · 3 comments
Closed

swiper-isearch and outlines #2119

gusbrs opened this issue Jul 3, 2019 · 3 comments

Comments

@gusbrs
Copy link
Contributor

@gusbrs gusbrs commented Jul 3, 2019

swiper-isearch does not currently play well with outlines, either in org-mode or outline-minor-mode. swiper, on the other hand, handles this quite gracefully, by which I mean:

  • after being run, it respects the previous folding state of the buffer, with the exception of an eventual selected candidate
  • as one navigates through the list of candidates, the current candidate is always shown on the buffer unfolded (temporarily, unless selected)

Neither of these properties is exhibited by swiper-isearch, however.

I set a somewhat arbitrary case for this, but which enables one to reproduce the mentioned behaviors.

Start with emacs -Q, then evaluate:

(package-initialize)
(ivy-mode)
(find-library "simple")
(outline-minor-mode)
(outline-hide-body)

Now, start swiper-isearch and search for the string "let"

M-x swiper-isearch RET let

and navigate through the list of candidates, with "C-n" or equivalent.

Notice that some candidates will fail to be shown in the buffer (I assume they are still in folded regions, but I’m not really sure). Not all candidates will be hidden, actually most of them will be shown, and some exceptions not.

Furthermore, from this point, consider two possible actions. First, cancel the search with "C-g". This will let the folding state of the buffer quite disturbed, if you had navigated through any considerable number of candidates. Second case, select one candidate. The selection will work as expected, but yet again, the folding state of the buffer will be quite disrupted in sections which are not the one of the selected candidate.

The same general behavior happens for Org files.

It would be really nice if swiper-isearch played better with outlines, specially as swiper already does a great job in this respect.

Environment: Emacs 26.2; swiper-20190627.1944; ivy-20190701.1140; counsel-20190629.1203.

PS: I hope it is as promised. :)

@abo-abo abo-abo closed this in f9e8116 Jul 3, 2019
@abo-abo
Copy link
Owner

@abo-abo abo-abo commented Jul 3, 2019

Thanks, please test.

@gusbrs
Copy link
Contributor Author

@gusbrs gusbrs commented Jul 3, 2019

Thank you very very much.
And, wow! that was fast!

I did test it here in the different environments I use some sort of outlining (Org, emacs-lisp, LaTeX), and it is working beautifully.

With this, the things I really missed from swiper I also get in swiper-isearch. Plus its benefits, of course. :-)
I still have some residual use cases for isearch itself, but that's another matter. Anyway, most of the lifting here is already done by Ivy & friends. It is very much appreciated. Thank you.

@abo-abo
Copy link
Owner

@abo-abo abo-abo commented Jul 4, 2019

You're welcome. Thanks for the report.

astoff added a commit to astoff/swiper that referenced this issue Jan 1, 2021
* swiper.el (swiper-isearch-action): The change to
  `isearch-range-invisible' params is important here.
(swiper-isearch): Clean up the overlays here, instead of in `swiper--cleanup'.

Expected behavior after the fix: all outlines that were revealed are
closed, either on finish or on abort. The exception is the outline
that contains the point.

Fixes abo-abo#2119
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