[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 8ba236e 2/2: Escape dash in xref rgrep regexp
From: |
Dmitry Gutov |
Subject: |
[Emacs-diffs] master 8ba236e 2/2: Escape dash in xref rgrep regexp |
Date: |
Sun, 29 Jan 2017 21:02:59 +0000 (UTC) |
branch: master
commit 8ba236e772b64d0bb021aa691bd7eacf4b7f3ae4
Author: Dmitry Gutov <address@hidden>
Commit: Dmitry Gutov <address@hidden>
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(+)
diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index d8098c5..a507755 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)