* Re: master 031e1c2: Regexp-quote literal symbols when grepping
[not found] ` <20210918114626.6FF8F20ABE@vcs0.savannah.gnu.org>
@ 2021-09-18 23:47 ` Dmitry Gutov
2021-09-19 7:35 ` Mattias Engdegård
0 siblings, 1 reply; 2+ messages in thread
From: Dmitry Gutov @ 2021-09-18 23:47 UTC (permalink / raw)
To: emacs-devel, Mattias Engdegård
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'.
^ permalink raw reply [flat|nested] 2+ messages in thread