rg.el icon indicating copy to clipboard operation
rg.el copied to clipboard

Searching in a single file or the current file is awkward

Open JohnWick95 opened this issue 4 years ago • 5 comments

When using Regex or Literal search is not clear that you can type the file name in the file filter prompt (works by coincidence?) but it works, no file navigation help(completion) though.

When using the 'Current file' option one can't specify the search pattern before the search because it searches the current 'word' under the cursor, so you have to then redefine the search.

Maybe I'm missing something or this is not a use case rg.el cares about much?

Tangential: The readme implies grep can only search one file but it can search many. Of course you know this, maybe you meant to say ripgrep is better optimized for search multiple files?

Anyway, best emacs ripgrep interface, thx!

JohnWick95 avatar Jul 04 '20 05:07 JohnWick95

Thanks!

Yes, you are right that the single file search has never been a prioritized use case for this package. The rg-dwim-current-file search function is not a true one file search function but rather search all files with this name under a specific directory. I think this is mentioned somewhere in the docs or at least I have thought about adding it. :)

This essentially comes from that this package grew as a replacement for the rgrep emacs command which is my personal primary use case. I have struggled with finding a good way of adding true single file search into this package and fit with the other concepts. I actually have a prototype on the search_buffers branch that adds a path filter concept that is intended to be used for single file search (among others). No such frontend atm but if you want to play with it it should be possible to create one with the rg-define-search macro pretty easily.

Tangential: The readme implies grep can only search one file but it can search many.

This is unintentional. If you point me at the passage I will try to fix that.

dajva avatar Jul 04 '20 08:07 dajva

No such frontend atm but if you want to play with it it should be possible to create one with the rg-define-search macro pretty easily.

This is not entirely true I realize. You would also have to modify the rg-path-filter-functions option properly so it gets a bit more tricky I am afraid.

dajva avatar Jul 04 '20 08:07 dajva

Thanks, Not much of a problem, we'll see what can I work out.

This is unintentional. If you point me at the passage I will try to fix that.

At the top of the README:

Ripgrep is a replacement for both grep like (search one file) and ag like (search many files) tools.

JohnWick95 avatar Jul 06 '20 18:07 JohnWick95

Any news of this?

failable avatar Sep 29 '21 06:09 failable

Not been working on this for long.

dajva avatar Sep 29 '21 16:09 dajva