dajva / rg.el

Emacs search tool based on ripgrep
https://rgel.readthedocs.io
GNU General Public License v3.0
474 stars 39 forks source link

navigate through latest searches #39

Closed kidd closed 5 years ago

kidd commented 6 years ago

sometimes I find myself searching something with rg (using rg or rg-dwim), and just realize that I'd like to list results of the last search again. I'm thinking something like Help mode's c-c c-b and c-c c-f. Do you think it's useful enough to be merged? which approach do you recommend? I'll try to send a PR

dajva commented 6 years ago

Sounds like a great idea that would definitely fit well into this package. Some options that come to mind is:

  1. The simplest solution I could think of would be to save search buffers by default. I think ag.el does this. Personally, I am not very fond of this since I don't like having random buffers floating around. This isn't exactly what you suggested either but would probably be very simple to implement with a defcustom that let you choose if you want to enable this or not. The benefit of this is that searches are instantly available without repeating the search.
  2. Store history of search parameters. This seems to fit better with your suggestion than 1. Drawback would be that searches would be repeated which could take time for large search result. We could store rg-search structs for this which would allow for the same interactions when navigating history as for new searches. One could also store the full command line but that would restrict history navigation to seeing the result of the search without the possibility to refine it.
  3. Save the result buffer content. Don't know how this would work. I guess it could be possible to just instert the raw text of the result after enabling rg-result mode but might not work with search term highlighting out of the box. Would also need a relatively large amount of storage compared to the other alternatives and not allow for modifying history results.

My initial preference would be 2 with storing rg-search structs if possible. What are your thoughts about the alternatives.

kidd commented 6 years ago

Yep , I think 2 is also best. In fact, I'm looking at using a similar approach to how Help buffers do it.

Stay tunned :)

dajva commented 6 years ago

@kidd: Are you working on this?

kidd commented 6 years ago

Unfortunately life kicked in before I could have anything half decent... :(

I got inspiration from emacs' help-go-back and help-xref-stack (even trying to reuse the same machinery), but couldn't finish this up (not sure it was the best approach but sounded like an easy one)

dajva commented 6 years ago

Right, no problem. Life is a constant problem. ;)

I got interested in this feature myself, that's why I am asking. I don't have time to work on it right now either so just checking the status really.

dajva commented 5 years ago

I'll start working on this myself unless you are doing work on this

kidd commented 5 years ago

:+1: go for it!

dajva commented 5 years ago

I've pushed a history branch in case you want to try it out. It needs some more fixes, tests and docs but should work pretty ok in the current state.

kidd commented 5 years ago

woah! nice!

Installed it already and I'm going to be using it during this next week. I'll report here any insights, nuances or anything.

kidd commented 5 years ago

Just dropping by to report that this is working great!

dajva commented 5 years ago

Great, this go stuck on the topic branch. Still some more tests and documentation missing. I will merge this to master now and do t he final additions there. Thanks for testing it out.