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: Sat, 05 Dec 2020 21:47:06 +0200 Organization: LINKOV.NET Message-ID: <87h7p0f611.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> <87zh2w7ww1.fsf@mail.linkov.net> <83pn3reyjs.fsf@gnu.org> <87y2ie7for.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="14328"; 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 Sat Dec 05 20:54:20 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 1klddI-0003Yq-KC for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 05 Dec 2020 20:54:16 +0100 Original-Received: from localhost ([::1]:48426 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1klddH-0004P6-MF for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 05 Dec 2020 14:54:15 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:59316) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kldd4-0004Nz-5w for bug-gnu-emacs@gnu.org; Sat, 05 Dec 2020 14:54:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:36735) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kldd3-0006A3-Rj for bug-gnu-emacs@gnu.org; Sat, 05 Dec 2020 14:54:01 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kldd3-0002r4-Qc for bug-gnu-emacs@gnu.org; Sat, 05 Dec 2020 14:54: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: Sat, 05 Dec 2020 19:54:01 +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.160719800710923 (code B ref 44983); Sat, 05 Dec 2020 19:54:01 +0000 Original-Received: (at 44983) by debbugs.gnu.org; 5 Dec 2020 19:53:27 +0000 Original-Received: from localhost ([127.0.0.1]:48281 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kldcV-0002q7-Ck for submit@debbugs.gnu.org; Sat, 05 Dec 2020 14:53:27 -0500 Original-Received: from relay10.mail.gandi.net ([217.70.178.230]:54397) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kldcT-0002pj-SF for 44983@debbugs.gnu.org; Sat, 05 Dec 2020 14:53:26 -0500 Original-Received: from mail.gandi.net (m91-129-99-98.cust.tele2.ee [91.129.99.98]) (Authenticated sender: juri@linkov.net) by relay10.mail.gandi.net (Postfix) with ESMTPSA id 6C6F9240006; Sat, 5 Dec 2020 19:53:18 +0000 (UTC) In-Reply-To: <87y2ie7for.fsf@mail.linkov.net> (Juri Linkov's message of "Thu, 03 Dec 2020 23:17:08 +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:195050 Archived-At: >> I suggested to request the equivalent of "cut -c" to be a feature >> added to Grep. >> >> Failing that, I don't think Emacs should do something like that, >> especially since 'cut' is not guaranteed to be available. Users who >> have such problems can, of course, modify the Grep command to do that. > > Finally I solved the long-standing problem by customizing > grep-find-template to > > "find -type f -print0 | sort -z | xargs -0 -e grep --color=always -inH -e | cut -c -200" I noticed the problems caused by "cut -c": it counts bytes, not multi-byte characters. Even though it documentation says that -b selects bytes, and -c selects characters, still when used with "cut -c -200" it selects bytes, not UTF characters. Often it cuts in the middle of a multi-byte UTF-8 character, so octal codes are displayed at the end of grep lines. This is like the character limit for a SMS message is 160 characters, whereas actually this means not characters, but bytes, because on an UTF text the SMS limit is only 70 characters.