>> @@ -150,15 +150,14 @@ semantic-symref-perform-search >> "-l ") >> ((eq (oref tool searchtype) 'regexp) >> "-nE ") >> - (t "-n "))) >> + (t (if (equal grep-program "rg") "" "-n ")))) > > It might be cleaner to see whether grep-find-template already includes that > flag, and if so, omit it. Though the search might be non-trivial if it's in > the form like "-abcn", still, that's searchable by regexp. Indeed, but such a hack is a temporary measure and can be removed later after ripgrep will be fixed. >> ;; Can't use the word boundaries: Grep >> ;; doesn't always agree with the language >> ;; syntax on those. >> - (format "\\(^\\|\\W\\)%s\\(\\W\\|$\\)" >> - (oref tool searchfor))))) >> + (format "\\b%s\\b" (oref tool searchfor))))) > > I think the original idea (surrounding with \W) is sound: after all, not > every symbol boundary in Emacs sense is a word boundary in Grep or RG. If > a method, say, ends with ?, then it won't be. I tried to search for 'soap-type-is-array?' in the Emacs tree, and ripgrep can find it with "\\b%s\\b", but Grep can't. > The problem with the above regexp is that it uses the basic syntax, instead > of Extended. But we can flip it. > > As long as we're able to ask Grep to search with Extended syntax, we can > use (format "(^|\\W)%s(\\W|$)" (oref tool searchfor)). And that can be > achieved with the same method as is used in xref-matches-in-directory: > > Something like (replace-regexp-in-string "grep " "grep -E" > grep-find-template t t), to be sure it's not ripgrep in there. > > The new user option can be used too, but I'd probably prefer a more > independent solution here. It would be more preferable not to change the existing default logic to avoid possible troubles. Since Grep with Basic syntax works fine, then better not to switch to Extended syntax. The new user option is already used in many places in grep.el in the previous patch, so it should be ok to use it in semantic-symref as well: