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#59888: [PATCH] Add 'grep-use-headings' Date: Wed, 01 Mar 2023 19:52:53 +0200 Organization: LINKOV.NET Message-ID: <86o7pcpduq.fsf@mail.linkov.net> References: <87v8mndrla.fsf@gmail.com> <87ilime025.fsf@gmail.com> <86359pm55x.fsf@mail.linkov.net> <87o7scdb45.fsf_-_@gmail.com> <837cz0z7wj.fsf@gnu.org> <87k0301h16.fsf@gmail.com> <831qp8z5gp.fsf@gnu.org> <87sfhn3tui.fsf@gmail.com> <83wn6zui9n.fsf@gnu.org> <87ilii41p9.fsf@gmail.com> <867cytgk0k.fsf@mail.linkov.net> <871qme5ej3.fsf@gmail.com> <87cz5w7ehu.fsf@gmail.com> <87pm9wcvoe.fsf@gmail.com> <86y1oj9byf.fsf@mail.linkov.net> <87cz5vc4io.fsf@gmail.com> <86r0u9oj4p.fsf@mail.linkov.net> <871qm9bqnq.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="31329"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu) Cc: 59888@debbugs.gnu.org To: Augusto Stoffel Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Mar 01 18:59:22 2023 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 1pXQjZ-00081u-1X for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 01 Mar 2023 18:59:21 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pXQjI-0004pM-DB; Wed, 01 Mar 2023 12:59:04 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pXQjH-0004ox-5P for bug-gnu-emacs@gnu.org; Wed, 01 Mar 2023 12:59:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXQjG-0001nF-N8 for bug-gnu-emacs@gnu.org; Wed, 01 Mar 2023 12:59:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pXQjG-0003n8-Jf for bug-gnu-emacs@gnu.org; Wed, 01 Mar 2023 12:59: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: Wed, 01 Mar 2023 17:59:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 59888 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 59888-submit@debbugs.gnu.org id=B59888.167769349314496 (code B ref 59888); Wed, 01 Mar 2023 17:59:02 +0000 Original-Received: (at 59888) by debbugs.gnu.org; 1 Mar 2023 17:58:13 +0000 Original-Received: from localhost ([127.0.0.1]:54851 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pXQiS-0003lk-W9 for submit@debbugs.gnu.org; Wed, 01 Mar 2023 12:58:13 -0500 Original-Received: from relay7-d.mail.gandi.net ([217.70.183.200]:39675) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pXQiR-0003lT-5x for 59888@debbugs.gnu.org; Wed, 01 Mar 2023 12:58:11 -0500 Original-Received: (Authenticated sender: juri@linkov.net) by mail.gandi.net (Postfix) with ESMTPSA id A4C8B2000E; Wed, 1 Mar 2023 17:58:02 +0000 (UTC) In-Reply-To: <871qm9bqnq.fsf@gmail.com> (Augusto Stoffel's message of "Tue, 28 Feb 2023 19:17:45 +0100") 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:257091 Archived-At: >>> + (any ?: ?- ?=)) >> >> I wonder what is the reason for this regexp to be different >> from grep-regexp-alist? Especially with such additional characters >> as ?- and ?=. This mismatch causes wrong handling of files when >> file names contain these characters. > > This is because of context lines: > > $ git grep -nC 1 grep-use-headings > lisp/progmodes/grep.el-459- > lisp/progmodes/grep.el:460:(defcustom grep-use-headings nil > lisp/progmodes/grep.el-461- "If non-nil, subdivide grep output into sections, one per file." > ... > At least when using grep --null, I think there is no confusion possible. I > wrote a unit test that purports to prove that. Thanks for mentioning --null, I completely forgot about it. I've customized 'grep-find-template' to "rg --no-heading" because ripgrep is fast, but since its headings are not supported by grep.el, so also needed "--no-heading". And now after adding "--null" to "rg --no-heading --null" 'grep-use-headings' correctly handles context lines and file names with numbers separated by dashes.