]> git.eshelyaron.com Git - emacs.git/commitdiff
Escape dash in xref rgrep regexp
authorDmitry Gutov <dgutov@yandex.ru>
Sun, 29 Jan 2017 08:41:32 +0000 (10:41 +0200)
committerDmitry Gutov <dgutov@yandex.ru>
Sun, 29 Jan 2017 21:01:42 +0000 (23:01 +0200)
* lisp/progmodes/xref.el (xref-collect-matches): Escape dash
in REGEXP if it's the first character.

lisp/progmodes/xref.el

index d8098c5a54af5a30e61130a2d2293516dd73451c..a507755d42e44c6294f0449840a6d66a2b660285 100644 (file)
@@ -918,6 +918,10 @@ IGNORES is a list of glob patterns."
   (grep-compute-defaults)
   (defvar grep-find-template)
   (defvar grep-highlight-matches)
+  ;; 'grep -E -foo' results in 'grep: oo: No such file or directory'.
+  ;; while 'grep -e -foo' inexplicably doesn't.
+  (when (eq (aref regexp 0) ?-)
+    (setq regexp (concat "\\" regexp)))
   (let* ((grep-find-template (replace-regexp-in-string "-e " "-E "
                                                        grep-find-template t t))
          (grep-highlight-matches nil)