From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Augusto Stoffel Newsgroups: gmane.emacs.bugs Subject: bug#59888: [PATCH] Add 'grep-use-headings' Date: Tue, 28 Feb 2023 19:17:45 +0100 Message-ID: <871qm9bqnq.fsf@gmail.com> 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> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="10305"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 59888@debbugs.gnu.org To: Juri Linkov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Feb 28 19:18: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 1pX4YP-0002Vz-CW for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 28 Feb 2023 19:18:21 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pX4Y8-0002HK-8T; Tue, 28 Feb 2023 13:18: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 1pX4Y6-0002Gv-KT for bug-gnu-emacs@gnu.org; Tue, 28 Feb 2023 13:18:02 -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 1pX4Y6-0000ZM-44 for bug-gnu-emacs@gnu.org; Tue, 28 Feb 2023 13:18:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pX4Y5-0007uM-TS for bug-gnu-emacs@gnu.org; Tue, 28 Feb 2023 13:18:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Augusto Stoffel Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 28 Feb 2023 18:18:01 +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.167760827630386 (code B ref 59888); Tue, 28 Feb 2023 18:18:01 +0000 Original-Received: (at 59888) by debbugs.gnu.org; 28 Feb 2023 18:17:56 +0000 Original-Received: from localhost ([127.0.0.1]:51984 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pX4Xz-0007u2-TN for submit@debbugs.gnu.org; Tue, 28 Feb 2023 13:17:56 -0500 Original-Received: from mail-ed1-f47.google.com ([209.85.208.47]:35576) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pX4Xx-0007tp-Jt for 59888@debbugs.gnu.org; Tue, 28 Feb 2023 13:17:54 -0500 Original-Received: by mail-ed1-f47.google.com with SMTP id ee7so43859868edb.2 for <59888@debbugs.gnu.org>; Tue, 28 Feb 2023 10:17:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=ykJDx0bSBsVr5agDGXRRvWH0gFWi6b+tiXm4L5G+WPQ=; b=ab+/hSmkqOJvfnMI5Ptji8AGFkRjZICkRnb4SNJmB+X1o5OsUndNPynHInrmg6ER+O AV0fo19HGzq+7C5FHFDjmprMIU9h117wzZqWNYPK+lp0INKYvTN29sgrejFGgbedalbz M2aYq0Tj5gIt+u1Qp+xS4jJmLt2PC8EpcPonV6o+Rufq+2Ra4M2gaCMjGmQ8wrqQun9/ RDuLJKVscr94LPa64R9KqA+q0XKgZjkg6RjjRk7NpsgKnqgEZTHCmzCC81TQZsHL/TJ7 1heaMHi8gJB8q6jX3vimv/dtnGLHMGeVZgbnhkzxQib5Qsl51xDw06suyDB/A3IRQHZI p9pA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=ykJDx0bSBsVr5agDGXRRvWH0gFWi6b+tiXm4L5G+WPQ=; b=SAkNUzT8+ASXkNBZN8OumpWkFm4mvek9QKlGHJGg27JRi53rx+lNlVSOM+YksA2dhG 69xP2ZIX3rO1auI8K+2oJDao/+UdJe5DnsbS8ikSmXj+3kB+l3RLThvo3zkXwi9gC1Tn DStLQws3y1pW2Q2sQYXbg9YnrgxyjvdkVh0H/oQt55YYFNOKE0FsLqAqYzaocIi4x0fz o/IBOoS4C0Xd3+zsHb0AIMjHmR/IpkTBhXt3nkRZdNk/Mzyc92MDj+Q4H2BAztGktxLR JXGnAaxt7GyeltRvTSjUqOCznuDLtJc8C2Gj8nUtRCHg/9rcNAWbmGSeu+Twodt2QX6g n2tg== X-Gm-Message-State: AO0yUKVcugxB8Lg6qemVli/ElgfY0zGLBPgJVdzON8JoCZwD5QYUXI50 6eKrAtfGKOJEPrj5rr5iaUSniB+0U6TOzA== X-Google-Smtp-Source: AK7set+mPu91OSuexDejge4DRdOHOAawNJB7qOVbodp1ZtDroKsZPw5IDSILHylH+veEhVCk1L1ueg== X-Received: by 2002:a05:6402:3458:b0:4af:6c28:337a with SMTP id l24-20020a056402345800b004af6c28337amr3915656edc.36.1677608267099; Tue, 28 Feb 2023 10:17:47 -0800 (PST) Original-Received: from ars3 ([2a02:8109:8ac0:56d0::8b3a]) by smtp.gmail.com with ESMTPSA id x2-20020a50d602000000b004acd14ab4dfsm4675320edi.41.2023.02.28.10.17.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Feb 2023 10:17:46 -0800 (PST) In-Reply-To: <86r0u9oj4p.fsf@mail.linkov.net> (Juri Linkov's message of "Tue, 28 Feb 2023 19:24:58 +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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:257004 Archived-At: On Tue, 28 Feb 2023 at 19:24, Juri Linkov wrote: >> +(defvar grep-heading-regexp >> + (rx bol >> + (or >> + (group-n 2 >> + (group-n 1 (+ (not (any 0 ?\n)))) >> + 0) >> + (group-n 2 >> + (group-n 1 (+? nonl)) >> + (any ?: ?- ?=))) >> + (+ digit) >> + (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: --8<---------------cut here---------------start------------->8--- $ git grep -nC 1 grep-use-headings etc/NEWS-99- etc/NEWS:100:*** New user option 'grep-use-headings'. etc/NEWS-101-When non-nil, the output of Grep is split into sections, one for each -- 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." -- lisp/progmodes/grep.el-465-(defface grep-heading `((t :inherit ,grep-hit-face)) lisp/progmodes/grep.el:466: "Face of headings when `grep-use-headings' is non-nil." lisp/progmodes/grep.el-467- :version "30.1") -- lisp/progmodes/grep.el-969- (string-replace "\0" ":" string))) lisp/progmodes/grep.el:970: (when grep-use-headings lisp/progmodes/grep.el-971- (add-hook 'compilation-filter-hook #'grep--heading-filter 80 t) --8<---------------cut here---------------end--------------->8--- (I forget which program uses the =LINE= syntax) At least when using grep --null, I think there is no confusion possible. I wrote a unit test that purports to prove that.