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: Wed, 02 Dec 2020 22:53:18 +0200 Organization: LINKOV.NET Message-ID: <87zh2w7ww1.fsf@mail.linkov.net> References: <87v9dlc3ti.fsf_-_@mail.linkov.net> <83ft4pik35.fsf@gnu.org> <87sg8p5kw0.fsf@mail.linkov.net> <83eek8hoyx.fsf@gnu.org> <87h7p4r1n9.fsf@mail.linkov.net> <62EB4762-278D-43E7-8699-BBDC47818A50@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="37414"; 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: 44983@debbugs.gnu.org, dgutov@yandex.ru To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Dec 02 22:36:12 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 1kkZnH-0009ao-8t for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 02 Dec 2020 22:36:11 +0100 Original-Received: from localhost ([::1]:38628 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kkZnG-0003cY-8m for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 02 Dec 2020 16:36:10 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:36246) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kkZn8-0003ZA-RO for bug-gnu-emacs@gnu.org; Wed, 02 Dec 2020 16:36:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:54271) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kkZn8-0007li-I9 for bug-gnu-emacs@gnu.org; Wed, 02 Dec 2020 16:36:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kkZn8-0004nk-EM for bug-gnu-emacs@gnu.org; Wed, 02 Dec 2020 16:36: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, 02 Dec 2020 21:36:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 44983 X-GNU-PR-Package: emacs Original-Received: via spool by 44983-submit@debbugs.gnu.org id=B44983.160694492418389 (code B ref 44983); Wed, 02 Dec 2020 21:36:02 +0000 Original-Received: (at 44983) by debbugs.gnu.org; 2 Dec 2020 21:35:24 +0000 Original-Received: from localhost ([127.0.0.1]:37580 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kkZmV-0004mW-RL for submit@debbugs.gnu.org; Wed, 02 Dec 2020 16:35:24 -0500 Original-Received: from relay11.mail.gandi.net ([217.70.178.231]:40881) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kkZmU-0004mI-7g for 44983@debbugs.gnu.org; Wed, 02 Dec 2020 16:35:22 -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 BE00C100007; Wed, 2 Dec 2020 21:35:14 +0000 (UTC) In-Reply-To: <62EB4762-278D-43E7-8699-BBDC47818A50@gnu.org> (Eli Zaretskii's message of "Wed, 02 Dec 2020 12:28:17 +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:194838 Archived-At: >> Or maybe the problem is caused by special characters >> used in minified web assets that contain many '{' chars. >> And indeed, after inserting 100 thousands of '{' >> >> (insert (propertize (make-string 100000 ?{) >> 'display "[…]" 'invisible t) "\n") >> >> and saving to a file, later visiting such file >> Emacs becomes unresponsive for indefinite time. >> But visiting the file with 100 thousands '{' >> with find-file-literally causes no such problem. > > Does it help to set bidi-inhibit-bpa non-nil? This helped to open the file with a lot of '{'. But on minified files grep.el is still very slow. Then instead of hiding long lines using font-lock, I tried to do the same using the process filter: (defun grep-filter () (save-excursion (let ((end (point-marker))) (goto-char compilation-filter-start) (forward-line 0) (while (< (point) end) (let ((eol (line-end-position))) (when (> (- eol (point)) 64) (put-text-property (+ 64 (point)) (line-end-position) 'display "[…]")) (forward-line 1)))))) Still very slow. Then tried to delete the excessive parts of long lines: (defun grep-filter-try () (save-excursion (let ((end (point-marker))) (goto-char compilation-filter-start) (forward-line 0) (while (< (point) end) (let ((eol (line-end-position))) (when (> (- eol (point)) 64) (delete-region (min (+ 64 (point)) (point-max)) (line-end-position))) (forward-line 1)))))) Now Emacs becomes more responsive. But still output processing takes too much time. Finally, the last thing to try was the same solution that Richard showed in bug#44941: grep -a "$@" | cut -c -200 that gives the best possible result. I doubt that it would be possible to invent something better. So the question is should this be customizable for adding `cut -c` automatically to the end of the grep command line, possibly with `stdbuf -oL` suggested by Andreas.