emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: master 031e1c2: Regexp-quote literal symbols when grepping


From: Dmitry Gutov
Subject: Re: master 031e1c2: Regexp-quote literal symbols when grepping
Date: Sun, 19 Sep 2021 02:47:23 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0

On 18.09.2021 14:46, Mattias Engdeg�rd wrote:
+(defun semantic-symref-grep--quote-extended (string)
+  "Quote STRING as an extended-syntax regexp."
+  (replace-regexp-in-string (rx (in ".^$*+?|{}[]()|\\"))
+                            (lambda (s) (concat "\\" s))
+                            string nil t))
+
  (cl-defmethod semantic-symref-perform-search ((tool 
semantic-symref-tool-grep))
    "Perform a search with Grep."
    ;; Grep doesn't support some types of searches.
@@ -151,7 +157,10 @@ This shell should support pipe redirect syntax."
                            ((eq (oref tool searchtype) 'regexp)
                             "-nE ")
                            (t "-nw ")))
-         (greppat (oref tool searchfor))
+         (searchfor (oref tool searchfor))
+         (greppat (if (eq (oref tool searchtype) 'regexp)
+                      searchfor
+                    (semantic-symref-grep--quote-extended searchfor)))

When the search is not 'regexp', we're using the default regexp mode of Grep, which is Basic, not Extended.

So this doesn't seem like the right change (yet?).

It's not particularly breaking for xref-find-references because of its post-filtering step, and because most of these chars are rarely present in symbol names, but it probably breaks 'M-x semantic-symref' (which doesn't do any post-filtering) because \? and \+ are actually special in Basic regexps. I haven't been able to test it, though.

It does break xref-find-references for symbols with '+' somewhere in the middle, like 'antlr-c++-mode-extra'.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]