Escape dash in xref rgrep regexp

* lisp/progmodes/xref.el (xref-collect-matches): Escape dash
in REGEXP if it's the first character.
This commit is contained in:
Dmitry Gutov 2017-01-29 10:41:32 +02:00
parent 52feecd3c7
commit 8ba236e772

View 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)