unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Dmitry Gutov <dgutov@yandex.ru>
To: emacs-devel@gnu.org, "Mattias Engdegård" <mattiase@acm.org>
Subject: Re: master 031e1c2: Regexp-quote literal symbols when grepping
Date: Sun, 19 Sep 2021 02:47:23 +0300	[thread overview]
Message-ID: <6e585f17-3c7a-7b22-00cd-0ec7039ffa72@yandex.ru> (raw)
In-Reply-To: <20210918114626.6FF8F20ABE@vcs0.savannah.gnu.org>

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	other threads:[~2021-09-18 23:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20210918114625.2175.90107@vcs0.savannah.gnu.org>
     [not found] ` <20210918114626.6FF8F20ABE@vcs0.savannah.gnu.org>
2021-09-18 23:47   ` Dmitry Gutov [this message]
2021-09-19  7:35     ` master 031e1c2: Regexp-quote literal symbols when grepping Mattias Engdegård

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6e585f17-3c7a-7b22-00cd-0ec7039ffa72@yandex.ru \
    --to=dgutov@yandex.ru \
    --cc=emacs-devel@gnu.org \
    --cc=mattiase@acm.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).