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#44983: Truncate long lines of grep output Date: Tue, 01 Dec 2020 10:45:29 +0200 Organization: LINKOV.NET Message-ID: <87v9dlc3ti.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="1382"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) To: 44983@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Dec 01 09:56:10 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 1kk1SD-00009W-UV for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 01 Dec 2020 09:56:09 +0100 Original-Received: from localhost ([::1]:38796 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kk1SC-0002Y5-Ip for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 01 Dec 2020 03:56:08 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:43840) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kk1S6-0002Xm-AD for bug-gnu-emacs@gnu.org; Tue, 01 Dec 2020 03:56:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:46179) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kk1S6-0002D5-1Q 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 1kk1S5-0003WF-Vb for bug-gnu-emacs@gnu.org; Tue, 01 Dec 2020 03:56:01 -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:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 44983 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.160681292213465 (code B ref -1); Tue, 01 Dec 2020 08:56:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 1 Dec 2020 08:55:22 +0000 Original-Received: from localhost ([127.0.0.1]:57723 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kk1RS-0003V1-ET for submit@debbugs.gnu.org; Tue, 01 Dec 2020 03:55:22 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:38194) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kk1RR-0003Us-92 for submit@debbugs.gnu.org; Tue, 01 Dec 2020 03:55:21 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:43706) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kk1RR-0002Vj-02 for bug-gnu-emacs@gnu.org; Tue, 01 Dec 2020 03:55:21 -0500 Original-Received: from relay11.mail.gandi.net ([217.70.178.231]:43351) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kk1RP-0001oO-2U for bug-gnu-emacs@gnu.org; Tue, 01 Dec 2020 03:55:20 -0500 Original-Received: from mail.gandi.net (m91-129-99-98.cust.tele2.ee [91.129.99.98]) (Authenticated sender: juri@linkov.net) by relay11.mail.gandi.net (Postfix) with ESMTPSA id B0D4810000B for ; Tue, 1 Dec 2020 08:55:15 +0000 (UTC) Received-SPF: pass client-ip=217.70.178.231; envelope-from=juri@linkov.net; helo=relay11.mail.gandi.net X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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:194708 Archived-At: [New bug report from emacs-devel] >>>> For grep output a bigger problem is that grep on binary data >>>> might output too long lines before the terminating newline. >>> >>> (*) We already have this kind of problem with "normal" files which contain >>> minified assets (JS or CSS). The file contents are usually normal ASCII, >>> but it's just one line which can reach several MBs in length. >>> >>> The usual way to deal with that is with project-ignores and >>> grep-find-ignored-files. That works for both cases. >> This is a bug problem - often grep output lines are so long >> that Emacs freezes, so need to kill the process. Updating >> manually ignored-files every time a new file causes freeze >> is very unreliable and time-consuming workaround. > > And a non-obvious one (for an average user). > > Is the same problem exhibited by commands using the Xref UI? I don't > remember seeing it, but of course our projects can be very different. No difference from grep, Xref output has the same problem. >> I tried to fix this problem, and fortunately the fix is simple >> with the 1-liner patch. >> It does exactly the same thing that we recently did to hide >> overly long grep command lines with 'grep-find-abbreviate'. >> The patch even uses the same 'grep-find-abbreviate-properties' >> to allow clicking the hidden part to expand it. >> diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el >> index dafba22f77..e0df2402ee 100644 >> --- a/lisp/progmodes/grep.el >> +++ b/lisp/progmodes/grep.el >> @@ -492,6 +492,9 @@ grep-mode-font-lock-keywords >> (0 grep-context-face) >> (1 (if (eq (char-after (match-beginning 1)) ?\0) >> `(face nil display ,(match-string 2))))) >> + ;; Hide excessive parts of grep output lines >> + ("^.+?:.\\{,64\\}\\(.*\\).\\{10\\}$" >> + 1 grep-find-abbreviate-properties) >> ;; Hide excessive part of rgrep command >> ("^find \\(\\. -type d .*\\\\)\\)" >> (1 (if grep-find-abbreviate grep-find-abbreviate-properties >> >> More customizability could be added later to define the >> length of the hidden part, etc. > > Maybe we'll want it to be dynamically determined by fill-column. > > Or just be a big enough value (e.g. 256) that the only lines where this > rule is hit are obviously too long. Or maybe determined by the frame width. This will avoid the need of using such workarounds as in bug#44941: grep -a "$@" | cut -c -200