dajva / rg.el

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

searching PDF #84

Closed AtomicNess123 closed 4 years ago

AtomicNess123 commented 4 years ago

Hi, I'm interested in searching across my PDFs. What would be the syntax in args to search within PDFs?

I want to do what this line does in ripgrep:

rg --pre ./preprocess 'The Commentz-Walter algorithm' 1995-watson.pdf
3 

[source: [https://github.com/BurntSushi/ripgrep/blob/master/GUIDE.md#preprocessor]]

I was also wondering if it can search in folders of PDFs, not just in one PDF document. Thanks!

dajva commented 4 years ago

You either have to use full command line search by giving universal argument to the rg command. In this way you can modify the command line according to you needs. This solution integrates pretty badly with the rest of this package though. Or, you would have to create a custom search for this. Something like this would do the trick I think:

(rg-define-search rg-pdf
  :files "pdf"
  :flags "--pre ./preprocess")

Then just run your new rg-pdf command with M-x. This package actually doesn't support the use case of specifying a single file (yet) to search on the command line so this should provide recursive search in your chosen directory.

dajva commented 4 years ago

Please reopen if this didn't help.

AtomicNess123 commented 4 years ago

Thanks, I will try and let you know.

AtomicNess123 commented 4 years ago

One more question though: is it possible to search across PDF and text notes or once the flag flags "--pre ./preprocess is set it wouldn't work for other file types? Could I just add :files "pdf" "txt"?

dajva commented 4 years ago

The :files directive translates into a native ripgrep --type flag. TBH, I don't know how ripgrep handles multiple types. I suggest you try at the command line and see if that works. There is nothing in this package that translate this to multiple --type flags at least. Might be something to improve on possibly. Currently my suggestion would be to add a custom type into rg-custom-type-aliases if it's a configuration you use often. That would make it available in more places in this package. Another question is if the preprocess command handle different file types but that should be all in your hand I guess.

AtomicNess123 commented 4 years ago

Thanks for your help. I will take your advice.