branch: externals/urgrep
commit bfab29d1d7d478a1aaa68c00586d1b615daeaeea
Author: Jim Porter <jporterb...@gmail.com>
Commit: Jim Porter <jporterb...@gmail.com>

    Add support for searches starting with "-"
---
 urgrep-tests.el | 16 ++++++++--------
 urgrep.el       | 14 ++++++++------
 2 files changed, 16 insertions(+), 14 deletions(-)

diff --git a/urgrep-tests.el b/urgrep-tests.el
index a56ef0c367..03812cc424 100644
--- a/urgrep-tests.el
+++ b/urgrep-tests.el
@@ -30,25 +30,25 @@
   (let ((tool (assoc "ag" urgrep-tools))
         (common-args "ag --color-path 35 --color-match 1\\;31 "))
     (should (equal (urgrep-command "foo" :tool tool)
-                   (concat common-args "-Q --group foo")))
+                   (concat common-args "-Q --group -- foo")))
     (should (equal (urgrep-command "foo" :tool tool :group nil)
-                   (concat common-args "-Q --nogroup foo")))
+                   (concat common-args "-Q --nogroup -- foo")))
     (should (equal (urgrep-command "foo" :tool tool :regexp t)
-                   (concat common-args "--group foo")))
+                   (concat common-args "--group -- foo")))
     (should (equal (urgrep-command "foo" :tool tool :context 3)
-                   (concat common-args "-C3 -Q --group foo")))))
+                   (concat common-args "-C3 -Q --group -- foo")))))
 
 (ert-deftest urgrep-tests-command-git-grep ()
   (let ((tool (assoc "git-grep" urgrep-tools))
         (common-args "git -c color.grep.filename\\=magenta grep -n 
--recurse-submodules --color "))
     (should (equal (urgrep-command "foo" :tool tool)
-                   (concat common-args "-F --heading --break foo")))
+                   (concat common-args "-F --heading --break -e foo")))
     (should (equal (urgrep-command "foo" :tool tool :group nil)
-                   (concat common-args "-F foo")))
+                   (concat common-args "-F -e foo")))
     (should (equal (urgrep-command "foo" :tool tool :regexp t)
-                   (concat common-args "--heading --break foo")))
+                   (concat common-args "--heading --break -e foo")))
     (should (equal (urgrep-command "foo" :tool tool :context 3)
-                   (concat common-args "-C3 -F --heading --break foo")))))
+                   (concat common-args "-C3 -F --heading --break -e foo")))))
 
 (ert-deftest urgrep-tests-command-grep ()
   (let ((tool (assoc "grep" urgrep-tools)))
diff --git a/urgrep.el b/urgrep.el
index 0536a7372a..074b30479e 100644
--- a/urgrep.el
+++ b/urgrep.el
@@ -81,7 +81,8 @@
 (defvar urgrep-tools
   `(("ag"
      (executable-name "ag")
-     (always-arguments ("--color-path" "35" "--color-match" "1;31"))
+     (pre-arguments ("--color-path" "35" "--color-match" "1;31"))
+     (post-arguments ("--"))
      (group-arguments ((t   ("--group"))
                        (nil ("--nogroup"))))
      (regexp-arguments ((nil ("-Q"))))
@@ -89,8 +90,9 @@
     ("git-grep"
      (executable-name "git")
      (vc-backend "Git")
-     (always-arguments ("-c" "color.grep.filename=magenta" "grep" "-n"
-                        "--recurse-submodules" "--color"))
+     (pre-arguments ("-c" "color.grep.filename=magenta" "grep" "-n"
+                     "--recurse-submodules" "--color"))
+     (post-arguments ("-e"))
      (group-arguments ((t ("--heading" "--break"))))
      (regexp-arguments ((nil ("-F"))))
      (context-arguments "-C%d"))
@@ -133,8 +135,8 @@
     (if cmd-fun
         (apply cmd-fun query rest)
       (let ((executable (urgrep-get-property tool 'executable-name))
-            (always-args (or (urgrep-get-property tool 'always-arguments) '()))
-            (arguments '()))
+            (pre-args (or (urgrep-get-property tool 'pre-arguments) '()))
+            (arguments (or (urgrep-get-property tool 'post-arguments) '())))
         ;; Fill in group arguments. XXX: Maybe figure out a more flexible way 
to
         ;; do this?
         (when-let ((x (urgrep-get-property-assoc tool 'group-arguments group)))
@@ -151,7 +153,7 @@
         ;; FIXME: Inside compile and dired buffers, `shell-quote-argument'
         ;; doesn't handle TRAMP right...
         (mapconcat #'shell-quote-argument
-                   (append `(,executable) always-args arguments `(,query))
+                   (append `(,executable) pre-args arguments `(,query))
                    " ")))))
 
 

Reply via email to