dajva / rg.el

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

how can I pass in additonal arguments like -w, -s #8

Closed it6 closed 7 years ago

it6 commented 7 years ago

Additional arguments doesn't work when passing additional arguments. Can you please add this to readme too.

I am passing in -w SEARCH_PATTERN here is the command and error I see

Now I see you have rg-command-line-flags how can I pass flags to this variable? I need the ability to pass random flags to different searches.


rg --color always --colors match:fg:red --type less --no-heading --type-add 'gn:*.gn' --type-add 'gn:*.gni' --type-add 'gyp:*.gyp' --type-add 'gyp:*.gypi' -i -w\ onboarding
error: Found argument '- ' which wasn't expected, or isn't valid in this context
dajva commented 7 years ago

rg-command-line-flags is a global variable so it's suited for flags you want in every search. It's customizable by doing M-x customize-group RET rg RET and adding flags under the Rg Command Line Flags setting.

If you want to add a flag for a single search you can use the prefix argument C-u to the rg command. That will let you edit the full command line before it's executed.

it6 commented 7 years ago

I see a \ being added to the -w flag when I try to add flag without using C-u this is causing the search to fail is there anyway we can enable this feature without pressing C-u

This throws an error as mentioned above

rg --color always --colors match:fg:red --type less --no-heading --type-add 'gn:*.gn' --type-add 'gn:*.gni' --type-add 'gyp:*.gyp' --type-add 'gyp:*.gypi' -i -w\ onboarding

This works as expected

rg --color always --colors match:fg:red --type less --no-heading --type-add 'gn:*.gn' --type-add 'gn:*.gni' --type-add 'gyp:*.gyp' --type-add 'gyp:*.gypi' -i -w onboarding
dajva commented 7 years ago

Spaces are escaped to allow for search terms with spaces in them. This comes from emacs builtin read input functions. If you don't want to use type C-u every time you can define your own wrapper:

(defun my-rg ()
  (interactive)
  (let ((current-prefix-arg '(4)))
    (call-interactively #'rg)))