From 8ba236e772b64d0bb021aa691bd7eacf4b7f3ae4 Mon Sep 17 00:00:00 2001 From: Dmitry Gutov Date: Sun, 29 Jan 2017 10:41:32 +0200 Subject: Escape dash in xref rgrep regexp * lisp/progmodes/xref.el (xref-collect-matches): Escape dash in REGEXP if it's the first character. --- lisp/progmodes/xref.el | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lisp/progmodes/xref.el') diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el index d8098c5a54a..a507755d42e 100644 --- a/lisp/progmodes/xref.el +++ b/lisp/progmodes/xref.el @@ -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) -- cgit v1.2.3