From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#31796: 27.1; dired-do-find-regexp-and-replace fails to find multiline regexps Date: Tue, 01 Dec 2020 10:39:56 +0200 Organization: LINKOV.NET Message-ID: <87blfec4l3.fsf@mail.linkov.net> References: <10120030-8b8d-b702-add4-8f099f934ed5@chalmers.se> <831rgivl7l.fsf@gnu.org> <83lfequ30g.fsf@gnu.org> <83a6v6tss9.fsf@gnu.org> <08c0bbce-051e-7a49-106a-d6d0629b2224@yandex.ru> <87blffns95.fsf@mail.linkov.net> <8c124412-3bb3-fd92-4c3b-da4b3a8bdcac@yandex.ru> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="3444"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) Cc: abela@chalmers.se, 31796@debbugs.gnu.org To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Dec 01 09:56:36 2020 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 1kk1Sb-0000i8-OX for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 01 Dec 2020 09:56:33 +0100 Original-Received: from localhost ([::1]:39296 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kk1Sa-0002px-Rp for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 01 Dec 2020 03:56:32 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:43850) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kk1S6-0002Xs-ND for bug-gnu-emacs@gnu.org; Tue, 01 Dec 2020 03:56:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:46181) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kk1S6-0002DF-Ft for bug-gnu-emacs@gnu.org; Tue, 01 Dec 2020 03:56:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kk1S6-0003WS-EI for bug-gnu-emacs@gnu.org; Tue, 01 Dec 2020 03:56:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 01 Dec 2020 08:56:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 31796 X-GNU-PR-Package: emacs Original-Received: via spool by 31796-submit@debbugs.gnu.org id=B31796.160681292213458 (code B ref 31796); Tue, 01 Dec 2020 08:56:02 +0000 Original-Received: (at 31796) by debbugs.gnu.org; 1 Dec 2020 08:55:22 +0000 Original-Received: from localhost ([127.0.0.1]:57721 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kk1RS-0003Uz-4Z for submit@debbugs.gnu.org; Tue, 01 Dec 2020 03:55:22 -0500 Original-Received: from relay4-d.mail.gandi.net ([217.70.183.196]:37921) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kk1RP-0003Ud-TO for 31796@debbugs.gnu.org; Tue, 01 Dec 2020 03:55:20 -0500 X-Originating-IP: 91.129.99.98 Original-Received: from mail.gandi.net (m91-129-99-98.cust.tele2.ee [91.129.99.98]) (Authenticated sender: juri@linkov.net) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id BBE9DE0008; Tue, 1 Dec 2020 08:55:12 +0000 (UTC) In-Reply-To: <8c124412-3bb3-fd92-4c3b-da4b3a8bdcac@yandex.ru> (Dmitry Gutov's message of "Tue, 1 Dec 2020 04:21:23 +0200") 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:194709 Archived-At: >> When a grep input pattern contains a newline, then xref could use >> the same algorithm as is used for 'M-.', i.e. run 'grep -Pzl' >> to get the file names that contain the pattern, then return >> these file names without line numbers. > > Do you mean the xref items backed by find-func.el? There are a particular > kind of references which are usually unique enough that special navigation > logic can work. It's also implemented this way because the search can be > performed without reading file contents (which would be slower). I meant xref-matches-in-files. It could also use another regexp for the output of 'grep -Pzo' without line numbers. >> This works exactly >> like a new feature of extending xref-show-xrefs-function >> with a new completion function was proposed recently on emacs-devel > > For Grep results, I think the line number is important because we're even > more likely to have multiple lines with the same contents in one file. Yes, sometimes this might cause inconvenience when the user wants to visit the second occurrence of exactly the same line. > What we *could* do, is run Grep, then take just the list of files names > that it returns, visit them all in Emacs and repeat the search in all of > them. But that would require a more complex abstraction than just "search > command", as well as some juggling of buffers that weren't open before (we > don't want to add more open buffers just because the user has run a search, > right?). dired-do-find-regexp uses 'ignores' to filter out ignored files. You could add another filter to filter out files without matches using 'grep -PzL'. >> (BTW, why it's not installed yet?) > > Waiting for the feedback. > > It went through several minor revisions. Do you like the most recent > version? If so, please reply to the message containing it. If you don't, > please also reply and say why. I suggest to create a new bug-number for it. >> So like this feature presenting such completions without line numbers: >> lisp/progmodes/project.el:(cl-defgeneric project-root) >> lisp/progmodes/project.el:(cl-defmethod project-root ((project (head transient)))) >> lisp/progmodes/project.el:(cl-defmethod project-root ((project (head vc)))) >> xref for grep could work the same way without line numbers: >> lisp/progmodes/project.el:names"^Jproject--read-file-cpd-relative) >> lisp/progmodes/project.el:names"^Jproject--read-file-absolute) >> Then visiting such grep hit should use Emacs search functions >> to find the grep hit in the visited file. > > These are two substrings inside that file that matched the search > regexp. But there could be substrings in the same file that are equal to > either of these but don't match said regexp, e.g. because they are preceded > or followed by some different contents. How is this possible? Please show examples.