dajva / rg.el

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

rg-build-template deletes duplicate args #33

Closed froydnj closed 6 years ago

froydnj commented 6 years ago

The rg documentation states that flags like -g, -i, and --ignore-file may be used multiple times. Unfortunately, if you try to build command line flags like so:

(let ((rg-command-line-flags (mapcan #'(lambda (dir) (list "-g" ...)) ignored-directories)))
  (rg ...))

rg will actually get invoked as:

rg ... -g DIR1 DIR2 DIR3 ...

rather than having multiple -g options, as intended.

dajva commented 6 years ago

Duplicate flags are removed since some flags yields errors if supplied multiple times.

I am not sure what format rg-command-line-flags would have in the end from looking at your example but it looks to me that the flag and associated value would be split into different items in the list. That could cause the behavior you see. Try to concat the flag and related value into a single string and see if it works better.

So you should have rg-command-line-flags be: '("-g foo" "-g bar") rather than '("-g" "foo" "-g" "bar)

froydnj commented 6 years ago

Try to concat the flag and related value into a single string and see if it works better.

Ah, indeed, that works! I should have grokked that from seeing other bits of rg-build-template, but for some reason assumed that every argument had to be its own string.

Thanks for the help!