From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.bugs Subject: bug#49836: Support ripgrep in semantic-symref-tool-grep Date: Wed, 4 Aug 2021 06:14:55 +0300 Message-ID: References: <87sfzrbke1.fsf_-_@mail.linkov.net> <875ywn556i.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="10691"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 To: Juri Linkov , 49836@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Aug 04 05:16:12 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mB7O8-0002g6-2A for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 04 Aug 2021 05:16:12 +0200 Original-Received: from localhost ([::1]:45504 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mB7O6-0008Ti-N3 for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 03 Aug 2021 23:16:10 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:41364) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mB7Nz-0008TX-CC for bug-gnu-emacs@gnu.org; Tue, 03 Aug 2021 23:16:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:58741) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mB7Nz-0006VO-5H for bug-gnu-emacs@gnu.org; Tue, 03 Aug 2021 23:16:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mB7Ny-0006nj-HR for bug-gnu-emacs@gnu.org; Tue, 03 Aug 2021 23:16:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 04 Aug 2021 03:16:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 49836 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 49836-submit@debbugs.gnu.org id=B49836.162804690626071 (code B ref 49836); Wed, 04 Aug 2021 03:16:02 +0000 Original-Received: (at 49836) by debbugs.gnu.org; 4 Aug 2021 03:15:06 +0000 Original-Received: from localhost ([127.0.0.1]:42054 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mB7N3-0006mR-Tt for submit@debbugs.gnu.org; Tue, 03 Aug 2021 23:15:06 -0400 Original-Received: from mail-wr1-f52.google.com ([209.85.221.52]:46695) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mB7N1-0006le-Og for 49836@debbugs.gnu.org; Tue, 03 Aug 2021 23:15:04 -0400 Original-Received: by mail-wr1-f52.google.com with SMTP id c16so527212wrp.13 for <49836@debbugs.gnu.org>; Tue, 03 Aug 2021 20:15:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=0AOo2fx7VNsE68676BMPriL8GnXwWSaoSKzYDiXSs2o=; b=vSGnxv5OyqgYTW4ycvTTN6j62il+ubjw/q53FNqGB0y58CBxfkLenU12/0M1F2GPgi eDFiTsZhFM/HSEL0wzd3bRAxZjbZKoYItVXJRbyE/Vjf8eWKWOA1CwuavWCBTy7lq6u4 8ttb2snBQecvDCsNoy+RnEUfV4dfKlZhzNY3QmpCgVDWKPgdjfaHb9uGGlS8z1c7z4c2 6owRn9GehAIwk1+7E8lXtIUPvF9/ySUopMGvdnsUtJkchqpmrj/PkRUl36EcNsRYlLMD 5hgVl8S5dD0rAM+74QHee8zK3/yemgudbc0DHQ3zSnRRqJfsthuawcsXlnQZi4+ploY1 r0jg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=0AOo2fx7VNsE68676BMPriL8GnXwWSaoSKzYDiXSs2o=; b=Em41lGYHedl5s9n8bDKrpB9pDkOuVfehw0GGojOFBJqQbp16sdhaqXWzKTuSS+XUcP BIqGdh/1rrFDsJxNIet1x4LmwHE15HWt9g6auOCtCrfvtFpaU37WWSabxCbIYFPYOCu8 5h3zvZBOXxTVF/Tm0bQnIonSr6hxrbu/d2I+agCJWi+xXibQdWZJ3oj12L5oueiYO+pI 8YUfB1VucWfh8ywk3Ee+vleY3RuLXqXYklhPzl75oUu1v1tmceugpmgLtc3PZTwmIjNv gaTc3BgfA57ssTm4UUw/z8duiRcTosHHyU8TJbElES/HDHWnPAoHmb0/HDV+Wlnq6WA/ 2pkw== X-Gm-Message-State: AOAM532gDZFobVRyGWP0T3A5HaGVc2QfWP5i89lJQzTXWGpGrGJ5y+u1 QejXgHH6HZjT6e8Y4VlhYUe+Z31871Y= X-Google-Smtp-Source: ABdhPJyLtxG2vI6XYPR7frnSomcitGBqxPqNQtVnyiMR6sWaBgUVHtvi1e8Ctfbgmn+r7Jz8qxdKIg== X-Received: by 2002:adf:eacb:: with SMTP id o11mr27578411wrn.62.1628046897875; Tue, 03 Aug 2021 20:14:57 -0700 (PDT) Original-Received: from [192.168.0.6] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id f2sm740634wrq.69.2021.08.03.20.14.56 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 03 Aug 2021 20:14:57 -0700 (PDT) In-Reply-To: <875ywn556i.fsf@mail.linkov.net> Content-Language: en-US X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:211115 Archived-At: I think we can improve this part: On 03.08.2021 11:10, Juri Linkov wrote: > diff --git a/lisp/cedet/semantic/symref/grep.el b/lisp/cedet/semantic/symref/grep.el > index 180d779a78..034f797076 100644 > --- a/lisp/cedet/semantic/symref/grep.el > +++ b/lisp/cedet/semantic/symref/grep.el > @@ -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. > (greppat (cond ((eq (oref tool searchtype) 'regexp) > (oref tool searchfor)) > (t > ;; 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))))) > ;; Misc > (b (get-buffer-create "*Semantic SymRef*")) > (ans nil) 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. 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.