dajva / rg.el

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

Make custom search remember search flags #89

Closed geza-herman closed 4 years ago

geza-herman commented 4 years ago

I have a little enhancement suggestion:

I created a custom search:

  (rg-define-search rg-my-default
    "Search everything, binary, zipped."
    :files "everything"
    :flags '("--binary -z")
    :confirm prefix
    :menu ("Search" "m" "My default"))

After I execute this search, I enter to rg-menu by pressing m. Here, all the flags are unset. It would be good, if my custom flags was remembered (binary and zipped), and I didn't have to set them again.

dajva commented 4 years ago

It will do that but the flags need to be present in the menu to begin with for that to happen. You have a couple of problems with your definition here:

  1. :flags should be a list with each flag as a separate item in the list. That would be needed for flags to be picked up by the menu.h
  2. You need to use the actual flag that is used by the menu. In the zipped case, you need to use --search-zip instead of -z.
  3. --binary is not part of the menu so will be left out. You can add this into the menu by using regular transient commands: https://magit.vc/manual/transient/Modifying-Existing-Transients.html#Modifying-Existing-Transients

The --binary flag is a relatively new addition AFAIU. The --text flag is in the menu but I am considering removing that in favor of --binary since it seems more useful in general

geza-herman commented 4 years ago

Thank you for the quick response! I used

  (transient-append-suffix 'rg-menu "-a" '(3 "-b" "Search binary files" "--binary"))

and

    :flags '("--search-zip" "--binary")

and this works indeed.