From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Gregory Heytings Newsgroups: gmane.emacs.bugs Subject: bug#46859: 28.0.50; [PATCH]: Add option to truncate long lines in xref.el Date: Wed, 03 Mar 2021 20:34:46 +0000 Message-ID: <4119ea30552873ab9870@heytings.org> References: <87im69uzlt.fsf@mail.linkov.net> <878s74fv27.fsf@mail.linkov.net> <4119ea3055ef8f306fc0@heytings.org> <4119ea30557ef84ca190@heytings.org> <7eb7ee0f-7dba-c90d-cb58-af42c3828643@yandex.ru> <4119ea30554b406efbbf@heytings.org> <4119ea30558f1e4145b0@heytings.org> <4119ea30555e80bdcf7e@heytings.org> <1c82e582-8b90-f3c5-5391-1e88ca4e7ab2@yandex.ru> <4119ea30553e3f90ab8c@heytings.org> <87y2f42ex5.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: text/plain; format=flowed; charset=us-ascii Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="36043"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 46859@debbugs.gnu.org To: Juri Linkov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Mar 03 21:35:12 2021 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 1lHYDA-0009EJ-8C for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 03 Mar 2021 21:35:12 +0100 Original-Received: from localhost ([::1]:56468 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lHYD9-0000YZ-A8 for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 03 Mar 2021 15:35:11 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:59152) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lHYD0-0000WL-9C for bug-gnu-emacs@gnu.org; Wed, 03 Mar 2021 15:35:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:45575) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lHYD0-0006WZ-1j for bug-gnu-emacs@gnu.org; Wed, 03 Mar 2021 15:35:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lHYCz-0004fH-V9 for bug-gnu-emacs@gnu.org; Wed, 03 Mar 2021 15:35:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Gregory Heytings Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 03 Mar 2021 20:35:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 46859 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 46859-submit@debbugs.gnu.org id=B46859.161480369017910 (code B ref 46859); Wed, 03 Mar 2021 20:35:01 +0000 Original-Received: (at 46859) by debbugs.gnu.org; 3 Mar 2021 20:34:50 +0000 Original-Received: from localhost ([127.0.0.1]:57121 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lHYCo-0004eo-Gc for submit@debbugs.gnu.org; Wed, 03 Mar 2021 15:34:50 -0500 Original-Received: from heytings.org ([95.142.160.155]:41916) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lHYCm-0004ef-J7 for 46859@debbugs.gnu.org; Wed, 03 Mar 2021 15:34:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=heytings.org; s=20210101; t=1614803687; bh=hHLq4PdAlUPHF+F3Su+JyOmofxi3ucjxH/KysFsWoVY=; h=Date:From:To:cc:Subject:In-Reply-To:Message-ID:References:From; b=BRBObt1SxPGCkCtX2UWLH1h00EfnJlZXm2G6fguveXfvvyShoHebVKCi9Gat74Ogd HepAddHokMk4hnV4eA/QQkcTHuiiFQINmLyIwjQNT8EsXknHQZbgLTKw/8kPZwQXYo 7mDiLfEbpNjw1+DmdQNHLpBI2Ooi+4lclD1rh8UJVDWiyOpYApBuCn/Z+PSU46vP7l auc13cOinJwOtPhng2i9OXwvZKtol4nAMx+hBIHWlR48qeAa2NuCSmJb6A8ZBH1IOZ 9QHrqw5BwAIky8XyqrmDRQhqOB5Guf5vrvypEl11XSqr7LW4PNqlGBnAB/+VyhC/oX FW4o7mLwIbBlA== In-Reply-To: <87y2f42ex5.fsf@mail.linkov.net> 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:201330 Archived-At: >>> OK, so we get the byte offset, but not the length of the match (which >>> we'll also need later, for purposes such as highlighting and >>> replacement). And what happens if there are several matches on the >>> same line? We need columns for all of them. >> >> I don't know exactly what you want to do, I initially chimed in this >> conversation to react to Juri's "GNU grep has no option to truncate >> output", to mention that GNU grep does have an option to do this; >> perhaps it doesn't do exactly what you want. > > By an option I meant a command line switch of GNU grep, not something > that looks like a hack. > It's not a hack at all, it's a command line switch: -o. The amount of context, which defaults to zero, is given in the regexp instead of as an argument to the command line switch. This -o option has been present since GNU grep 2.5, twenty years ago. You can use it together with other options: grep -o PATTERN FILE prints the matches grep -no PATTERN FILE prints the matches and their line number grep -bo PATTERN FILE prints the matches and their offset grep -bo '.\{0,BEFORE\}PATTERN.\{0,AFTER\}' FILE prints the matches with a given BEFORE and AFTER context and so forth. And the -o option is supported by ripgrep, ag and ack, with almost the same syntax. It's perhaps not what you want, but at least to me it seems more powerful than ripgrep's -M option.