GNU bug report logs - #46859
28.0.50; [PATCH]: Add option to truncate long lines in xref.el

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Theodor Thornhill <theo@HIDDEN>; Keywords: patch; dated Mon, 1 Mar 2021 20:42:01 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 46859 <at> debbugs.gnu.org:


Received: (at 46859) by debbugs.gnu.org; 6 Mar 2021 12:58:47 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Mar 06 07:58:47 2021
Received: from localhost ([127.0.0.1]:36235 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lIWW7-0000Hu-9x
	for submit <at> debbugs.gnu.org; Sat, 06 Mar 2021 07:58:47 -0500
Received: from heytings.org ([95.142.160.155]:45486)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <gregory@HIDDEN>) id 1lIWW5-0000Hm-N7
 for 46859 <at> debbugs.gnu.org; Sat, 06 Mar 2021 07:58:46 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=heytings.org;
 s=20210101; t=1615035524;
 bh=pu+nG5SOmflDqTN4zDTSaXX68YuOoo+9gkng1Kb0Z5M=;
 h=Date:From:To:cc:Subject:In-Reply-To:Message-ID:References:From;
 b=e7045l54YoVxTJ47HiyHlG++qFnfN0pPPCcml4Kg05B87LtAgJUwjtek0iKqZvyvw
 q9cQnLR7X5iqephkavoFKs6obapfPFt/lxFsTZJfRvYSjeZkFWpdvumvba8H6lxdxf
 j8qrCvSAfdF0/nHiiUL/fZPuOCc/26WsQdEFlTffJc7uqgzwGzU65cb98o4vHQWvzJ
 rdVqkiu8FKjzNEeNGSORBPTERPbs/yjrz5RLbMgcX7IJIUIqh3u4/qry7lwTXkS9Ib
 nv9hupcN7bsosxh3xp6yP4EnIqwZtUbODTT3Sy4enaTJvb819QVvr5eA0CTzTGIbGs
 50k63yuhJp0Mg==
Date: Sat, 06 Mar 2021 12:58:44 +0000
From: Gregory Heytings <gregory@HIDDEN>
To: Dmitry Gutov <dgutov@HIDDEN>
Subject: Re: bug#46859: 28.0.50; [PATCH]: Add option to truncate long lines
 in xref.el
In-Reply-To: <b8474b14-fe69-9b72-a939-6f89a79fb3e9@HIDDEN>
Message-ID: <7de1aeec52b5dcf97969@HIDDEN>
References: <m25z2azjxp.fsf@HIDDEN> <87im69uzlt.fsf@HIDDEN>
 <m2wnup9s2y.fsf@HIDDEN> <878s74fv27.fsf@HIDDEN>
 <4119ea3055ef8f306fc0@HIDDEN>
 <d52c0f52-8c8b-0688-e735-c8eacf4ebcdb@HIDDEN>
 <4119ea30557ef84ca190@HIDDEN>
 <7eb7ee0f-7dba-c90d-cb58-af42c3828643@HIDDEN>
 <4119ea30554b406efbbf@HIDDEN> <4119ea30558f1e4145b0@HIDDEN>
 <ae221795-5197-36c5-4e0e-e1cb97e2a076@HIDDEN>
 <4119ea30555e80bdcf7e@HIDDEN>
 <1c82e582-8b90-f3c5-5391-1e88ca4e7ab2@HIDDEN>
 <4119ea30553e3f90ab8c@HIDDEN>
 <08b51962-6305-5188-0bea-b17b4139646c@HIDDEN>
 <4119ea3055bd6f6d2e91@HIDDEN>
 <b8474b14-fe69-9b72-a939-6f89a79fb3e9@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; format=flowed; charset=us-ascii
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 46859
Cc: 46859 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)


>> I don't know what you exactly need (I don't (yet?) use project), so I 
>> can't elaborate further or provide benchmarks alas.
>
> The same code is also used in the default implementation of 
> xref-find-references, in case you ever tried it.
>
>> Could you perhaps tell me what you need?
>
> We are discussing changes to xref.el, because project-find-regexp 
> delegates a lot of its logic to it.
>
> Check out xref-matches-in-files and xref--convert-hits which it calls at 
> the end.
>

Okay, thanks, what you need is clearer to me, I'll have a look.

>
> What you're thinking of seems to require a Grep-specific version of 
> xref--convert-hits logic, which in the end constructs specialized xref 
> items with a new type of location (alternative to xref-file-location).
>

Yes, that's what I'm thinking of indeed, but it's not specific to "grep" 
because it would work the same way with ripgrep, ag and ack.  But indeed 
it's specific to grep-like tools.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#46859; Package emacs. Full text available.

Message received at 46859 <at> debbugs.gnu.org:


Received: (at 46859) by debbugs.gnu.org; 6 Mar 2021 12:54:43 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Mar 06 07:54:43 2021
Received: from localhost ([127.0.0.1]:36216 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lIWSB-0000Aj-0u
	for submit <at> debbugs.gnu.org; Sat, 06 Mar 2021 07:54:43 -0500
Received: from heytings.org ([95.142.160.155]:45472)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <gregory@HIDDEN>) id 1lIWS9-0000AY-Ba
 for 46859 <at> debbugs.gnu.org; Sat, 06 Mar 2021 07:54:41 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=heytings.org;
 s=20210101; t=1615035280;
 bh=raaNAvR/I0txbYXFMWdFRcmL28hZD49gO8hDY2bdCsA=;
 h=Date:From:To:cc:Subject:In-Reply-To:Message-ID:References:From;
 b=lcj/oM7C1BeQ6PIMb/jfyL2n+2IvQHR/AHrMbVGyBqtV8BSaxgr+fqjL0BuO+k3Zg
 jSQ97T2Q0fA+UUyp6tsgkgsqtJR0nWtu0SxHy0tGnzdu4wXahz0bs+E+KuIlDbyDTc
 jENf+mCjTP8X96cpci55XiSeT5f5iKmZV1dx9rgtBEmUdw1pzhaDHQMuoPytfilSem
 9TLP5ZmddQPppV+CUyXmAZELwz9FJv36o1QHJLz2iIz83yiUcAaoSpT6AnZf2z/yS5
 7XUC6vAGqyk4GPwLEG0mbmX9K6xds1G0UeidvygJvVBLa9tyKFBfzbyHqTkuD50p9I
 fl4P6pXg0c87Q==
Date: Sat, 06 Mar 2021 12:54:40 +0000
From: Gregory Heytings <gregory@HIDDEN>
To: Dmitry Gutov <dgutov@HIDDEN>
Subject: Re: bug#46859: 28.0.50; [PATCH]: Add option to truncate long lines
 in xref.el
In-Reply-To: <109276c6-30fb-b1ca-cafa-48a15710099b@HIDDEN>
Message-ID: <7de1aeec520f4204be5b@HIDDEN>
References: <m25z2azjxp.fsf@HIDDEN>
 <m2wnup9s2y.fsf@HIDDEN> <878s74fv27.fsf@HIDDEN>
 <4119ea3055ef8f306fc0@HIDDEN>
 <d52c0f52-8c8b-0688-e735-c8eacf4ebcdb@HIDDEN>
 <4119ea30557ef84ca190@HIDDEN>
 <7eb7ee0f-7dba-c90d-cb58-af42c3828643@HIDDEN>
 <4119ea30554b406efbbf@HIDDEN> <4119ea30558f1e4145b0@HIDDEN>
 <ae221795-5197-36c5-4e0e-e1cb97e2a076@HIDDEN>
 <4119ea30555e80bdcf7e@HIDDEN>
 <1c82e582-8b90-f3c5-5391-1e88ca4e7ab2@HIDDEN>
 <4119ea30553e3f90ab8c@HIDDEN> <87y2f42ex5.fsf@HIDDEN>
 <4119ea30552873ab9870@HIDDEN> <83eegvk2u0.fsf@HIDDEN>
 <9cff0f8894658f3b50c8@HIDDEN> <83y2f3huz2.fsf@HIDDEN>
 <9cff0f88942d4103c685@HIDDEN> <83mtvjhrzj.fsf@HIDDEN>
 <9cff0f889435d8d03313@HIDDEN> <834khq266r.fsf@HIDDEN>
 <9cff0f8894ab45713d12@HIDDEN>
 <16ac41d4-5718-0cec-a68b-4abcc736ee4a@HIDDEN>
 <109276c6-30fb-b1ca-cafa-48a15710099b@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; format=flowed; charset=us-ascii
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 46859
Cc: 46859 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)


>
> Except, um, we still need to fill in the "summary" attribute for all 
> matches, so that there is something to display in the Xref buffer (the 
> line contents around the match), and the -o flag strips those.
>

That's the purpose of the '.{0,100}' context.  In typical cases (souce 
code files with lines that do not have more than 80 colums) you don't even 
see the difference in the result buffer: you see the whole line.

>
> And if we were to use the '.{0,100}file.{0,100}' trick, it messes up the 
> location of the match, the reported byte offset become unreliable.
>

That's a problem to solve, indeed.  At first sight it doesn't seem 
unsolvable.

>
> Also: grepping for that kind of regexp is noticeably slower than 
> grepping for 'file'. Or even '.file'. Like 85ms vs 7ms slower.
>

Well, the bug report mentioned delays of 3-4 seconds on files with very 
long lines, so I'd guess that 85 ms is a pretty reasonable speed...




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#46859; Package emacs. Full text available.

Message received at 46859 <at> debbugs.gnu.org:


Received: (at 46859) by debbugs.gnu.org; 6 Mar 2021 12:49:19 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Mar 06 07:49:19 2021
Received: from localhost ([127.0.0.1]:36212 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lIWMx-0008UF-Cv
	for submit <at> debbugs.gnu.org; Sat, 06 Mar 2021 07:49:19 -0500
Received: from heytings.org ([95.142.160.155]:45462)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <gregory@HIDDEN>) id 1lIWMu-0008U5-Br
 for 46859 <at> debbugs.gnu.org; Sat, 06 Mar 2021 07:49:17 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=heytings.org;
 s=20210101; t=1615034955;
 bh=RdnFDBijsg/ewvfutvseWXdbHTAKycK4s+HOZaOyjPw=;
 h=Date:From:To:cc:Subject:In-Reply-To:Message-ID:References:From;
 b=Nna0ChR0L2O9KyAe3Hu0ROP7ARaJ170S7zjSWV/NjpCZWTw+uGWj/U3zrfCnk1hML
 T/rSCZhVv5is8iNriV5a/Vynl66WTqQnEckmz5R3DbWJ4pUoILAE4ojSVxSDoh0xDv
 PpSpHVW7AQeP0sv8O3podUJRKa0lFcrYcFfilhbZwmmcu7pzAMoy8DsbHmLXLWAD+j
 zI2fanVgpB9nQe1iS8XQ+75PrBg8iMbOexjq9PDhfFYJbKcrmYXeqle6z4shk4cM/m
 unVt8DiqQyZgliavczwx2ygLwLSWMQgjANFmTnelHzXEOZI0XhUp1lZi3UfoZ/Mzh8
 TleXTzQoltKdQ==
Date: Sat, 06 Mar 2021 12:49:14 +0000
From: Gregory Heytings <gregory@HIDDEN>
To: Dmitry Gutov <dgutov@HIDDEN>
Subject: Re: bug#46859: 28.0.50; [PATCH]: Add option to truncate long lines
 in xref.el
In-Reply-To: <16ac41d4-5718-0cec-a68b-4abcc736ee4a@HIDDEN>
Message-ID: <7de1aeec52418a3d5fd5@HIDDEN>
References: <m25z2azjxp.fsf@HIDDEN> <87im69uzlt.fsf@HIDDEN>
 <m2wnup9s2y.fsf@HIDDEN> <878s74fv27.fsf@HIDDEN>
 <4119ea3055ef8f306fc0@HIDDEN>
 <d52c0f52-8c8b-0688-e735-c8eacf4ebcdb@HIDDEN>
 <4119ea30557ef84ca190@HIDDEN>
 <7eb7ee0f-7dba-c90d-cb58-af42c3828643@HIDDEN>
 <4119ea30554b406efbbf@HIDDEN> <4119ea30558f1e4145b0@HIDDEN>
 <ae221795-5197-36c5-4e0e-e1cb97e2a076@HIDDEN>
 <4119ea30555e80bdcf7e@HIDDEN>
 <1c82e582-8b90-f3c5-5391-1e88ca4e7ab2@HIDDEN>
 <4119ea30553e3f90ab8c@HIDDEN> <87y2f42ex5.fsf@HIDDEN>
 <4119ea30552873ab9870@HIDDEN> <83eegvk2u0.fsf@HIDDEN>
 <9cff0f8894658f3b50c8@HIDDEN> <83y2f3huz2.fsf@HIDDEN>
 <9cff0f88942d4103c685@HIDDEN> <83mtvjhrzj.fsf@HIDDEN>
 <9cff0f889435d8d03313@HIDDEN> <834khq266r.fsf@HIDDEN>
 <9cff0f8894ab45713d12@HIDDEN>
 <16ac41d4-5718-0cec-a68b-4abcc736ee4a@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; format=flowed; charset=us-ascii
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 46859
Cc: 46859 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)


>> Just tried 'exact, it works, it's slow (but not horribly slow: 1.2 
>> seconds on that 25 MB file)
>
> 1.2s is pretty slow for this purpose.
>

It is: (1) on a 25 MB file (not the typical case), (2) on a file with an 
exotic encoding (not a typical case either).  On typical files (UTF-8 or 
single byte encoding) the delay is not noticeable (a few milliseconds).

>
> Otherwise it would be possible to use this approach (by introducing a 
> Grep-specific location type) and avoid parsing the line contents for 
> every match.
>

It would be much faster, especially with very long lines, which was the 
question with which this bug report started.

>
> One downside would be missing on the syntax highlighting which we 
> sometimes get for already-fontified parts of buffers, but it's 
> unreliable anyway.
>

Yes, I don't understand why syntax highlighting is used in such buffers, 
IMO it's useless, it would be useful only if (1) it were reliable and (2) 
all lines were highlighted.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#46859; Package emacs. Full text available.

Message received at 46859 <at> debbugs.gnu.org:


Received: (at 46859) by debbugs.gnu.org; 6 Mar 2021 12:45:01 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Mar 06 07:45:01 2021
Received: from localhost ([127.0.0.1]:36208 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lIWIm-0006IK-Pq
	for submit <at> debbugs.gnu.org; Sat, 06 Mar 2021 07:45:01 -0500
Received: from mail-wr1-f49.google.com ([209.85.221.49]:34221)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <raaahh@HIDDEN>) id 1lIWIl-0006I7-50
 for 46859 <at> debbugs.gnu.org; Sat, 06 Mar 2021 07:44:59 -0500
Received: by mail-wr1-f49.google.com with SMTP id u16so5459126wrt.1
 for <46859 <at> debbugs.gnu.org>; Sat, 06 Mar 2021 04:44:59 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=sender:subject:to:cc:references:from:message-id:date:user-agent
 :mime-version:in-reply-to:content-language:content-transfer-encoding;
 bh=i9kTuyLJOcwVnnK1Hqcz7peiUKoz+t+vR5D5al7psK8=;
 b=iO6aAW1oRsIluYd/rOpfSBkQQggr+jUTqnVzJy1IcLQxrkM+8zDbUk0fajVsk7+zk+
 +lQYPYTUhxYJLufvm6kvoaMiLwa5i8jhHNnojVMtBA0sD6AN2alXNVrofNFBLcj3eqRn
 vF6KBpx1slV/Ls8yXlJvavPdufynDw7q4536RhcVdEwBsmGLrbeLl1k3vhP56tjOg4zf
 eXmjfm8LJcZ1IC4qiKLAhxaSNhQNjAo3ZYl0DN7mr7XGiDRRC9iqg7TBKnlM+B81Ye3q
 I11JENFmHVRytGegrm1xzQL6P1G2VC8+BN3BnpW1JbsP7nquxDI170PcRRQ8ZxAAKcoi
 ql3g==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:sender:subject:to:cc:references:from:message-id
 :date:user-agent:mime-version:in-reply-to:content-language
 :content-transfer-encoding;
 bh=i9kTuyLJOcwVnnK1Hqcz7peiUKoz+t+vR5D5al7psK8=;
 b=o+aK4/JFXz0s59xx6xPvTJ9xsPjBVSYv/ZKAkPhOLzjZ9jtNyTFT2N7xJuAkV00rDS
 l4+pziniiurgRG97pllo06bXIgQng1/YITHegj+SkiI8Uvb/ox6N02fVZrUuP6pdP5KM
 0ha8Hjfvz5gSnXUF4AgCwhr6BIp3nvaI9OExvLqy8I5iDW9FEFVkEwBsDD4oQv3pkLQJ
 YYBSNZYuRml0tyhrfGUIO0ctijrur/oxAsfkl11rgj/YFd0ZLlbWuNlA6tr6hl/xu9c5
 K9aEWaYsyH3YNyWH4yyZ495FvxXoesOOhMI4U9R/o6kSdfpYMk6OEJMMpfcmfnbXYcu+
 NLbg==
X-Gm-Message-State: AOAM532GlXyGRatW5uCoOGDUOTdJUrCNcjRcImgjeSdfxiEz0QI6P3Bz
 LHEeJpEq5urjl/Dv8VoFTLcinEeMoIg=
X-Google-Smtp-Source: ABdhPJzkZPP1+m7M0Dk2UDNY1l2F9yoTJHSG5CCKvdUPJBXWwRHytJmPyrIzb8lB3r7PynoeBhNhuQ==
X-Received: by 2002:adf:fe01:: with SMTP id n1mr14087521wrr.341.1615034693325; 
 Sat, 06 Mar 2021 04:44:53 -0800 (PST)
Received: from [192.168.0.6] ([46.251.119.176])
 by smtp.googlemail.com with ESMTPSA id p6sm8642862wru.2.2021.03.06.04.44.49
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Sat, 06 Mar 2021 04:44:53 -0800 (PST)
Subject: Re: bug#46859: 28.0.50; [PATCH]: Add option to truncate long lines in
 xref.el
To: Gregory Heytings <gregory@HIDDEN>
References: <m25z2azjxp.fsf@HIDDEN> <87im69uzlt.fsf@HIDDEN>
 <m2wnup9s2y.fsf@HIDDEN> <878s74fv27.fsf@HIDDEN>
 <4119ea3055ef8f306fc0@HIDDEN>
 <d52c0f52-8c8b-0688-e735-c8eacf4ebcdb@HIDDEN>
 <4119ea30557ef84ca190@HIDDEN>
 <7eb7ee0f-7dba-c90d-cb58-af42c3828643@HIDDEN>
 <4119ea30554b406efbbf@HIDDEN> <4119ea30558f1e4145b0@HIDDEN>
 <ae221795-5197-36c5-4e0e-e1cb97e2a076@HIDDEN>
 <4119ea30555e80bdcf7e@HIDDEN>
 <1c82e582-8b90-f3c5-5391-1e88ca4e7ab2@HIDDEN>
 <4119ea30553e3f90ab8c@HIDDEN>
 <08b51962-6305-5188-0bea-b17b4139646c@HIDDEN>
 <4119ea3055bd6f6d2e91@HIDDEN>
From: Dmitry Gutov <dgutov@HIDDEN>
Message-ID: <b8474b14-fe69-9b72-a939-6f89a79fb3e9@HIDDEN>
Date: Sat, 6 Mar 2021 14:44:45 +0200
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
 Thunderbird/68.10.0
MIME-Version: 1.0
In-Reply-To: <4119ea3055bd6f6d2e91@HIDDEN>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 7bit
X-Spam-Score: 0.5 (/)
X-Debbugs-Envelope-To: 46859
Cc: 46859 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.5 (/)

On 03.03.2021 23:06, Gregory Heytings wrote:
> 
>>
>> With your approach we'll have to deal with interpreting Grep outputs 
>> which list every line in the searched files. This will almost 
>> certainly be slower in the case when there are only handful of 
>> matches. But benchmarks welcome.
>>
> 
> I don't know what you exactly need (I don't (yet?) use project), so I 
> can't elaborate further or provide benchmarks alas.

The same code is also used in the default implementation of 
xref-find-references, in case you ever tried it.

> Could you perhaps tell me what you need?

We are discussing changes to xref.el, because project-find-regexp 
delegates a lot of its logic to it.

Check out xref-matches-in-files and xref--convert-hits which it calls at 
the end. What you're thinking of seems to require a Grep-specific 
version of xref--convert-hits logic, which in the end constructs 
specialized xref items with a new type of location (alternative to 
xref-file-location).




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#46859; Package emacs. Full text available.

Message received at 46859 <at> debbugs.gnu.org:


Received: (at 46859) by debbugs.gnu.org; 6 Mar 2021 12:39:47 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Mar 06 07:39:47 2021
Received: from localhost ([127.0.0.1]:36200 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lIWDi-0006AL-T8
	for submit <at> debbugs.gnu.org; Sat, 06 Mar 2021 07:39:47 -0500
Received: from mail-wr1-f48.google.com ([209.85.221.48]:36583)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <raaahh@HIDDEN>) id 1lIWDg-0006A5-Hl
 for 46859 <at> debbugs.gnu.org; Sat, 06 Mar 2021 07:39:44 -0500
Received: by mail-wr1-f48.google.com with SMTP id u14so5471011wri.3
 for <46859 <at> debbugs.gnu.org>; Sat, 06 Mar 2021 04:39:44 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=sender:subject:to:cc:references:from:message-id:date:user-agent
 :mime-version:in-reply-to:content-language:content-transfer-encoding;
 bh=yqpicjki1r5ANV1oj4wU87vuGCj8TDUnTmagDg0PUPo=;
 b=eYQA5rLRUoyzwj9/6P+GvcyeGuuuHjOkhI7eJmbmgJoQDKq1fHLIYXUtDSCwInFoOC
 LDuIiIIVJJF0W3FybYILzurpGbjaMJzgAkFXNveVLeaZhJuEg4zWAUI80LuGz/up7Z+t
 MgvM8k8iAJ/67hnDAJFb+AZhWU3ef1jaiqdBw7QwVf/Lb17G1chDqrbAdXAZmRh0Z665
 TfcaYy4lim5yOfv8mH6NEVWc3yUwjPHZNkDYwAVJcJvFLwGIGAKU1/xgbjdUoRpnISyO
 IzExJ6Z+AVzVzUFVHh/ZjxfDvpkhJ1Y2WRY0fsVQAXGG+iYAKj7qgDIhQYrbv49vrPOt
 WzCQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:sender:subject:to:cc:references:from:message-id
 :date:user-agent:mime-version:in-reply-to:content-language
 :content-transfer-encoding;
 bh=yqpicjki1r5ANV1oj4wU87vuGCj8TDUnTmagDg0PUPo=;
 b=cnLfXfagMxErGswrf/VmfNM9j8J/Q3VUGGCWnn16LRLnPBnDOinRko1LbjSExf4XD3
 tLnVERTDGae5r981R4wLyuDShnfy1PR45XXE85myODtLjVorWesfNxjmO5BYiP6kkjDb
 yw1HPI5ezXVOMxHlU6s0Cv6dPLyv2D3WRswnVadqsQ/hTXJCBhsOMMUbA+K4PEbj+vWI
 sou8SRB14tJx+VV/Np0bYd+9hADD+WHXXZVEVDNL3QJHVHm6ba7HckEbfwBI6UTsCwSz
 iYoGhIVaA4ll40DvVL1Pz98gt8P21Apo5QE4Zz7bZD6vqVi65aIBaIc0rfgceugVg2mi
 5XZw==
X-Gm-Message-State: AOAM532jEZ4Oqpzra8EugDNL5EwJqm4z17M1gx91ROblfW+evYGiPVzU
 CT8M3EXRk4yXfX3c6uaoHTEWjzMTsiQ=
X-Google-Smtp-Source: ABdhPJwnX4/znO+LTMlnu6M/68FBy7jUxprtCMbm0RP1xS5FkpLHlLRFeHMhYRqohDMIerptFiuXlg==
X-Received: by 2002:a5d:6703:: with SMTP id o3mr13962917wru.357.1615034379008; 
 Sat, 06 Mar 2021 04:39:39 -0800 (PST)
Received: from [192.168.0.6] ([46.251.119.176])
 by smtp.googlemail.com with ESMTPSA id s18sm2208125wrr.27.2021.03.06.04.39.37
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Sat, 06 Mar 2021 04:39:38 -0800 (PST)
Subject: Re: bug#46859: 28.0.50; [PATCH]: Add option to truncate long lines in
 xref.el
To: Juri Linkov <juri@HIDDEN>
References: <m25z2azjxp.fsf@HIDDEN> <87im69uzlt.fsf@HIDDEN>
 <m2wnup9s2y.fsf@HIDDEN> <878s74fv27.fsf@HIDDEN>
 <4119ea3055ef8f306fc0@HIDDEN>
 <d52c0f52-8c8b-0688-e735-c8eacf4ebcdb@HIDDEN>
 <4119ea30557ef84ca190@HIDDEN>
 <7eb7ee0f-7dba-c90d-cb58-af42c3828643@HIDDEN>
 <4119ea30554b406efbbf@HIDDEN> <4119ea30558f1e4145b0@HIDDEN>
 <ae221795-5197-36c5-4e0e-e1cb97e2a076@HIDDEN>
 <4119ea30555e80bdcf7e@HIDDEN>
 <1c82e582-8b90-f3c5-5391-1e88ca4e7ab2@HIDDEN>
 <875z282el0.fsf@HIDDEN>
 <9d87da5b-e30e-149d-a467-a2c4c752a60e@HIDDEN>
 <87czwf9sq9.fsf@HIDDEN>
 <e6e66354-f7a2-68b6-cce3-a9e8fda31288@HIDDEN>
 <87mtviajlf.fsf@HIDDEN>
From: Dmitry Gutov <dgutov@HIDDEN>
Message-ID: <f3ad7bef-e5c9-1f90-ca28-945c215e1e12@HIDDEN>
Date: Sat, 6 Mar 2021 14:39:36 +0200
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
 Thunderbird/68.10.0
MIME-Version: 1.0
In-Reply-To: <87mtviajlf.fsf@HIDDEN>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 7bit
X-Spam-Score: 0.5 (/)
X-Debbugs-Envelope-To: 46859
Cc: Gregory Heytings <gregory@HIDDEN>, 46859 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.5 (/)

On 04.03.2021 19:56, Juri Linkov wrote:
>>> I don't know if extra font-locking is worth worse performance.
>>> But I took this idea for consistency from occur that uses
>>> 'font-lock-ensure' in 'occur-engine-line'.
>> If you're sure you want this behavior, we can make it a user option.
> I'm not sure because most hits are not fontified anyway
> when not all files are visited especially in a large codebase.

Other values for this option for better consistency could mean "strip 
all fontifications" and "make sure to visit every file and fontify every 
line".

I'm not sure anybody would want either of them, though.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#46859; Package emacs. Full text available.

Message received at 46859 <at> debbugs.gnu.org:


Received: (at 46859) by debbugs.gnu.org; 6 Mar 2021 12:37:38 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Mar 06 07:37:38 2021
Received: from localhost ([127.0.0.1]:36196 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lIWBe-000672-HS
	for submit <at> debbugs.gnu.org; Sat, 06 Mar 2021 07:37:38 -0500
Received: from mail-wr1-f54.google.com ([209.85.221.54]:37416)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <raaahh@HIDDEN>) id 1lIWBc-00066o-Ht
 for 46859 <at> debbugs.gnu.org; Sat, 06 Mar 2021 07:37:37 -0500
Received: by mail-wr1-f54.google.com with SMTP id v15so5443823wrx.4
 for <46859 <at> debbugs.gnu.org>; Sat, 06 Mar 2021 04:37:36 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=sender:subject:from:to:cc:references:message-id:date:user-agent
 :mime-version:in-reply-to:content-language:content-transfer-encoding;
 bh=u5pLcM2SWv+vlbB81aPAkFLcDu1WeFU13yMdpAcwhmM=;
 b=hsqsmfjwAu7qeBxwtAycfmZAVFwzS/MiwQZXVHv9rsa3YNE5gWVfpXzsjsEyhHmyBG
 4w9M1y6PRfqyL2bE9JmRLKPg5DP5UZRPT/40LSRRbHREgr/4hbhdaShwCM9EO1wEqUHo
 /vuXMemSGNDx6RnhZYkKwORHymfHI90vkMdWN40Cvhlp4VUEVXts5iM3eOLgZROQvE6X
 NxnmgyLUVQj2pzJfYJIZXfEpLRa7/7qisPT8wmyU1acgCJCGRTTYJJWmgKe7CfdLDd98
 RyVWzajesKyPRSBxxlixz6BBxLV11/M63JJAbqcLZViIVsaea95kUwPzc50+DSO5PTUe
 9ujw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:sender:subject:from:to:cc:references:message-id
 :date:user-agent:mime-version:in-reply-to:content-language
 :content-transfer-encoding;
 bh=u5pLcM2SWv+vlbB81aPAkFLcDu1WeFU13yMdpAcwhmM=;
 b=QRfTITla4MpGVAEZ9BJJPx6IJr0AV/lISDg5Zs62Q6TWbLDJ/2+ChB3/2dGkIs+8Yu
 wjTFty/aVLxoi9d3niFCdS3klXok3abDvuxZSPafwiWInABIYujvACNkhSb9wNszXbGp
 3abFGJ1mDr9hA3qORpFTsUcf1Ii009/kKcf22o3iCH8T5UyIFpDvaJ5tOvyshE0mt1ve
 p71ro7TKaEjQNv9ouz1RZvBvIH9Pan5AJQ7ZvzJPuT3C2t5aePOgYUNQV7ornV0Huuke
 zh6woKO38mKvXAILSDQ9O0I259XbrXzjkyKjkjZzfElmOTCm9GSuY5nkMyaivPqEZzCb
 rGhA==
X-Gm-Message-State: AOAM531xNfxqYynyCPqdbTrM0/U85gNQm5zB0rbtWYfN3svWUAfhzEiA
 BfTUbeSfKFV1Sz3D7m5l0WWfzGbloHg=
X-Google-Smtp-Source: ABdhPJwVNx3tLeE3ahRLqgIBJFJ3U5i3xSgGQkcU9RQTKj8kHEtwewBegwmNVjJ0pttp826pA6BPDg==
X-Received: by 2002:adf:828e:: with SMTP id 14mr14043519wrc.123.1615034250718; 
 Sat, 06 Mar 2021 04:37:30 -0800 (PST)
Received: from [192.168.0.6] ([46.251.119.176])
 by smtp.googlemail.com with ESMTPSA id a21sm9063858wmb.5.2021.03.06.04.37.29
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Sat, 06 Mar 2021 04:37:30 -0800 (PST)
Subject: Re: bug#46859: 28.0.50; [PATCH]: Add option to truncate long lines in
 xref.el
From: Dmitry Gutov <dgutov@HIDDEN>
To: Gregory Heytings <gregory@HIDDEN>, Eli Zaretskii <eliz@HIDDEN>
References: <m25z2azjxp.fsf@HIDDEN> <87im69uzlt.fsf@HIDDEN>
 <m2wnup9s2y.fsf@HIDDEN> <878s74fv27.fsf@HIDDEN>
 <4119ea3055ef8f306fc0@HIDDEN>
 <d52c0f52-8c8b-0688-e735-c8eacf4ebcdb@HIDDEN>
 <4119ea30557ef84ca190@HIDDEN>
 <7eb7ee0f-7dba-c90d-cb58-af42c3828643@HIDDEN>
 <4119ea30554b406efbbf@HIDDEN> <4119ea30558f1e4145b0@HIDDEN>
 <ae221795-5197-36c5-4e0e-e1cb97e2a076@HIDDEN>
 <4119ea30555e80bdcf7e@HIDDEN>
 <1c82e582-8b90-f3c5-5391-1e88ca4e7ab2@HIDDEN>
 <4119ea30553e3f90ab8c@HIDDEN> <87y2f42ex5.fsf@HIDDEN>
 <4119ea30552873ab9870@HIDDEN> <83eegvk2u0.fsf@HIDDEN>
 <9cff0f8894658f3b50c8@HIDDEN> <83y2f3huz2.fsf@HIDDEN>
 <9cff0f88942d4103c685@HIDDEN> <83mtvjhrzj.fsf@HIDDEN>
 <9cff0f889435d8d03313@HIDDEN> <834khq266r.fsf@HIDDEN>
 <9cff0f8894ab45713d12@HIDDEN>
 <16ac41d4-5718-0cec-a68b-4abcc736ee4a@HIDDEN>
Message-ID: <109276c6-30fb-b1ca-cafa-48a15710099b@HIDDEN>
Date: Sat, 6 Mar 2021 14:37:26 +0200
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
 Thunderbird/68.10.0
MIME-Version: 1.0
In-Reply-To: <16ac41d4-5718-0cec-a68b-4abcc736ee4a@HIDDEN>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 7bit
X-Spam-Score: 0.5 (/)
X-Debbugs-Envelope-To: 46859
Cc: 46859 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.5 (/)

On 06.03.2021 14:31, Dmitry Gutov wrote:
> Otherwise it would be possible to use this approach (by introducing a 
> Grep-specific location type) and avoid parsing the line contents for 
> every match.

Except, um, we still need to fill in the "summary" attribute for all 
matches, so that there is something to display in the Xref buffer (the 
line contents around the match), and the -o flag strips those.

And if we were to use the '.{0,100}file.{0,100}' trick, it messes up the 
location of the match, the reported byte offset become unreliable. Also: 
grepping for that kind of regexp is noticeably slower than grepping for 
'file'. Or even '.file'. Like 85ms vs 7ms slower.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#46859; Package emacs. Full text available.

Message received at 46859 <at> debbugs.gnu.org:


Received: (at 46859) by debbugs.gnu.org; 6 Mar 2021 12:31:45 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Mar 06 07:31:45 2021
Received: from localhost ([127.0.0.1]:36178 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lIW5x-0005FP-66
	for submit <at> debbugs.gnu.org; Sat, 06 Mar 2021 07:31:45 -0500
Received: from mail-ej1-f49.google.com ([209.85.218.49]:45125)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <raaahh@HIDDEN>) id 1lIW5v-00059l-Kk
 for 46859 <at> debbugs.gnu.org; Sat, 06 Mar 2021 07:31:43 -0500
Received: by mail-ej1-f49.google.com with SMTP id mm21so9239123ejb.12
 for <46859 <at> debbugs.gnu.org>; Sat, 06 Mar 2021 04:31:43 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=sender:subject:to:cc:references:from:message-id:date:user-agent
 :mime-version:in-reply-to:content-language:content-transfer-encoding;
 bh=1SHtJ/Q6HIVrXDL8u00aifpy5xzQIR8aJcVP5NOF4Ec=;
 b=oRkHaiUynm1tqyjLmOcsXr1Qf6BqayepDyv7XQ2eJkdj/d/vW8SZzlEy3BFUCV2WaJ
 4u5uHq3O0oM0XIhamCaJ9urRCEe6KNNf4AczX+TeXbKl+Sme2RwrIhQzRTL/tGCVQ31t
 lZ1FEEajA1yY2Wr98d7w1vh4Sj9PZIFB707Kp4kdE47Z8lxD+Gte9gulcwbyqlB+3L5k
 KaGcUmDbajEl8GtDv4+6DLoenQBD4h5mRF1KOL05A3i0QwweBCc9xuaUJ+xDKZxTeUUY
 SpJ1SmOuHG+y8P5CKwuBbxSQxEP7DKOR2T5nIV6DCPPlR4/Ao0BNMfoCI1bnSP1G27j6
 3msQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:sender:subject:to:cc:references:from:message-id
 :date:user-agent:mime-version:in-reply-to:content-language
 :content-transfer-encoding;
 bh=1SHtJ/Q6HIVrXDL8u00aifpy5xzQIR8aJcVP5NOF4Ec=;
 b=er9tCF74GIS+84dujNE/KJLi25Cy7DbruUswjZWHROAcE9Vkmf78jnX/Hmiu72Wdnc
 gCaEpoKSPtMlPUrMWP6ZIZFboaziTKuEJBWxuByaQg3SGQvfZl/c7Nxhrta1/toaJFfL
 we5J2NjOU9wnNYoWjQdjnJ3ujHEPvkSmf/26rgJNgce36Ma53iXTVHJM8l2aVL9KjAjv
 VxCsoyfDkBdfva3tdFVpAohW5J2T7cer7nRkiHDbxPojIllKa1MjMEDTlqpWbHBx1b+m
 SsnLnlc5/TEYQEeWWyksUORQVUHqB+Ni0Ys7HnnDDXUJjS0Y+r475n0Ke/OZM9ojYUXo
 j9Hg==
X-Gm-Message-State: AOAM5321xbL/Rf26OSxFlMWXktCuG18su2EInJzV38XIZeF+ECuLg2Yn
 u/3MFySuZnlMm0yewkQaAQMSkRla6xw=
X-Google-Smtp-Source: ABdhPJzNsSV7OocwhZAsSa9zjhvab4VVuGkmKLBBS+kG+M0hj1soHyxC2xCzmWI8CuL+TSYszncACQ==
X-Received: by 2002:a17:906:dfce:: with SMTP id
 jt14mr6797325ejc.83.1615033897863; 
 Sat, 06 Mar 2021 04:31:37 -0800 (PST)
Received: from [192.168.0.6] ([46.251.119.176])
 by smtp.googlemail.com with ESMTPSA id f3sm3250948ejd.42.2021.03.06.04.31.33
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Sat, 06 Mar 2021 04:31:37 -0800 (PST)
Subject: Re: bug#46859: 28.0.50; [PATCH]: Add option to truncate long lines in
 xref.el
To: Gregory Heytings <gregory@HIDDEN>, Eli Zaretskii <eliz@HIDDEN>
References: <m25z2azjxp.fsf@HIDDEN> <87im69uzlt.fsf@HIDDEN>
 <m2wnup9s2y.fsf@HIDDEN> <878s74fv27.fsf@HIDDEN>
 <4119ea3055ef8f306fc0@HIDDEN>
 <d52c0f52-8c8b-0688-e735-c8eacf4ebcdb@HIDDEN>
 <4119ea30557ef84ca190@HIDDEN>
 <7eb7ee0f-7dba-c90d-cb58-af42c3828643@HIDDEN>
 <4119ea30554b406efbbf@HIDDEN> <4119ea30558f1e4145b0@HIDDEN>
 <ae221795-5197-36c5-4e0e-e1cb97e2a076@HIDDEN>
 <4119ea30555e80bdcf7e@HIDDEN>
 <1c82e582-8b90-f3c5-5391-1e88ca4e7ab2@HIDDEN>
 <4119ea30553e3f90ab8c@HIDDEN> <87y2f42ex5.fsf@HIDDEN>
 <4119ea30552873ab9870@HIDDEN> <83eegvk2u0.fsf@HIDDEN>
 <9cff0f8894658f3b50c8@HIDDEN> <83y2f3huz2.fsf@HIDDEN>
 <9cff0f88942d4103c685@HIDDEN> <83mtvjhrzj.fsf@HIDDEN>
 <9cff0f889435d8d03313@HIDDEN> <834khq266r.fsf@HIDDEN>
 <9cff0f8894ab45713d12@HIDDEN>
From: Dmitry Gutov <dgutov@HIDDEN>
Message-ID: <16ac41d4-5718-0cec-a68b-4abcc736ee4a@HIDDEN>
Date: Sat, 6 Mar 2021 14:31:28 +0200
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
 Thunderbird/68.10.0
MIME-Version: 1.0
In-Reply-To: <9cff0f8894ab45713d12@HIDDEN>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 7bit
X-Spam-Score: 0.5 (/)
X-Debbugs-Envelope-To: 46859
Cc: 46859 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.5 (/)

On 04.03.2021 19:35, Gregory Heytings wrote:
> Just tried 'exact, it works, it's slow (but not horribly slow: 1.2 
> seconds on that 25 MB file)

1.2s is pretty slow for this purpose.

Otherwise it would be possible to use this approach (by introducing a 
Grep-specific location type) and avoid parsing the line contents for 
every match.

One downside would be missing on the syntax highlighting which we 
sometimes get for already-fontified parts of buffers, but it's 
unreliable anyway.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#46859; Package emacs. Full text available.

Message received at 46859 <at> debbugs.gnu.org:


Received: (at 46859) by debbugs.gnu.org; 4 Mar 2021 18:58:01 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Mar 04 13:58:01 2021
Received: from localhost ([127.0.0.1]:60240 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lHtAf-0004lH-C2
	for submit <at> debbugs.gnu.org; Thu, 04 Mar 2021 13:58:01 -0500
Received: from mail-wm1-f53.google.com ([209.85.128.53]:37631)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <raaahh@HIDDEN>) id 1lHtAb-0004l2-BT
 for 46859 <at> debbugs.gnu.org; Thu, 04 Mar 2021 13:57:59 -0500
Received: by mail-wm1-f53.google.com with SMTP id m1so10716727wml.2
 for <46859 <at> debbugs.gnu.org>; Thu, 04 Mar 2021 10:57:57 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=sender:subject:to:cc:references:from:message-id:date:user-agent
 :mime-version:in-reply-to:content-language:content-transfer-encoding;
 bh=XihY01nJqBrnFUvr1iVd64M7+xHJ37AZNnm12AkE76g=;
 b=S485ZzA78RbJbAvh5pFz1BgoKz57i8BL1Gaxl+aq+mfe3Nqwq4LoKOLeBB0GP4rcjj
 GL8EWwUEIs/qgxF5PPlJ1JFuk9pNVyg6pQrkQ2XuSLhNzb0wh71DcmXkenIdyaUiOBTs
 fjlT/25EarUzQPw7xRcyTmaSaPCtP4dh0oimPlrTcaKJ8FfsBEn+ALPDd1nJSFqtEq4b
 JrZTTDj7c4b7tzGxfkbEpRIrfL3dCkEG37MO3txAKTkx5LSjPB58D8ZVTXVPKAowcVr5
 xpWjwAk8KHmuGrj06sI5sSnhSF1MPJSb6OTXCFH36zzt0pPfpkGtdISRkJ/W7ReiIJCd
 6+Qg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:sender:subject:to:cc:references:from:message-id
 :date:user-agent:mime-version:in-reply-to:content-language
 :content-transfer-encoding;
 bh=XihY01nJqBrnFUvr1iVd64M7+xHJ37AZNnm12AkE76g=;
 b=ZZAP9oon/ZIKMQNtdQqI+qOxSvwsxaNx3Q0UTcTZTE+ymZMahzjUQjIUrugueyTqDQ
 hylUktSQHTB4XMzB3j1e5RdHPtlOPisfI8fQhe2mU95nMRI0kSk7T42HWC4yY7yf4Roy
 rPSssmOQK6QMjeh3/RTM3KpnrsdWADVjmjK6BNOTmQ1APDnVwyMg8SPbJQfVrnb+rlSB
 lhCUN/bvGGSwL2E6GbKasH3jkMHedSrnMRAX4bJjRWl/zVr0dcUYr+9rImkFJ5/Qc07V
 b7f4SxEvhAHF7qaLtIXadPpdqG74NxjaahJ1lNBYaQHt7LqMGRGX4tGY3Okhr58GotDi
 mGSQ==
X-Gm-Message-State: AOAM530MT3UufganDA5A/mmYyVf4QbxEv4U53u3//yCIqiZWq98+8YkI
 ttMkgajEoD+93KF8jnCHJloW0ry26FI=
X-Google-Smtp-Source: ABdhPJyuKJjZVOC92iONk2ZwQRk7C8fhpydxo+vLT3TheqFJuJWy+J5xFEzqikridW5xowCfJ+wamg==
X-Received: by 2002:a1c:a958:: with SMTP id s85mr5524580wme.4.1614884271344;
 Thu, 04 Mar 2021 10:57:51 -0800 (PST)
Received: from [192.168.0.6] ([46.251.119.176])
 by smtp.googlemail.com with ESMTPSA id o3sm445543wmq.46.2021.03.04.10.57.49
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Thu, 04 Mar 2021 10:57:50 -0800 (PST)
Subject: Re: bug#46859: 28.0.50; [PATCH]: Add option to truncate long lines in
 xref.el
To: Juri Linkov <juri@HIDDEN>
References: <m25z2azjxp.fsf@HIDDEN> <87im69uzlt.fsf@HIDDEN>
 <m2wnup9s2y.fsf@HIDDEN> <878s74fv27.fsf@HIDDEN>
 <4119ea3055ef8f306fc0@HIDDEN>
 <d52c0f52-8c8b-0688-e735-c8eacf4ebcdb@HIDDEN>
 <4119ea30557ef84ca190@HIDDEN>
 <7eb7ee0f-7dba-c90d-cb58-af42c3828643@HIDDEN>
 <4119ea30554b406efbbf@HIDDEN> <4119ea30558f1e4145b0@HIDDEN>
 <ae221795-5197-36c5-4e0e-e1cb97e2a076@HIDDEN>
 <4119ea30555e80bdcf7e@HIDDEN>
 <1c82e582-8b90-f3c5-5391-1e88ca4e7ab2@HIDDEN>
 <875z282el0.fsf@HIDDEN>
 <9d87da5b-e30e-149d-a467-a2c4c752a60e@HIDDEN>
 <87czwf9sq9.fsf@HIDDEN>
 <e6e66354-f7a2-68b6-cce3-a9e8fda31288@HIDDEN>
 <87mtviajlf.fsf@HIDDEN>
From: Dmitry Gutov <dgutov@HIDDEN>
Message-ID: <c1ed425c-c729-d708-1c53-34270bfc537e@HIDDEN>
Date: Thu, 4 Mar 2021 20:57:48 +0200
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
 Thunderbird/68.10.0
MIME-Version: 1.0
In-Reply-To: <87mtviajlf.fsf@HIDDEN>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 7bit
X-Spam-Score: 0.5 (/)
X-Debbugs-Envelope-To: 46859
Cc: Gregory Heytings <gregory@HIDDEN>, 46859 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.5 (/)

On 04.03.2021 19:56, Juri Linkov wrote:
> I'm not sure because most hits are not fontified anyway
> when not all files are visited especially in a large codebase.

Yes, so highlighting won't be universal anyway.

OTOH, if we have a long file which is visited somewhere near the 
beginning, and there are a lot of hits inside, font-lock-ensure can 
create some noticeable overhead.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#46859; Package emacs. Full text available.

Message received at 46859 <at> debbugs.gnu.org:


Received: (at 46859) by debbugs.gnu.org; 4 Mar 2021 18:44:40 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Mar 04 13:44:40 2021
Received: from localhost ([127.0.0.1]:60222 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lHsxk-0004RE-ET
	for submit <at> debbugs.gnu.org; Thu, 04 Mar 2021 13:44:40 -0500
Received: from relay2-d.mail.gandi.net ([217.70.183.194]:53787)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <juri@HIDDEN>) id 1lHsxi-0004Qc-9H
 for 46859 <at> debbugs.gnu.org; Thu, 04 Mar 2021 13:44:38 -0500
X-Originating-IP: 91.129.96.116
Received: from mail.gandi.net (m91-129-96-116.cust.tele2.ee [91.129.96.116])
 (Authenticated sender: juri@HIDDEN)
 by relay2-d.mail.gandi.net (Postfix) with ESMTPSA id 7BC6A4000D;
 Thu,  4 Mar 2021 18:44:30 +0000 (UTC)
From: Juri Linkov <juri@HIDDEN>
To: Dmitry Gutov <dgutov@HIDDEN>
Subject: Re: bug#46859: 28.0.50; [PATCH]: Add option to truncate long lines
 in xref.el
Organization: LINKOV.NET
References: <m25z2azjxp.fsf@HIDDEN> <87im69uzlt.fsf@HIDDEN>
 <m2wnup9s2y.fsf@HIDDEN> <878s74fv27.fsf@HIDDEN>
 <4119ea3055ef8f306fc0@HIDDEN>
 <d52c0f52-8c8b-0688-e735-c8eacf4ebcdb@HIDDEN>
 <4119ea30557ef84ca190@HIDDEN>
 <7eb7ee0f-7dba-c90d-cb58-af42c3828643@HIDDEN>
 <4119ea30554b406efbbf@HIDDEN>
 <4119ea30558f1e4145b0@HIDDEN>
 <ae221795-5197-36c5-4e0e-e1cb97e2a076@HIDDEN>
 <4119ea30555e80bdcf7e@HIDDEN>
 <1c82e582-8b90-f3c5-5391-1e88ca4e7ab2@HIDDEN>
 <875z282el0.fsf@HIDDEN>
 <9d87da5b-e30e-149d-a467-a2c4c752a60e@HIDDEN>
 <87czwf9sq9.fsf@HIDDEN>
 <e6e66354-f7a2-68b6-cce3-a9e8fda31288@HIDDEN>
Date: Thu, 04 Mar 2021 19:56:28 +0200
In-Reply-To: <e6e66354-f7a2-68b6-cce3-a9e8fda31288@HIDDEN> (Dmitry Gutov's
 message of "Thu, 4 Mar 2021 19:20:32 +0200")
Message-ID: <87mtviajlf.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 46859
Cc: Gregory Heytings <gregory@HIDDEN>, 46859 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)

>> I don't know if extra font-locking is worth worse performance.
>> But I took this idea for consistency from occur that uses
>> 'font-lock-ensure' in 'occur-engine-line'.
>
> If you're sure you want this behavior, we can make it a user option.

I'm not sure because most hits are not fontified anyway
when not all files are visited especially in a large codebase.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#46859; Package emacs. Full text available.

Message received at 46859 <at> debbugs.gnu.org:


Received: (at 46859) by debbugs.gnu.org; 4 Mar 2021 18:29:03 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Mar 04 13:29:03 2021
Received: from localhost ([127.0.0.1]:60188 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lHsid-00042k-4n
	for submit <at> debbugs.gnu.org; Thu, 04 Mar 2021 13:29:03 -0500
Received: from eggs.gnu.org ([209.51.188.92]:44702)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1lHsia-00042G-55
 for 46859 <at> debbugs.gnu.org; Thu, 04 Mar 2021 13:29:01 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e]:38496)
 by eggs.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <eliz@HIDDEN>)
 id 1lHsiT-0000sB-AL; Thu, 04 Mar 2021 13:28:54 -0500
Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:3993
 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256)
 (Exim 4.82) (envelope-from <eliz@HIDDEN>)
 id 1lHsiR-00039n-IL; Thu, 04 Mar 2021 13:28:52 -0500
Date: Thu, 04 Mar 2021 20:28:32 +0200
Message-Id: <83zgzizsbz.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Gregory Heytings <gregory@HIDDEN>
In-Reply-To: <9cff0f8894ab45713d12@HIDDEN> (message from Gregory
 Heytings on Thu, 04 Mar 2021 17:35:42 +0000)
Subject: Re: bug#46859: 28.0.50; [PATCH]: Add option to truncate long lines
 in xref.el
References: <m25z2azjxp.fsf@HIDDEN> <87im69uzlt.fsf@HIDDEN>
 <m2wnup9s2y.fsf@HIDDEN> <878s74fv27.fsf@HIDDEN>
 <4119ea3055ef8f306fc0@HIDDEN>
 <d52c0f52-8c8b-0688-e735-c8eacf4ebcdb@HIDDEN>
 <4119ea30557ef84ca190@HIDDEN>
 <7eb7ee0f-7dba-c90d-cb58-af42c3828643@HIDDEN>
 <4119ea30554b406efbbf@HIDDEN> <4119ea30558f1e4145b0@HIDDEN>
 <ae221795-5197-36c5-4e0e-e1cb97e2a076@HIDDEN>
 <4119ea30555e80bdcf7e@HIDDEN>
 <1c82e582-8b90-f3c5-5391-1e88ca4e7ab2@HIDDEN>
 <4119ea30553e3f90ab8c@HIDDEN> <87y2f42ex5.fsf@HIDDEN>
 <4119ea30552873ab9870@HIDDEN> <83eegvk2u0.fsf@HIDDEN>
 <9cff0f8894658f3b50c8@HIDDEN> <83y2f3huz2.fsf@HIDDEN>
 <9cff0f88942d4103c685@HIDDEN> <83mtvjhrzj.fsf@HIDDEN>
 <9cff0f889435d8d03313@HIDDEN> <834khq266r.fsf@HIDDEN>
 <9cff0f8894ab45713d12@HIDDEN>
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 46859
Cc: 46859 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)

> Date: Thu, 04 Mar 2021 17:35:42 +0000
> From: Gregory Heytings <gregory@HIDDEN>
> cc: 46859 <at> debbugs.gnu.org
> 
> > Not 'best, 'exact.  Did you try 'exact?  It should have worked, barring 
> > any bugs.
> 
> Sorry for mixing things up.  Just tried 'exact, it works, it's slow (but 
> not horribly slow: 1.2 seconds on that 25 MB file), but it doesn't give 
> the correct answer alas, it's about ~1000 characters away from the correct 
> position.

Sounds like a bug, I'd appreciate a bug report with the details
(including the file, if you can share it).

Thanks.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#46859; Package emacs. Full text available.

Message received at 46859 <at> debbugs.gnu.org:


Received: (at 46859) by debbugs.gnu.org; 4 Mar 2021 17:35:47 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Mar 04 12:35:47 2021
Received: from localhost ([127.0.0.1]:60090 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lHrt4-0002jK-Ci
	for submit <at> debbugs.gnu.org; Thu, 04 Mar 2021 12:35:47 -0500
Received: from heytings.org ([95.142.160.155]:43156)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <gregory@HIDDEN>) id 1lHrt2-0002jA-20
 for 46859 <at> debbugs.gnu.org; Thu, 04 Mar 2021 12:35:45 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=heytings.org;
 s=20210101; t=1614879342;
 bh=L1fJEMwGDYo8svqrGEfunJIJowbFsPgkIIVUuDwmzGU=;
 h=Date:From:To:cc:Subject:In-Reply-To:Message-ID:References:From;
 b=WKLdv39ykaUjzVj35Hh3XyrdgQ0YwBVdATEsOJNGCsOVIYyuJux9q75LO7brC6+VL
 LZkKxhYkIhDSAZUwKvIHCz1BOP8wy/rKCS6gveZvmpFrxvcgh/yhHEOliwnQl6x0y+
 fJ+sfFMPr1dOwYEKPq3N3jbopKnTKsAahe1F9EIuysTjTtAFL4l8e06Bo2Vr2r99EM
 /tx0NZOVPunhBuRVODrqwQmGv9oI7GVvwye2NEzr6eCvQn0KETgMLGfV2Be1xGzVJM
 c8DVpuElFQnM8wUmikXYxDOLPRPCs92VdiMvuF79c4MnPS/wS7TPqHTC1RbYDcBjDM
 xaaP7p1zAVXww==
Date: Thu, 04 Mar 2021 17:35:42 +0000
From: Gregory Heytings <gregory@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#46859: 28.0.50; [PATCH]: Add option to truncate long lines
 in xref.el
In-Reply-To: <834khq266r.fsf@HIDDEN>
Message-ID: <9cff0f8894ab45713d12@HIDDEN>
References: <m25z2azjxp.fsf@HIDDEN> <87im69uzlt.fsf@HIDDEN>
 <m2wnup9s2y.fsf@HIDDEN> <878s74fv27.fsf@HIDDEN>
 <4119ea3055ef8f306fc0@HIDDEN>
 <d52c0f52-8c8b-0688-e735-c8eacf4ebcdb@HIDDEN>
 <4119ea30557ef84ca190@HIDDEN>
 <7eb7ee0f-7dba-c90d-cb58-af42c3828643@HIDDEN>
 <4119ea30554b406efbbf@HIDDEN> <4119ea30558f1e4145b0@HIDDEN>
 <ae221795-5197-36c5-4e0e-e1cb97e2a076@HIDDEN>
 <4119ea30555e80bdcf7e@HIDDEN>
 <1c82e582-8b90-f3c5-5391-1e88ca4e7ab2@HIDDEN>
 <4119ea30553e3f90ab8c@HIDDEN> <87y2f42ex5.fsf@HIDDEN>
 <4119ea30552873ab9870@HIDDEN> <83eegvk2u0.fsf@HIDDEN>
 <9cff0f8894658f3b50c8@HIDDEN> <83y2f3huz2.fsf@HIDDEN>
 <9cff0f88942d4103c685@HIDDEN> <83mtvjhrzj.fsf@HIDDEN>
 <9cff0f889435d8d03313@HIDDEN> <834khq266r.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; format=flowed; charset=us-ascii
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 46859
Cc: 46859 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)


>> I don't know anything about ISO-2022, but tried with a 25 MB file, 
>> created with iconv, which Emacs recognizes as an iso-2022-7bit-dos one. 
>> In that case filepos-to-bufferpos does not work at all, with 
>> 'approximate you get a position that is about 2 million characters away 
>> from the correct one, and with 'best or nil you get nil...
>
> Not 'best, 'exact.  Did you try 'exact?  It should have worked, barring 
> any bugs.
>

Sorry for mixing things up.  Just tried 'exact, it works, it's slow (but 
not horribly slow: 1.2 seconds on that 25 MB file), but it doesn't give 
the correct answer alas, it's about ~1000 characters away from the correct 
position.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#46859; Package emacs. Full text available.

Message received at 46859 <at> debbugs.gnu.org:


Received: (at 46859) by debbugs.gnu.org; 4 Mar 2021 17:20:44 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Mar 04 12:20:44 2021
Received: from localhost ([127.0.0.1]:60073 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lHreW-0002LD-Aa
	for submit <at> debbugs.gnu.org; Thu, 04 Mar 2021 12:20:44 -0500
Received: from mail-wm1-f53.google.com ([209.85.128.53]:40637)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <raaahh@HIDDEN>) id 1lHreT-0002Kl-Pv
 for 46859 <at> debbugs.gnu.org; Thu, 04 Mar 2021 12:20:43 -0500
Received: by mail-wm1-f53.google.com with SMTP id o2so9934888wme.5
 for <46859 <at> debbugs.gnu.org>; Thu, 04 Mar 2021 09:20:41 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=sender:subject:to:cc:references:from:message-id:date:user-agent
 :mime-version:in-reply-to:content-language:content-transfer-encoding;
 bh=cb0VyegjtcF63aVgMLeVrj3R/MLdB2alG/Sl7CEEHuQ=;
 b=TohaYDLQuJIsiSxNQmdTe2Oig6q/JgZRXJg/AFqcF1Df6XnniAXRSpBlefW+3tDC7g
 f2S1rtg88M39psLAkDvMI+YhFQuVU+o1CzVtst3XZk6RllYos5BsZVicWZegazul9MxT
 CPZ6ZmDu0DqdT+PF1XeY9FkgMuOIQh/9638EAKPgoGc54g3H7zscKK204Z7eRaxlmdFS
 EDGrIjSLhRZYignDKSQ4xyYmZwhOEFef1idibmZJGty/JbNCWRBdb0+c3UZF6hCqWuGp
 BMutag5l3uA/zNBt9yohMCL3Ag8eqJj+JEBVaWvp2F4em6yK6YqL/4mC+YugYtcKWBOH
 xXkA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:sender:subject:to:cc:references:from:message-id
 :date:user-agent:mime-version:in-reply-to:content-language
 :content-transfer-encoding;
 bh=cb0VyegjtcF63aVgMLeVrj3R/MLdB2alG/Sl7CEEHuQ=;
 b=pxVEi3bfpaOAiBwR9yv9zru9OhvULtkFRK//laJXyBZbITIfRKr9WsxwwpZlZaSwHS
 /5PzUv5RHSUvaLUVNXtRbo0J3EJLEfnopFPZ81QPrnRpFzNdov580upAftFp/NoDF0ib
 qrjEWpjjZpqYDH8g89ipffyZuqTn5CCv8BT5ysIDjYTm0Sa5hyFntj+ILkmliCXNrZMe
 s5NOCPF2l7KNnP+7Gw6AqAdPP0GeOkmK84GcVFTm1dXOPewgBcjv2UGx8sYhdDaCoGuB
 zKFkSFXzzAWD6sdRrUoz5d2iFQkwwU6OrukLM9VwVQPM2utqRwaDw+Jc701UWtR8SuOL
 XolQ==
X-Gm-Message-State: AOAM531NsqG5fX5Tl5yrXBEyS2XCnGLr0uiLoW2lNzSdhDIjbMUEp1Tj
 75ErN1NykQJ8DljmYQ9VNKHzL+umYjU=
X-Google-Smtp-Source: ABdhPJzTKu6WAr/uVY8Sg71tGcD1lWCIYPqpjGnTs2uAOo8lfKd1PqeIU2FGJ0M2/EmqW/H66c+AiQ==
X-Received: by 2002:a1c:a7d3:: with SMTP id q202mr4927113wme.93.1614878436224; 
 Thu, 04 Mar 2021 09:20:36 -0800 (PST)
Received: from [192.168.0.6] ([46.251.119.176])
 by smtp.googlemail.com with ESMTPSA id s3sm18173800wrt.93.2021.03.04.09.20.34
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Thu, 04 Mar 2021 09:20:35 -0800 (PST)
Subject: Re: bug#46859: 28.0.50; [PATCH]: Add option to truncate long lines in
 xref.el
To: Juri Linkov <juri@HIDDEN>
References: <m25z2azjxp.fsf@HIDDEN> <87im69uzlt.fsf@HIDDEN>
 <m2wnup9s2y.fsf@HIDDEN> <878s74fv27.fsf@HIDDEN>
 <4119ea3055ef8f306fc0@HIDDEN>
 <d52c0f52-8c8b-0688-e735-c8eacf4ebcdb@HIDDEN>
 <4119ea30557ef84ca190@HIDDEN>
 <7eb7ee0f-7dba-c90d-cb58-af42c3828643@HIDDEN>
 <4119ea30554b406efbbf@HIDDEN> <4119ea30558f1e4145b0@HIDDEN>
 <ae221795-5197-36c5-4e0e-e1cb97e2a076@HIDDEN>
 <4119ea30555e80bdcf7e@HIDDEN>
 <1c82e582-8b90-f3c5-5391-1e88ca4e7ab2@HIDDEN>
 <875z282el0.fsf@HIDDEN>
 <9d87da5b-e30e-149d-a467-a2c4c752a60e@HIDDEN>
 <87czwf9sq9.fsf@HIDDEN>
From: Dmitry Gutov <dgutov@HIDDEN>
Message-ID: <e6e66354-f7a2-68b6-cce3-a9e8fda31288@HIDDEN>
Date: Thu, 4 Mar 2021 19:20:32 +0200
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
 Thunderbird/68.10.0
MIME-Version: 1.0
In-Reply-To: <87czwf9sq9.fsf@HIDDEN>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 7bit
X-Spam-Score: 0.5 (/)
X-Debbugs-Envelope-To: 46859
Cc: Gregory Heytings <gregory@HIDDEN>, 46859 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.5 (/)

On 04.03.2021 11:24, Juri Linkov wrote:
> ;; Without patch
> (benchmark-run 10 (project-find-regexp "expose_frame")) ;; (1.936206149 21 0.27307954999999995)
> 
> ;; With patch without the "(unless syntax-needed" guard
> (benchmark-run 10 (project-find-regexp "expose_frame")) ;; (2.195018443 31 0.354854643)

Thanks.

Note that running the benchmark 10 times means that on the last 9 
iterations the lines are already fontified.

The cost of doing this should be apparent with more search hits, though. 
For example:

   (benchmark-run 1 (project-find-regexp "expose"))

> I don't know if extra font-locking is worth worse performance.
> But I took this idea for consistency from occur that uses
> 'font-lock-ensure' in 'occur-engine-line'.

If you're sure you want this behavior, we can make it a user option.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#46859; Package emacs. Full text available.

Message received at 46859 <at> debbugs.gnu.org:


Received: (at 46859) by debbugs.gnu.org; 4 Mar 2021 17:13:43 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Mar 04 12:13:43 2021
Received: from localhost ([127.0.0.1]:60055 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lHrXi-000287-RC
	for submit <at> debbugs.gnu.org; Thu, 04 Mar 2021 12:13:43 -0500
Received: from eggs.gnu.org ([209.51.188.92]:57506)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1lHrXh-00027u-CR
 for 46859 <at> debbugs.gnu.org; Thu, 04 Mar 2021 12:13:41 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e]:37131)
 by eggs.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <eliz@HIDDEN>)
 id 1lHrXa-0008F6-Em; Thu, 04 Mar 2021 12:13:35 -0500
Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:3359
 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256)
 (Exim 4.82) (envelope-from <eliz@HIDDEN>)
 id 1lHrXZ-0003yA-Iq; Thu, 04 Mar 2021 12:13:34 -0500
Date: Thu, 04 Mar 2021 19:13:16 +0200
Message-Id: <834khq266r.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Gregory Heytings <gregory@HIDDEN>
In-Reply-To: <9cff0f889435d8d03313@HIDDEN> (message from Gregory
 Heytings on Thu, 04 Mar 2021 16:47:30 +0000)
Subject: Re: bug#46859: 28.0.50; [PATCH]: Add option to truncate long lines
 in xref.el
References: <m25z2azjxp.fsf@HIDDEN> <87im69uzlt.fsf@HIDDEN>
 <m2wnup9s2y.fsf@HIDDEN> <878s74fv27.fsf@HIDDEN>
 <4119ea3055ef8f306fc0@HIDDEN>
 <d52c0f52-8c8b-0688-e735-c8eacf4ebcdb@HIDDEN>
 <4119ea30557ef84ca190@HIDDEN>
 <7eb7ee0f-7dba-c90d-cb58-af42c3828643@HIDDEN>
 <4119ea30554b406efbbf@HIDDEN> <4119ea30558f1e4145b0@HIDDEN>
 <ae221795-5197-36c5-4e0e-e1cb97e2a076@HIDDEN>
 <4119ea30555e80bdcf7e@HIDDEN>
 <1c82e582-8b90-f3c5-5391-1e88ca4e7ab2@HIDDEN>
 <4119ea30553e3f90ab8c@HIDDEN> <87y2f42ex5.fsf@HIDDEN>
 <4119ea30552873ab9870@HIDDEN> <83eegvk2u0.fsf@HIDDEN>
 <9cff0f8894658f3b50c8@HIDDEN> <83y2f3huz2.fsf@HIDDEN>
 <9cff0f88942d4103c685@HIDDEN> <83mtvjhrzj.fsf@HIDDEN>
 <9cff0f889435d8d03313@HIDDEN>
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 46859
Cc: 46859 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)

> Date: Thu, 04 Mar 2021 16:47:30 +0000
> From: Gregory Heytings <gregory@HIDDEN>
> cc: 46859 <at> debbugs.gnu.org
> 
> > Yes.  But it can be slow.
> 
> Can it become so slow that it would have an impact on user experience? 

I don't know, Grep is a somewhat special application.

> filepos-to-bufferpos would be called only when the xref link is followed, 
> so I guess that even a 0.1 or 0.2 second delay should be okay.

Yes, 0.1 sec is definitely okay.

> I just tried again on a 25 MB Latin-1 file, on one of the last bytes it 
> took ~13 ms without specifying a quality.  I tried with nil, 'approximate 
> and 'best, but do not see any difference, the result with benchmark-run is 
> always ~13 ms.
> 
> > Also, what happens with multibyte encodings that are not UTF-8, like 
> > iso-2022, for example?
> 
> Well, the Latin-1 file is already different from UTF-8.

AFAIR, with single-byte encoding we take a shortcut there.

> I don't know anything about ISO-2022, but tried with a 25 MB file, created 
> with iconv, which Emacs recognizes as an iso-2022-7bit-dos one.  In that 
> case filepos-to-bufferpos does not work at all, with 'approximate you get 
> a position that is about 2 million characters away from the correct one, 
> and with 'best or nil you get nil...

Not 'best, 'exact.  Did you try 'exact?  It should have worked,
barring any bugs.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#46859; Package emacs. Full text available.

Message received at 46859 <at> debbugs.gnu.org:


Received: (at 46859) by debbugs.gnu.org; 4 Mar 2021 16:47:34 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Mar 04 11:47:34 2021
Received: from localhost ([127.0.0.1]:60013 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lHr8Q-0001Uu-HW
	for submit <at> debbugs.gnu.org; Thu, 04 Mar 2021 11:47:34 -0500
Received: from heytings.org ([95.142.160.155]:43082)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <gregory@HIDDEN>) id 1lHr8O-0001Um-Jd
 for 46859 <at> debbugs.gnu.org; Thu, 04 Mar 2021 11:47:33 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=heytings.org;
 s=20210101; t=1614876451;
 bh=v5FFdOTvUizGiu0aNKqUQbkDZKvKIyhlk6Da4xHu+W8=;
 h=Date:From:To:cc:Subject:In-Reply-To:Message-ID:References:From;
 b=rCa3sXzvRqYOpKw8qIurc9Nj+tKDaVrV4Sy305FjEeKILHg1qqOBRDMwiPjP4G5yd
 NF6dw4UpK+yxr1e2EUqV4r50jdhaKEGr1FJbG+YoSD/bm0cHubXFMjN5uqfoAEuU6T
 JHx8iOHlY9zr+bM1MqulyAwcHcWY8tUzTm4DVaSCxp6WbIGK14RQE0Bo45BJSBpI48
 7fJWAXOwhs1oHkOMgrEQYbI6RAdTAd7lTY/h+S/lYM/t1X46zFCuE7ZFU+RwL/aVqS
 SPbs8SrnGoyA0Ch0zYE7RPPVKzjAyZ+CLgoqPu2BRCJN+mA9R8QoQKRPteVi6tMDoR
 nh82b7ULgl5Gg==
Date: Thu, 04 Mar 2021 16:47:30 +0000
From: Gregory Heytings <gregory@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#46859: 28.0.50; [PATCH]: Add option to truncate long lines
 in xref.el
In-Reply-To: <83mtvjhrzj.fsf@HIDDEN>
Message-ID: <9cff0f889435d8d03313@HIDDEN>
References: <m25z2azjxp.fsf@HIDDEN> <87im69uzlt.fsf@HIDDEN>
 <m2wnup9s2y.fsf@HIDDEN> <878s74fv27.fsf@HIDDEN>
 <4119ea3055ef8f306fc0@HIDDEN>
 <d52c0f52-8c8b-0688-e735-c8eacf4ebcdb@HIDDEN>
 <4119ea30557ef84ca190@HIDDEN>
 <7eb7ee0f-7dba-c90d-cb58-af42c3828643@HIDDEN>
 <4119ea30554b406efbbf@HIDDEN> <4119ea30558f1e4145b0@HIDDEN>
 <ae221795-5197-36c5-4e0e-e1cb97e2a076@HIDDEN>
 <4119ea30555e80bdcf7e@HIDDEN>
 <1c82e582-8b90-f3c5-5391-1e88ca4e7ab2@HIDDEN>
 <4119ea30553e3f90ab8c@HIDDEN> <87y2f42ex5.fsf@HIDDEN>
 <4119ea30552873ab9870@HIDDEN> <83eegvk2u0.fsf@HIDDEN>
 <9cff0f8894658f3b50c8@HIDDEN> <83y2f3huz2.fsf@HIDDEN>
 <9cff0f88942d4103c685@HIDDEN> <83mtvjhrzj.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; format=flowed; charset=us-ascii
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 46859
Cc: 46859 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)


>> But you provide the solution: when an xref is followed, the file is 
>> opened in a buffer, at which point buffer-file-coding-system is set. 
>> So it seems that it suffices to do (goto-char (filepos-to-bufferpos 
>> (get-byte-position))).
>
> Yes.  But it can be slow.
>

Can it become so slow that it would have an impact on user experience? 
filepos-to-bufferpos would be called only when the xref link is followed, 
so I guess that even a 0.1 or 0.2 second delay should be okay.

>> I just did a filepos-to-bufferpos for one of the last bytes of a 6 MB 
>> Latin-1 file, and it took only ~2 ms.
>
> Which value of QUALITY did you use?
>

I just tried again on a 25 MB Latin-1 file, on one of the last bytes it 
took ~13 ms without specifying a quality.  I tried with nil, 'approximate 
and 'best, but do not see any difference, the result with benchmark-run is 
always ~13 ms.

>
> Also, what happens with multibyte encodings that are not UTF-8, like 
> iso-2022, for example?
>

Well, the Latin-1 file is already different from UTF-8.

I don't know anything about ISO-2022, but tried with a 25 MB file, created 
with iconv, which Emacs recognizes as an iso-2022-7bit-dos one.  In that 
case filepos-to-bufferpos does not work at all, with 'approximate you get 
a position that is about 2 million characters away from the correct one, 
and with 'best or nil you get nil...




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#46859; Package emacs. Full text available.

Message received at 46859 <at> debbugs.gnu.org:


Received: (at 46859) by debbugs.gnu.org; 4 Mar 2021 15:13:46 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Mar 04 10:13:46 2021
Received: from localhost ([127.0.0.1]:59941 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lHpfe-0007cg-9F
	for submit <at> debbugs.gnu.org; Thu, 04 Mar 2021 10:13:46 -0500
Received: from eggs.gnu.org ([209.51.188.92]:49342)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1lHpfb-0007cT-HJ
 for 46859 <at> debbugs.gnu.org; Thu, 04 Mar 2021 10:13:44 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e]:33728)
 by eggs.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <eliz@HIDDEN>)
 id 1lHpfW-0001tC-6t; Thu, 04 Mar 2021 10:13:38 -0500
Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:2448
 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256)
 (Exim 4.82) (envelope-from <eliz@HIDDEN>)
 id 1lHpfV-0004Uj-A4; Thu, 04 Mar 2021 10:13:37 -0500
Date: Thu, 04 Mar 2021 17:13:20 +0200
Message-Id: <83mtvjhrzj.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Gregory Heytings <gregory@HIDDEN>
In-Reply-To: <9cff0f88942d4103c685@HIDDEN> (message from Gregory
 Heytings on Thu, 04 Mar 2021 14:39:23 +0000)
Subject: Re: bug#46859: 28.0.50; [PATCH]: Add option to truncate long lines
 in xref.el
References: <m25z2azjxp.fsf@HIDDEN> <87im69uzlt.fsf@HIDDEN>
 <m2wnup9s2y.fsf@HIDDEN> <878s74fv27.fsf@HIDDEN>
 <4119ea3055ef8f306fc0@HIDDEN>
 <d52c0f52-8c8b-0688-e735-c8eacf4ebcdb@HIDDEN>
 <4119ea30557ef84ca190@HIDDEN>
 <7eb7ee0f-7dba-c90d-cb58-af42c3828643@HIDDEN>
 <4119ea30554b406efbbf@HIDDEN> <4119ea30558f1e4145b0@HIDDEN>
 <ae221795-5197-36c5-4e0e-e1cb97e2a076@HIDDEN>
 <4119ea30555e80bdcf7e@HIDDEN>
 <1c82e582-8b90-f3c5-5391-1e88ca4e7ab2@HIDDEN>
 <4119ea30553e3f90ab8c@HIDDEN> <87y2f42ex5.fsf@HIDDEN>
 <4119ea30552873ab9870@HIDDEN> <83eegvk2u0.fsf@HIDDEN>
 <9cff0f8894658f3b50c8@HIDDEN> <83y2f3huz2.fsf@HIDDEN>
 <9cff0f88942d4103c685@HIDDEN>
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 46859
Cc: 46859 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)

> Date: Thu, 04 Mar 2021 14:39:23 +0000
> From: Gregory Heytings <gregory@HIDDEN>
> cc: 46859 <at> debbugs.gnu.org
> 
> But you provide the solution: when an xref is followed, the file is opened 
> in a buffer, at which point buffer-file-coding-system is set.  So it seems 
> that it suffices to do (goto-char (filepos-to-bufferpos 
> (get-byte-position))).

Yes.  But it can be slow.

> I just did a filepos-to-bufferpos for one of the last bytes of a 6 MB 
> Latin-1 file, and it took only ~2 ms.

Which value of QUALITY did you use?

Also, what happens with multibyte encodings that are not UTF-8, like
iso-2022, for example?




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#46859; Package emacs. Full text available.

Message received at 46859 <at> debbugs.gnu.org:


Received: (at 46859) by debbugs.gnu.org; 4 Mar 2021 14:39:28 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Mar 04 09:39:28 2021
Received: from localhost ([127.0.0.1]:58236 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lHp8S-0006NP-9I
	for submit <at> debbugs.gnu.org; Thu, 04 Mar 2021 09:39:28 -0500
Received: from heytings.org ([95.142.160.155]:42938)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <gregory@HIDDEN>) id 1lHp8O-0006NF-Ts
 for 46859 <at> debbugs.gnu.org; Thu, 04 Mar 2021 09:39:27 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=heytings.org;
 s=20210101; t=1614868763;
 bh=ItK91PCkD14HTyk9TK/H7golE3Kn2so/if0FI+QnepU=;
 h=Date:From:To:cc:Subject:In-Reply-To:Message-ID:References:From;
 b=HccmgNIiL2b+tGqd12p1tunoMKKuNWY5Wf8QkNqNyPuPDwLJSw9fGeGHHQ6xSGUbd
 CHtYo4hHvCGERQI8FU4oJ9/vMhyIgBR/736rcD+vyO6XsBWmKIWooRq0HNxJNU/aUm
 YKUBFiW4bO41NrfbGe9V2kn/mCwHQc/9IpCZ5LBfNR6lJzFXsPyajPE6co07yo7q6W
 4u2BCApe4/LB3Rl1siNCC2iJeQjVerzPuPIJijJt7B0FPm/7W3RuuxDZGKCnJUd9UK
 jKK+lQopzVCuJpJJhusWqQqaoL7Ql7THCwYrt4ch00lVPBjz64J5I4JGXM1Se4M2eo
 qcRBZfJZdyJtw==
Date: Thu, 04 Mar 2021 14:39:23 +0000
From: Gregory Heytings <gregory@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#46859: 28.0.50; [PATCH]: Add option to truncate long lines
 in xref.el
In-Reply-To: <83y2f3huz2.fsf@HIDDEN>
Message-ID: <9cff0f88942d4103c685@HIDDEN>
References: <m25z2azjxp.fsf@HIDDEN> <87im69uzlt.fsf@HIDDEN>
 <m2wnup9s2y.fsf@HIDDEN> <878s74fv27.fsf@HIDDEN>
 <4119ea3055ef8f306fc0@HIDDEN>
 <d52c0f52-8c8b-0688-e735-c8eacf4ebcdb@HIDDEN>
 <4119ea30557ef84ca190@HIDDEN>
 <7eb7ee0f-7dba-c90d-cb58-af42c3828643@HIDDEN>
 <4119ea30554b406efbbf@HIDDEN> <4119ea30558f1e4145b0@HIDDEN>
 <ae221795-5197-36c5-4e0e-e1cb97e2a076@HIDDEN>
 <4119ea30555e80bdcf7e@HIDDEN>
 <1c82e582-8b90-f3c5-5391-1e88ca4e7ab2@HIDDEN>
 <4119ea30553e3f90ab8c@HIDDEN> <87y2f42ex5.fsf@HIDDEN>
 <4119ea30552873ab9870@HIDDEN> <83eegvk2u0.fsf@HIDDEN>
 <9cff0f8894658f3b50c8@HIDDEN> <83y2f3huz2.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; format=flowed; charset=us-ascii
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 46859
Cc: 46859 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)


>
> No.  byte-to-position works for text in an Emacs buffer, whereas we are 
> talking about the text in its original file on disk.  Unless that file 
> is encoded in UTF-8, byte-to-position will give you wrong results.  You 
> need to use filepos-to-bufferpos, and you will need to specify the 
> file's encoding.  And it's relatively slow for non-UTF-8 encoded files.
>

Thank you, I was not aware of that subtlety.

But you provide the solution: when an xref is followed, the file is opened 
in a buffer, at which point buffer-file-coding-system is set.  So it seems 
that it suffices to do (goto-char (filepos-to-bufferpos 
(get-byte-position))).

I just did a filepos-to-bufferpos for one of the last bytes of a 6 MB 
Latin-1 file, and it took only ~2 ms.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#46859; Package emacs. Full text available.

Message received at 46859 <at> debbugs.gnu.org:


Received: (at 46859) by debbugs.gnu.org; 4 Mar 2021 14:09:17 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Mar 04 09:09:17 2021
Received: from localhost ([127.0.0.1]:58186 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lHofF-0005ay-ES
	for submit <at> debbugs.gnu.org; Thu, 04 Mar 2021 09:09:17 -0500
Received: from eggs.gnu.org ([209.51.188.92]:58686)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1lHofB-0005aT-Km
 for 46859 <at> debbugs.gnu.org; Thu, 04 Mar 2021 09:09:16 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e]:60069)
 by eggs.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <eliz@HIDDEN>)
 id 1lHof6-0006WH-6a; Thu, 04 Mar 2021 09:09:08 -0500
Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:2479
 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256)
 (Exim 4.82) (envelope-from <eliz@HIDDEN>)
 id 1lHof5-0008A5-Mq; Thu, 04 Mar 2021 09:09:08 -0500
Date: Thu, 04 Mar 2021 16:08:49 +0200
Message-Id: <83y2f3huz2.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Gregory Heytings <gregory@HIDDEN>
In-Reply-To: <9cff0f8894658f3b50c8@HIDDEN> (message from Gregory
 Heytings on Thu, 04 Mar 2021 09:19:50 +0000)
Subject: Re: bug#46859: 28.0.50; [PATCH]: Add option to truncate long lines
 in xref.el
References: <m25z2azjxp.fsf@HIDDEN> <87im69uzlt.fsf@HIDDEN>
 <m2wnup9s2y.fsf@HIDDEN> <878s74fv27.fsf@HIDDEN>
 <4119ea3055ef8f306fc0@HIDDEN>
 <d52c0f52-8c8b-0688-e735-c8eacf4ebcdb@HIDDEN>
 <4119ea30557ef84ca190@HIDDEN>
 <7eb7ee0f-7dba-c90d-cb58-af42c3828643@HIDDEN>
 <4119ea30554b406efbbf@HIDDEN> <4119ea30558f1e4145b0@HIDDEN>
 <ae221795-5197-36c5-4e0e-e1cb97e2a076@HIDDEN>
 <4119ea30555e80bdcf7e@HIDDEN>
 <1c82e582-8b90-f3c5-5391-1e88ca4e7ab2@HIDDEN>
 <4119ea30553e3f90ab8c@HIDDEN> <87y2f42ex5.fsf@HIDDEN>
 <4119ea30552873ab9870@HIDDEN> <83eegvk2u0.fsf@HIDDEN>
 <9cff0f8894658f3b50c8@HIDDEN>
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 46859
Cc: 46859 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)

> Date: Thu, 04 Mar 2021 09:19:50 +0000
> From: Gregory Heytings <gregory@HIDDEN>
> cc: 46859 <at> debbugs.gnu.org
> 
> > While you discuss all those possibilities, please be aware that byte 
> > offsets have one more problem: converting them to character offsets or 
> > columns might not be trivial, especially if the encoding of the file is 
> > not UTF-8.  (Apologies if you already discussed this.)
> >
> 
> We did not discuss this, thanks for pointing that out.
> 
> Is this not easy to do with byte-to-position?

No.  byte-to-position works for text in an Emacs buffer, whereas we
are talking about the text in its original file on disk.  Unless that
file is encoded in UTF-8, byte-to-position will give you wrong
results.  You need to use filepos-to-bufferpos, and you will need to
specify the file's encoding.  And it's relatively slow for non-UTF-8
encoded files.

> What I would suggest is to use "grep -nbo '.\{0,50\}PATTERN.\{0,50\}'", to 
> hide the byte position in the xref buffer, and when the user jumps to an 
> occurrence to use something like (goto-char (byte-to-position 
> (get-byte-position))).  Does that make sense?

Yes, but see above about encodings other than UTF-8.  For example, if
the original file is in Latin-1, each character is 1 byte, but in an
Emacs buffer non-ASCII Latin-1 characters will take 2 bytes.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#46859; Package emacs. Full text available.

Message received at 46859 <at> debbugs.gnu.org:


Received: (at 46859) by debbugs.gnu.org; 4 Mar 2021 10:16:25 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Mar 04 05:16:25 2021
Received: from localhost ([127.0.0.1]:57775 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lHl1s-0007lh-PD
	for submit <at> debbugs.gnu.org; Thu, 04 Mar 2021 05:16:24 -0500
Received: from relay12.mail.gandi.net ([217.70.178.232]:46963)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <juri@HIDDEN>) id 1lHl1r-0007lE-DX
 for 46859 <at> debbugs.gnu.org; Thu, 04 Mar 2021 05:16:23 -0500
Received: from mail.gandi.net (m91-129-96-116.cust.tele2.ee [91.129.96.116])
 (Authenticated sender: juri@HIDDEN)
 by relay12.mail.gandi.net (Postfix) with ESMTPSA id E9D55200015;
 Thu,  4 Mar 2021 10:16:14 +0000 (UTC)
From: Juri Linkov <juri@HIDDEN>
To: Dmitry Gutov <dgutov@HIDDEN>
Subject: Re: bug#46859: 28.0.50; [PATCH]: Add option to truncate long lines
 in xref.el
Organization: LINKOV.NET
References: <m25z2azjxp.fsf@HIDDEN> <87im69uzlt.fsf@HIDDEN>
 <m2wnup9s2y.fsf@HIDDEN> <878s74fv27.fsf@HIDDEN>
 <4119ea3055ef8f306fc0@HIDDEN>
 <d52c0f52-8c8b-0688-e735-c8eacf4ebcdb@HIDDEN>
 <4119ea30557ef84ca190@HIDDEN>
 <7eb7ee0f-7dba-c90d-cb58-af42c3828643@HIDDEN>
 <4119ea30554b406efbbf@HIDDEN>
 <4119ea30558f1e4145b0@HIDDEN>
 <ae221795-5197-36c5-4e0e-e1cb97e2a076@HIDDEN>
 <4119ea30555e80bdcf7e@HIDDEN>
 <1c82e582-8b90-f3c5-5391-1e88ca4e7ab2@HIDDEN>
 <875z282el0.fsf@HIDDEN>
 <9d87da5b-e30e-149d-a467-a2c4c752a60e@HIDDEN>
Date: Thu, 04 Mar 2021 11:24:30 +0200
In-Reply-To: <9d87da5b-e30e-149d-a467-a2c4c752a60e@HIDDEN> (Dmitry Gutov's
 message of "Thu, 4 Mar 2021 04:50:48 +0200")
Message-ID: <87czwf9sq9.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 46859
Cc: Gregory Heytings <gregory@HIDDEN>, 46859 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)

>> Reusing visited files is a nice feature, but still needs a fix.
>> Test case: visit emacs/src/xdisp.c and type
>>    C-x p g expose_frame RET
>> See that not all lines from xdisp.c have font-lock highlighting.
>> After applying this patch, all xref output lines from xdisp.c
>> have font-lock faces:
>
> I thought about this, but applying font-lock rules is not exactly a trivial
> action. So I figured we better avoid it (and only call syntax-propertize
> when necessary) to get the best performance possible.
>
> Have you tried benchmarking with and without your patch? Particular case of
> interest: many files, each already visited, with 1 match in each of
> them. Or few matches.
>
> The opposite would be one file with many matches inside of it. This case
> should be relatively inexpensive for this patch, but it's worth measuring
> to compare too.
>
> P.S. The "(unless syntax-needed" guard in the proposed patch is not needed.

;; Without patch
(benchmark-run 10 (project-find-regexp "expose_frame")) ;; (1.936206149 21 0.27307954999999995)

;; With patch without the "(unless syntax-needed" guard
(benchmark-run 10 (project-find-regexp "expose_frame")) ;; (2.195018443 31 0.354854643)

I don't know if extra font-locking is worth worse performance.
But I took this idea for consistency from occur that uses
'font-lock-ensure' in 'occur-engine-line'.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#46859; Package emacs. Full text available.

Message received at 46859 <at> debbugs.gnu.org:


Received: (at 46859) by debbugs.gnu.org; 4 Mar 2021 09:19:54 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Mar 04 04:19:54 2021
Received: from localhost ([127.0.0.1]:57701 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lHk9C-0004IB-0y
	for submit <at> debbugs.gnu.org; Thu, 04 Mar 2021 04:19:54 -0500
Received: from heytings.org ([95.142.160.155]:42570)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <gregory@HIDDEN>) id 1lHk9A-0004I2-G9
 for 46859 <at> debbugs.gnu.org; Thu, 04 Mar 2021 04:19:52 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=heytings.org;
 s=20210101; t=1614849591;
 bh=3G2IbMGriRgqPmrvFpLgEJ2og2yRSkUfKzPNXNJFGt8=;
 h=Date:From:To:cc:Subject:In-Reply-To:Message-ID:References:From;
 b=L62LSL9mydmAAbVUrbq353+WSXENSArwzlaR4J3sXKROWR4TTIuHgWOeibnO+Arym
 lAQF86rVECNzq4/hoTeNzGCux5Wp0MqdHUNNbnzrHgLGbUSKFAZd7+/afiFNLAoI1R
 WOvJOJkqrN4FCkGAuR8NtuhS4o5GHOwc5c/ErrJf7rwnB2saML1BagDTkJ6eZrxPn8
 Qbgt55kVnKte7M6raB4HBJRNxJ474c1RcNSE8YcpC/B6ZawuMFjyGaMG9UKiXTBUkJ
 TX0FNcmNNlkm4pJOdNeTgsBpOuLsxgYWQPEvhq0kfNg0PLek7cgWsrwI63S8iMl/qA
 dBIfHlMN8SzCg==
Date: Thu, 04 Mar 2021 09:19:50 +0000
From: Gregory Heytings <gregory@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#46859: 28.0.50; [PATCH]: Add option to truncate long lines
 in xref.el
In-Reply-To: <83eegvk2u0.fsf@HIDDEN>
Message-ID: <9cff0f8894658f3b50c8@HIDDEN>
References: <m25z2azjxp.fsf@HIDDEN> <87im69uzlt.fsf@HIDDEN>
 <m2wnup9s2y.fsf@HIDDEN> <878s74fv27.fsf@HIDDEN>
 <4119ea3055ef8f306fc0@HIDDEN>
 <d52c0f52-8c8b-0688-e735-c8eacf4ebcdb@HIDDEN>
 <4119ea30557ef84ca190@HIDDEN>
 <7eb7ee0f-7dba-c90d-cb58-af42c3828643@HIDDEN>
 <4119ea30554b406efbbf@HIDDEN> <4119ea30558f1e4145b0@HIDDEN>
 <ae221795-5197-36c5-4e0e-e1cb97e2a076@HIDDEN>
 <4119ea30555e80bdcf7e@HIDDEN>
 <1c82e582-8b90-f3c5-5391-1e88ca4e7ab2@HIDDEN>
 <4119ea30553e3f90ab8c@HIDDEN> <87y2f42ex5.fsf@HIDDEN>
 <4119ea30552873ab9870@HIDDEN> <83eegvk2u0.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; format=flowed; charset=us-ascii
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 46859
Cc: 46859 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)


>
> While you discuss all those possibilities, please be aware that byte 
> offsets have one more problem: converting them to character offsets or 
> columns might not be trivial, especially if the encoding of the file is 
> not UTF-8.  (Apologies if you already discussed this.)
>

We did not discuss this, thanks for pointing that out.

Is this not easy to do with byte-to-position?

What I would suggest is to use "grep -nbo '.\{0,50\}PATTERN.\{0,50\}'", to 
hide the byte position in the xref buffer, and when the user jumps to an 
occurrence to use something like (goto-char (byte-to-position 
(get-byte-position))).  Does that make sense?




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#46859; Package emacs. Full text available.

Message received at 46859 <at> debbugs.gnu.org:


Received: (at 46859) by debbugs.gnu.org; 4 Mar 2021 03:36:36 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Mar 03 22:36:36 2021
Received: from localhost ([127.0.0.1]:57376 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lHemx-00042t-P4
	for submit <at> debbugs.gnu.org; Wed, 03 Mar 2021 22:36:35 -0500
Received: from eggs.gnu.org ([209.51.188.92]:39390)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1lHemv-00042h-W9
 for 46859 <at> debbugs.gnu.org; Wed, 03 Mar 2021 22:36:34 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e]:51049)
 by eggs.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <eliz@HIDDEN>)
 id 1lHemp-0004eO-6i; Wed, 03 Mar 2021 22:36:27 -0500
Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:3603
 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256)
 (Exim 4.82) (envelope-from <eliz@HIDDEN>)
 id 1lHemo-0002sS-CL; Wed, 03 Mar 2021 22:36:27 -0500
Date: Thu, 04 Mar 2021 05:36:07 +0200
Message-Id: <83eegvk2u0.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Gregory Heytings <gregory@HIDDEN>
In-Reply-To: <4119ea30552873ab9870@HIDDEN> (message from Gregory
 Heytings on Wed, 03 Mar 2021 20:34:46 +0000)
Subject: Re: bug#46859: 28.0.50;
 [PATCH]: Add option to truncate long lines in xref.el
References: <m25z2azjxp.fsf@HIDDEN> <87im69uzlt.fsf@HIDDEN>
 <m2wnup9s2y.fsf@HIDDEN> <878s74fv27.fsf@HIDDEN>
 <4119ea3055ef8f306fc0@HIDDEN>
 <d52c0f52-8c8b-0688-e735-c8eacf4ebcdb@HIDDEN>
 <4119ea30557ef84ca190@HIDDEN>
 <7eb7ee0f-7dba-c90d-cb58-af42c3828643@HIDDEN>
 <4119ea30554b406efbbf@HIDDEN> <4119ea30558f1e4145b0@HIDDEN>
 <ae221795-5197-36c5-4e0e-e1cb97e2a076@HIDDEN>
 <4119ea30555e80bdcf7e@HIDDEN>
 <1c82e582-8b90-f3c5-5391-1e88ca4e7ab2@HIDDEN>
 <4119ea30553e3f90ab8c@HIDDEN> <87y2f42ex5.fsf@HIDDEN>
 <4119ea30552873ab9870@HIDDEN>
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 46859
Cc: 46859 <at> debbugs.gnu.org, juri@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)

> Date: Wed, 03 Mar 2021 20:34:46 +0000
> From: Gregory Heytings <gregory@HIDDEN>
> Cc: 46859 <at> debbugs.gnu.org
> 
> > 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.

While you discuss all those possibilities, please be aware that byte
offsets have one more problem: converting them to character offsets or
columns might not be trivial, especially if the encoding of the file
is not UTF-8.  (Apologies if you already discussed this.)




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#46859; Package emacs. Full text available.

Message received at 46859 <at> debbugs.gnu.org:


Received: (at 46859) by debbugs.gnu.org; 4 Mar 2021 02:50:59 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Mar 03 21:50:59 2021
Received: from localhost ([127.0.0.1]:57357 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lHe4p-0000qO-Lh
	for submit <at> debbugs.gnu.org; Wed, 03 Mar 2021 21:50:59 -0500
Received: from mail-wr1-f51.google.com ([209.85.221.51]:33110)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <raaahh@HIDDEN>) id 1lHe4n-0000qC-TN
 for 46859 <at> debbugs.gnu.org; Wed, 03 Mar 2021 21:50:58 -0500
Received: by mail-wr1-f51.google.com with SMTP id 7so25956272wrz.0
 for <46859 <at> debbugs.gnu.org>; Wed, 03 Mar 2021 18:50:57 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=sender:subject:to:cc:references:from:message-id:date:user-agent
 :mime-version:in-reply-to:content-language:content-transfer-encoding;
 bh=1o+9TC4lGOQnoDyKqBvcv9yYIJLciesGKnw03Oni8yM=;
 b=gnMRmU7Br/FVhRbjWoTd+qNJ/WEnNwaouPrN+4SLbKYNXXJ+Sev7cxohDwxalHdftC
 mWeVxXd9UUrCWSjflC7MkJ0dfRWG8EShEOlxsJRo+tNH2Xq5d+0mH/h/daj3JxE8vN30
 9mViTWNlvJEe2GqFL0Thl3jY0AbfeN88oBo8f/qOcWFRaCtX6eUbkf4ke5Lz0743SSPh
 GYaBR07Dn1+PfIfM0UdpBFSJFklIxgHNmCkwthUfX0ug/wDbRs0GAZkN2+oiup1m987C
 ZTUyT5BVkH3Lr8V1OvHds+aGUNQSP+Bke/XCUg8/6dZo6PVnGaUmuLGORRkUBSrujuVl
 0wZQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:sender:subject:to:cc:references:from:message-id
 :date:user-agent:mime-version:in-reply-to:content-language
 :content-transfer-encoding;
 bh=1o+9TC4lGOQnoDyKqBvcv9yYIJLciesGKnw03Oni8yM=;
 b=dDWb9tqAOsh0D26m428erwIf2dx7P7hiS7RKi8JQEccXrphlCzlthKiuw2/2Vurj8X
 8CIgPDwrczVVhTLfRXpx5LizGeDwHUkQAq/6qOLemJraDI5m7CktqhE4hqDOZ7rjHUPB
 YKERF+d3AQN50u2tvX95IvpfBq6Dkwmxmes3AWrqJyd2HBeY6wwNS4zDwspgquTBvjOk
 TfyrBEAZPTTwJ8XfnXJQQ0g5cc3KfbpBmtLGDboIISUTdRdDJlgahiu80KNEkp93Npqs
 gIjNQqSNb/4h+kkPvuuQlPkRdFgF4s5Aqi1jCVgPnrxyGnhgfkDb6MuKjkJklkKK+Idk
 VSiQ==
X-Gm-Message-State: AOAM532Dj/5NHMTTbABR2HDmHel4aVlsmcAXLvC5JS8BU7QdwXVzUps3
 B2fjQuBrzqKSgWperNH363oSKNscHVE=
X-Google-Smtp-Source: ABdhPJym2SnkOueqvbdiSTt6g0PHQC8R4/JEAKr//Gz7dstBe5rjf+mmW/ksdIPU1HvTnEpung23JQ==
X-Received: by 2002:a5d:42d2:: with SMTP id t18mr1605030wrr.258.1614826252004; 
 Wed, 03 Mar 2021 18:50:52 -0800 (PST)
Received: from [192.168.0.6] ([46.251.119.176])
 by smtp.googlemail.com with ESMTPSA id d16sm34053119wrx.79.2021.03.03.18.50.50
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Wed, 03 Mar 2021 18:50:51 -0800 (PST)
Subject: Re: bug#46859: 28.0.50; [PATCH]: Add option to truncate long lines in
 xref.el
To: Juri Linkov <juri@HIDDEN>
References: <m25z2azjxp.fsf@HIDDEN> <87im69uzlt.fsf@HIDDEN>
 <m2wnup9s2y.fsf@HIDDEN> <878s74fv27.fsf@HIDDEN>
 <4119ea3055ef8f306fc0@HIDDEN>
 <d52c0f52-8c8b-0688-e735-c8eacf4ebcdb@HIDDEN>
 <4119ea30557ef84ca190@HIDDEN>
 <7eb7ee0f-7dba-c90d-cb58-af42c3828643@HIDDEN>
 <4119ea30554b406efbbf@HIDDEN> <4119ea30558f1e4145b0@HIDDEN>
 <ae221795-5197-36c5-4e0e-e1cb97e2a076@HIDDEN>
 <4119ea30555e80bdcf7e@HIDDEN>
 <1c82e582-8b90-f3c5-5391-1e88ca4e7ab2@HIDDEN>
 <875z282el0.fsf@HIDDEN>
From: Dmitry Gutov <dgutov@HIDDEN>
Message-ID: <9d87da5b-e30e-149d-a467-a2c4c752a60e@HIDDEN>
Date: Thu, 4 Mar 2021 04:50:48 +0200
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
 Thunderbird/68.10.0
MIME-Version: 1.0
In-Reply-To: <875z282el0.fsf@HIDDEN>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 7bit
X-Spam-Score: 0.5 (/)
X-Debbugs-Envelope-To: 46859
Cc: Gregory Heytings <gregory@HIDDEN>, 46859 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.5 (/)

Hi Juri,

On 03.03.2021 21:59, Juri Linkov wrote:
>> We currently don't visit the file buffer if it's not already visited,
>> parsing the line in a temp buffer instead. That approach resulted in a nice
>> perf improvement.
> 
> Reusing visited files is a nice feature, but still needs a fix.
> 
> Test case: visit emacs/src/xdisp.c and type
> 
>    C-x p g expose_frame RET
> 
> See that not all lines from xdisp.c have font-lock highlighting.
> After applying this patch, all xref output lines from xdisp.c
> have font-lock faces:

I thought about this, but applying font-lock rules is not exactly a 
trivial action. So I figured we better avoid it (and only call 
syntax-propertize when necessary) to get the best performance possible.

Have you tried benchmarking with and without your patch? Particular case 
of interest: many files, each already visited, with 1 match in each of 
them. Or few matches.

The opposite would be one file with many matches inside of it. This case 
should be relatively inexpensive for this patch, but it's worth 
measuring to compare too.

P.S. The "(unless syntax-needed" guard in the proposed patch is not needed.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#46859; Package emacs. Full text available.

Message received at 46859 <at> debbugs.gnu.org:


Received: (at 46859) by debbugs.gnu.org; 3 Mar 2021 21:07:06 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Mar 03 16:07:06 2021
Received: from localhost ([127.0.0.1]:57130 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lHYi2-0005Pa-At
	for submit <at> debbugs.gnu.org; Wed, 03 Mar 2021 16:07:06 -0500
Received: from heytings.org ([95.142.160.155]:41952)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <gregory@HIDDEN>) id 1lHYhx-0005P6-8h
 for 46859 <at> debbugs.gnu.org; Wed, 03 Mar 2021 16:07:04 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=heytings.org;
 s=20210101; t=1614805620;
 bh=/yChIEvTGnrzUSgzHcqbW+RvzdPqkV0FusndRe/K0cA=;
 h=Date:From:To:cc:Subject:In-Reply-To:Message-ID:References:From;
 b=p85ssnemBXkqBWEz6MtIviSraR45I1rm3N0z664Y23uNR5h4XU1i2xhygYHxIGEbo
 uOiCq0V8lXBp1T0P0Py2cn97AqnN4hZ85hCQSc9QvTHBlvqhqdUfIlSKudDqkhr2TX
 +G00O9MzAo43PaL1gyfSggsHvhomJQ/PSqw4ORLNTHegtB0dIi9ayORJSCP31cU1yR
 /u3sPm5Ru9MuWBofXZVnVv/DSuyma/myW1ZapyeERmvZOZWWDPRNiIo+9NAZDbRHYV
 bQ+LgjYCLA2k1Lvomc0l02tpZhQnCpmYn+P3ctRCJ9M9rPxQJbJyvjCf5ojeObTPp6
 5XQRlcfv5A7lQ==
Date: Wed, 03 Mar 2021 21:06:59 +0000
From: Gregory Heytings <gregory@HIDDEN>
To: Dmitry Gutov <dgutov@HIDDEN>
Subject: Re: bug#46859: 28.0.50; [PATCH]: Add option to truncate long lines
 in xref.el
In-Reply-To: <08b51962-6305-5188-0bea-b17b4139646c@HIDDEN>
Message-ID: <4119ea3055bd6f6d2e91@HIDDEN>
References: <m25z2azjxp.fsf@HIDDEN> <87im69uzlt.fsf@HIDDEN>
 <m2wnup9s2y.fsf@HIDDEN> <878s74fv27.fsf@HIDDEN>
 <4119ea3055ef8f306fc0@HIDDEN>
 <d52c0f52-8c8b-0688-e735-c8eacf4ebcdb@HIDDEN>
 <4119ea30557ef84ca190@HIDDEN>
 <7eb7ee0f-7dba-c90d-cb58-af42c3828643@HIDDEN>
 <4119ea30554b406efbbf@HIDDEN> <4119ea30558f1e4145b0@HIDDEN>
 <ae221795-5197-36c5-4e0e-e1cb97e2a076@HIDDEN>
 <4119ea30555e80bdcf7e@HIDDEN>
 <1c82e582-8b90-f3c5-5391-1e88ca4e7ab2@HIDDEN>
 <4119ea30553e3f90ab8c@HIDDEN>
 <08b51962-6305-5188-0bea-b17b4139646c@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; format=flowed; charset=us-ascii
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 46859
Cc: 46859 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)


>
> With your approach we'll have to deal with interpreting Grep outputs 
> which list every line in the searched files. This will almost certainly 
> be slower in the case when there are only handful of matches. But 
> benchmarks welcome.
>

I don't know what you exactly need (I don't (yet?) use project), so I 
can't elaborate further or provide benchmarks alas.

Could you perhaps tell me what you need?




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#46859; Package emacs. Full text available.

Message received at 46859 <at> debbugs.gnu.org:


Received: (at 46859) by debbugs.gnu.org; 3 Mar 2021 20:34:50 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Mar 03 15:34:50 2021
Received: from localhost ([127.0.0.1]:57121 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lHYCo-0004eo-Gc
	for submit <at> debbugs.gnu.org; Wed, 03 Mar 2021 15:34:50 -0500
Received: from heytings.org ([95.142.160.155]:41916)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <gregory@HIDDEN>) id 1lHYCm-0004ef-J7
 for 46859 <at> 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==
Date: Wed, 03 Mar 2021 20:34:46 +0000
From: Gregory Heytings <gregory@HIDDEN>
To: Juri Linkov <juri@HIDDEN>
Subject: Re: bug#46859: 28.0.50; [PATCH]: Add option to truncate long lines
 in xref.el
In-Reply-To: <87y2f42ex5.fsf@HIDDEN>
Message-ID: <4119ea30552873ab9870@HIDDEN>
References: <m25z2azjxp.fsf@HIDDEN> <87im69uzlt.fsf@HIDDEN>
 <m2wnup9s2y.fsf@HIDDEN> <878s74fv27.fsf@HIDDEN>
 <4119ea3055ef8f306fc0@HIDDEN>
 <d52c0f52-8c8b-0688-e735-c8eacf4ebcdb@HIDDEN>
 <4119ea30557ef84ca190@HIDDEN>
 <7eb7ee0f-7dba-c90d-cb58-af42c3828643@HIDDEN>
 <4119ea30554b406efbbf@HIDDEN> <4119ea30558f1e4145b0@HIDDEN>
 <ae221795-5197-36c5-4e0e-e1cb97e2a076@HIDDEN>
 <4119ea30555e80bdcf7e@HIDDEN>
 <1c82e582-8b90-f3c5-5391-1e88ca4e7ab2@HIDDEN>
 <4119ea30553e3f90ab8c@HIDDEN> <87y2f42ex5.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; format=flowed; charset=us-ascii
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 46859
Cc: 46859 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)


>>> 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.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#46859; Package emacs. Full text available.

Message received at 46859 <at> debbugs.gnu.org:


Received: (at 46859) by debbugs.gnu.org; 3 Mar 2021 20:30:24 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Mar 03 15:30:24 2021
Received: from localhost ([127.0.0.1]:57117 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lHY8V-0004Yp-SD
	for submit <at> debbugs.gnu.org; Wed, 03 Mar 2021 15:30:24 -0500
Received: from mail-wr1-f43.google.com ([209.85.221.43]:37527)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <raaahh@HIDDEN>) id 1lHY8S-0004YW-0l
 for 46859 <at> debbugs.gnu.org; Wed, 03 Mar 2021 15:30:21 -0500
Received: by mail-wr1-f43.google.com with SMTP id v15so25171583wrx.4
 for <46859 <at> debbugs.gnu.org>; Wed, 03 Mar 2021 12:30:19 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=sender:subject:to:cc:references:from:message-id:date:user-agent
 :mime-version:in-reply-to:content-language:content-transfer-encoding;
 bh=Qq3hjv+4ektbFQU0agOXnnQlOMGgZ2l8alPISvd9GPU=;
 b=ks645ckew+Xxd/f0d2kVEImcFig6PV17cUpbiOl1FFRWeKNPEtoSErxG8AVIZhTPrf
 SULpEvtpDjsRPUs/gM6JlcBXVMlUGZ3Z9g1WJcauErana5mhIgF8eDoQ3K/4TbyGHi/A
 Xw+iamwkPYXYJF3qxVPH1sB7qD7JKOX7DdMMGNpU63OV7RMH6kYW0iscHoyfal12Qq7n
 Svo6sz0yBt9/cpeqJPJ3vZcslVBjAGlhVBcmkSW3/DveQK6kbv/bWJrcg8LhwWwAGcO/
 DuIw2oE4rnu5jXCQdSzOOLxOeyl+h7jDbXDGkstAUJLfw1eeWo/xhfR6uuKyXTeRzacp
 zxZg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:sender:subject:to:cc:references:from:message-id
 :date:user-agent:mime-version:in-reply-to:content-language
 :content-transfer-encoding;
 bh=Qq3hjv+4ektbFQU0agOXnnQlOMGgZ2l8alPISvd9GPU=;
 b=VJ3Mt1+yqCJe9T/wjsOMDsSYK7w9tlc4FP1NlLgAYnisuDLrFIrL5he7aZXTouN6Cp
 noaAwtvKKzTrW5UXQSdusINLWXqDXAFQP5vHI1FIFw/youPdCahWmvHnnTY9a8bdehqo
 FMjjk6POQG5ArvygspZXqHbFw7nhp402XKgx5esNmEF5HEV2RhfD7YkJKSLHKpqH77wP
 3NFT0Tf9gOMOVjisJjI9e3CGAh+NfE5LHx387SrKpK1I64nO4TyeQ5ISuEqlLGuuy69a
 KMPJxB5HH7w5abXTJ9Swl7sM0HLolnyTER+IcU9Pdsa7VzVbW12c44JTcZF1Y+JmMwFv
 0Mcg==
X-Gm-Message-State: AOAM533eY69d1Y0GzKP9poTVsGxW32i6/8VCK8taUFjTSi114j3PwPDB
 u7TRPld0IfCLkNiJOWEkfl6Ig9QH4n8=
X-Google-Smtp-Source: ABdhPJxdkPTIDr+cAS7TufFkkoUSloQykjyvryAZkNrQtKQqleoqRVPTg28RyNDGtGBb9I9grSpyvw==
X-Received: by 2002:adf:f144:: with SMTP id y4mr436972wro.408.1614803414095;
 Wed, 03 Mar 2021 12:30:14 -0800 (PST)
Received: from [192.168.0.6] ([46.251.119.176])
 by smtp.googlemail.com with ESMTPSA id y18sm32592598wrq.61.2021.03.03.12.30.12
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Wed, 03 Mar 2021 12:30:13 -0800 (PST)
Subject: Re: bug#46859: 28.0.50; [PATCH]: Add option to truncate long lines in
 xref.el
To: Gregory Heytings <gregory@HIDDEN>
References: <m25z2azjxp.fsf@HIDDEN> <87im69uzlt.fsf@HIDDEN>
 <m2wnup9s2y.fsf@HIDDEN> <878s74fv27.fsf@HIDDEN>
 <4119ea3055ef8f306fc0@HIDDEN>
 <d52c0f52-8c8b-0688-e735-c8eacf4ebcdb@HIDDEN>
 <4119ea30557ef84ca190@HIDDEN>
 <7eb7ee0f-7dba-c90d-cb58-af42c3828643@HIDDEN>
 <4119ea30554b406efbbf@HIDDEN> <4119ea30558f1e4145b0@HIDDEN>
 <ae221795-5197-36c5-4e0e-e1cb97e2a076@HIDDEN>
 <4119ea30555e80bdcf7e@HIDDEN>
 <1c82e582-8b90-f3c5-5391-1e88ca4e7ab2@HIDDEN>
 <4119ea30553e3f90ab8c@HIDDEN>
From: Dmitry Gutov <dgutov@HIDDEN>
Message-ID: <08b51962-6305-5188-0bea-b17b4139646c@HIDDEN>
Date: Wed, 3 Mar 2021 22:30:09 +0200
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
 Thunderbird/68.10.0
MIME-Version: 1.0
In-Reply-To: <4119ea30553e3f90ab8c@HIDDEN>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.5 (/)
X-Debbugs-Envelope-To: 46859
Cc: 46859 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.5 (/)

On 03.03.2021 21:34, Gregory Heytings wrote:
> 
>>> Yes.  You get, for each match: the line number (from the beginning of 
>>> the file), the byte offset (from the beginning of the file) of the 
>>> first displayed character, and the context of the match.
>>
>> 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.
> 
> I could be wrong, but I believe that adapting what you want to what GNU 
> grep provides will always be more efficient than the opposite.

That's the general principle I have tried to follow, but Grep has proved 
suboptimal for a number of purposes (matching one regexp to multiple 
lines among them).

>>> And you can easily get the byte offset of each beginning of line with 
>>> "grep -nbo '^.'", so calculating the byte offset from the beginning 
>>> of the line is easy.
>>
>> Do you mean to suggest we call grep one more time for each matching line?
>>
> 
> No, once for each file.  "grep -nbo '^.' FILE" returns a "<line>:<offset 
> of first char>:<first char>" line for each line in FILE.  With this you 
> can easily calculate the offset of a match on a given line.  This will 
> be more efficient than calculating the offset of a match by parsing each 
> line with Elisp code.

That's still +1 Grep invocation per file, right? Can't say for sure, 
perhaps it will be more efficient than parsing in Lisp, but at least 
with Lisp I know that parsing 10-20 matches is fast (and, actually, it's 
fairly instantaneous with 1000s of matches, as long as we don't 
encounter pathological files where all contents reside on one line).

With your approach we'll have to deal with interpreting Grep outputs 
which list every line in the searched files. This will almost certainly 
be slower in the case when there are only handful of matches. But 
benchmarks welcome.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#46859; Package emacs. Full text available.

Message received at 46859 <at> debbugs.gnu.org:


Received: (at 46859) by debbugs.gnu.org; 3 Mar 2021 20:02:00 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Mar 03 15:02:00 2021
Received: from localhost ([127.0.0.1]:57075 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lHXh2-0003qj-Bh
	for submit <at> debbugs.gnu.org; Wed, 03 Mar 2021 15:02:00 -0500
Received: from relay7-d.mail.gandi.net ([217.70.183.200]:50145)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <juri@HIDDEN>) id 1lHXh0-0003qJ-3S
 for 46859 <at> debbugs.gnu.org; Wed, 03 Mar 2021 15:01:58 -0500
X-Originating-IP: 91.129.96.116
Received: from mail.gandi.net (m91-129-96-116.cust.tele2.ee [91.129.96.116])
 (Authenticated sender: juri@HIDDEN)
 by relay7-d.mail.gandi.net (Postfix) with ESMTPSA id 8736920002;
 Wed,  3 Mar 2021 20:01:50 +0000 (UTC)
From: Juri Linkov <juri@HIDDEN>
To: Dmitry Gutov <dgutov@HIDDEN>
Subject: Re: bug#46859: 28.0.50; [PATCH]: Add option to truncate long lines
 in xref.el
Organization: LINKOV.NET
References: <m25z2azjxp.fsf@HIDDEN> <87im69uzlt.fsf@HIDDEN>
 <m2wnup9s2y.fsf@HIDDEN> <878s74fv27.fsf@HIDDEN>
 <4119ea3055ef8f306fc0@HIDDEN>
 <d52c0f52-8c8b-0688-e735-c8eacf4ebcdb@HIDDEN>
 <4119ea30557ef84ca190@HIDDEN>
 <7eb7ee0f-7dba-c90d-cb58-af42c3828643@HIDDEN>
 <4119ea30554b406efbbf@HIDDEN>
 <4119ea30558f1e4145b0@HIDDEN>
 <ae221795-5197-36c5-4e0e-e1cb97e2a076@HIDDEN>
 <4119ea30555e80bdcf7e@HIDDEN>
 <1c82e582-8b90-f3c5-5391-1e88ca4e7ab2@HIDDEN>
Date: Wed, 03 Mar 2021 21:59:39 +0200
In-Reply-To: <1c82e582-8b90-f3c5-5391-1e88ca4e7ab2@HIDDEN> (Dmitry Gutov's
 message of "Wed, 3 Mar 2021 21:14:02 +0200")
Message-ID: <875z282el0.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu)
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 46859
Cc: Gregory Heytings <gregory@HIDDEN>, 46859 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)

--=-=-=
Content-Type: text/plain

> We currently don't visit the file buffer if it's not already visited,
> parsing the line in a temp buffer instead. That approach resulted in a nice
> perf improvement.

Reusing visited files is a nice feature, but still needs a fix.

Test case: visit emacs/src/xdisp.c and type

  C-x p g expose_frame RET

See that not all lines from xdisp.c have font-lock highlighting.
After applying this patch, all xref output lines from xdisp.c
have font-lock faces:


--=-=-=
Content-Type: text/x-diff
Content-Disposition: inline; filename=xref-font-lock-ensure.patch

diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index 18fdd963fb..6a5361f852 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -1691,7 +1701,10 @@ xref--collect-matches-1
       (let* ((beg-column (- (match-beginning 0) line-beg))
              (end-column (- (match-end 0) line-beg))
              (loc (xref-make-file-location file line beg-column))
-             (summary (buffer-substring line-beg line-end)))
+             (summary (progn
+                        (unless syntax-needed
+                          (font-lock-ensure line-beg line-end))
+                        (buffer-substring line-beg line-end))))
         (add-face-text-property beg-column end-column 'xref-match
                                 t summary)
         (push (xref-make-match summary loc (- end-column beg-column))

--=-=-=--




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#46859; Package emacs. Full text available.

Message received at 46859 <at> debbugs.gnu.org:


Received: (at 46859) by debbugs.gnu.org; 3 Mar 2021 20:01:57 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Mar 03 15:01:57 2021
Received: from localhost ([127.0.0.1]:57072 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lHXgz-0003qT-5D
	for submit <at> debbugs.gnu.org; Wed, 03 Mar 2021 15:01:57 -0500
Received: from relay1-d.mail.gandi.net ([217.70.183.193]:64107)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <juri@HIDDEN>) id 1lHXgx-0003qE-4L
 for 46859 <at> debbugs.gnu.org; Wed, 03 Mar 2021 15:01:56 -0500
X-Originating-IP: 91.129.96.116
Received: from mail.gandi.net (m91-129-96-116.cust.tele2.ee [91.129.96.116])
 (Authenticated sender: juri@HIDDEN)
 by relay1-d.mail.gandi.net (Postfix) with ESMTPSA id A5D21240003;
 Wed,  3 Mar 2021 20:01:46 +0000 (UTC)
From: Juri Linkov <juri@HIDDEN>
To: Gregory Heytings <gregory@HIDDEN>
Subject: Re: bug#46859: 28.0.50; [PATCH]: Add option to truncate long lines
 in xref.el
Organization: LINKOV.NET
References: <m25z2azjxp.fsf@HIDDEN> <87im69uzlt.fsf@HIDDEN>
 <m2wnup9s2y.fsf@HIDDEN> <878s74fv27.fsf@HIDDEN>
 <4119ea3055ef8f306fc0@HIDDEN>
 <d52c0f52-8c8b-0688-e735-c8eacf4ebcdb@HIDDEN>
 <4119ea30557ef84ca190@HIDDEN>
 <7eb7ee0f-7dba-c90d-cb58-af42c3828643@HIDDEN>
 <4119ea30554b406efbbf@HIDDEN>
 <4119ea30558f1e4145b0@HIDDEN>
 <ae221795-5197-36c5-4e0e-e1cb97e2a076@HIDDEN>
 <4119ea30555e80bdcf7e@HIDDEN>
 <1c82e582-8b90-f3c5-5391-1e88ca4e7ab2@HIDDEN>
 <4119ea30553e3f90ab8c@HIDDEN>
Date: Wed, 03 Mar 2021 21:52:22 +0200
In-Reply-To: <4119ea30553e3f90ab8c@HIDDEN> (Gregory Heytings's message
 of "Wed, 03 Mar 2021 19:34:30 +0000")
Message-ID: <87y2f42ex5.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 46859
Cc: 46859 <at> debbugs.gnu.org, Dmitry Gutov <dgutov@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)

>> 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.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#46859; Package emacs. Full text available.

Message received at 46859 <at> debbugs.gnu.org:


Received: (at 46859) by debbugs.gnu.org; 3 Mar 2021 19:54:51 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Mar 03 14:54:51 2021
Received: from localhost ([127.0.0.1]:57060 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lHXa7-0003eR-36
	for submit <at> debbugs.gnu.org; Wed, 03 Mar 2021 14:54:51 -0500
Received: from out1.migadu.com ([91.121.223.63]:33934)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <theo@HIDDEN>) id 1lHXa5-0003eI-CY
 for 46859 <at> debbugs.gnu.org; Wed, 03 Mar 2021 14:54:50 -0500
X-Report-Abuse: Please report any abuse attempt to abuse@HIDDEN and
 include these headers.
From: Theodor Thornhill <theo@HIDDEN>
To: Dmitry Gutov <dgutov@HIDDEN>, juri@HIDDEN, 46859 <at> debbugs.gnu.org
Subject: Re: bug#46859: 28.0.50; [PATCH]: Add option to truncate long lines
 in xref.el
In-Reply-To: <666564dc-0252-6bf5-04e1-58c9916cffbe@HIDDEN>
References: <m25z2azjxp.fsf@HIDDEN>
 <87im69uzlt.fsf@HIDDEN> <m2wnup9s2y.fsf@HIDDEN>
 <db9bae17-b4ae-ac21-2550-baeb6e714559@HIDDEN>
 <m2mtvlcieg.fsf@HIDDEN>
 <25782781-4baa-5d44-99a1-2e57552ab3a0@HIDDEN>
 <m2sg5cw6yh.fsf@HIDDEN>
 <666564dc-0252-6bf5-04e1-58c9916cffbe@HIDDEN>
Date: Wed, 03 Mar 2021 20:54:46 +0100
Message-ID: <m2lfb4j9mh.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Migadu-Flow: FLOW_OUT
X-Migadu-Auth-User: theo@HIDDEN
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 46859
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)

Hi again,

>> I tried another approach which yielded some nice results.
>
> Thank you.
>
> Could you also try this benchmark with an input string that has no more 
> than, say, 3 matches in the big one-line file? Or maybe just 1.
>
> I'd like to compare the relative performance in such scenario, too.
>

Curiously, it doesn't seem to affect things much, neither for your patch
or mine. 

>> However, only my patch actually renders the long file as a match in the
> output buffer. All the others seem to drop it altogether. IMO that is
> one point in favour of my approaches.
>
> Indeed.
>


>> In addition, we could add another
>> defcustom for the xref--collect-matches-1 function,
>
> That can be done already by the user customizing 
> xref-search-program-alist, I think.

Oh? How so?

--
Theo




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#46859; Package emacs. Full text available.

Message received at 46859 <at> debbugs.gnu.org:


Received: (at 46859) by debbugs.gnu.org; 3 Mar 2021 19:34:35 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Mar 03 14:34:35 2021
Received: from localhost ([127.0.0.1]:57032 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lHXGU-00039u-Op
	for submit <at> debbugs.gnu.org; Wed, 03 Mar 2021 14:34:34 -0500
Received: from heytings.org ([95.142.160.155]:41796)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <gregory@HIDDEN>) id 1lHXGS-00039l-3j
 for 46859 <at> debbugs.gnu.org; Wed, 03 Mar 2021 14:34:32 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=heytings.org;
 s=20210101; t=1614800071;
 bh=1ClAw3RPSUscBSP7kAeCdHcqgKQyynIyTdjzHZclfCg=;
 h=Date:From:To:cc:Subject:In-Reply-To:Message-ID:References:From;
 b=sf6h9AjJRBJlqIkWETzgpj6vTRwz1d0gwYhyXB6H5gwjlOta4WXnK52b45GyIofAQ
 2Q2SZoVLGX2SIm198271v2PDloKWXPNGVKNUN8Esjvh8SV47HdRuE1k8XVCBQkqREh
 N5kDq1EbO3yN2rTMcBM0lZZj+zEz5UHLZNQEyqzC/QQA0Yk+2c7aAybGXzvGAdDiZf
 APSh3E3ZZubjzMVs3Y5D0Jbek74d/JVOwKJKCMfxkDu3p7Vipte10qvJWXYq4D7st1
 EedBdFcjNabFykYdaXe7z2hYoXdMTNnnBwQuTj3AYjfyQVFBJ1EiN+wGdfFeljeTew
 zx9GB8ZQ1jIQA==
Date: Wed, 03 Mar 2021 19:34:30 +0000
From: Gregory Heytings <gregory@HIDDEN>
To: Dmitry Gutov <dgutov@HIDDEN>
Subject: Re: bug#46859: 28.0.50; [PATCH]: Add option to truncate long lines
 in xref.el
In-Reply-To: <1c82e582-8b90-f3c5-5391-1e88ca4e7ab2@HIDDEN>
Message-ID: <4119ea30553e3f90ab8c@HIDDEN>
References: <m25z2azjxp.fsf@HIDDEN> <87im69uzlt.fsf@HIDDEN>
 <m2wnup9s2y.fsf@HIDDEN> <878s74fv27.fsf@HIDDEN>
 <4119ea3055ef8f306fc0@HIDDEN>
 <d52c0f52-8c8b-0688-e735-c8eacf4ebcdb@HIDDEN>
 <4119ea30557ef84ca190@HIDDEN>
 <7eb7ee0f-7dba-c90d-cb58-af42c3828643@HIDDEN>
 <4119ea30554b406efbbf@HIDDEN> <4119ea30558f1e4145b0@HIDDEN>
 <ae221795-5197-36c5-4e0e-e1cb97e2a076@HIDDEN>
 <4119ea30555e80bdcf7e@HIDDEN>
 <1c82e582-8b90-f3c5-5391-1e88ca4e7ab2@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="G0L0IVQL72"
Content-ID: <4119ea30550b7a3e6ebb@HIDDEN>
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 46859
Cc: 46859 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)


--G0L0IVQL72
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: quoted-printable
Content-ID: <4119ea305501a07f8b35@HIDDEN>


>> Yes.=C2=A0 You get, for each match: the line number (from the beginning =
of=20
>> the file), the byte offset (from the beginning of the file) of the=20
>> first displayed character, and the context of the match.
>
> OK, so we get the byte offset, but not the length of the match (which=20
> we'll also need later, for purposes such as highlighting and=20
> replacement). And what happens if there are several matches on the same=
=20
> line? We need columns for all of them.
>

I don't know exactly what you want to do, I initially chimed in this=20
conversation to react to Juri's "GNU grep has no option to truncate=20
output", to mention that GNU grep does have an option to do this; perhaps=
=20
it doesn't do exactly what you want.

I could be wrong, but I believe that adapting what you want to what GNU=20
grep provides will always be more efficient than the opposite.

>> And you can easily get the byte offset of each beginning of line with=20
>> "grep -nbo '^.'", so calculating the byte offset from the beginning of=
=20
>> the line is easy.
>
> Do you mean to suggest we call grep one more time for each matching=20
> line?
>

No, once for each file.  "grep -nbo '^.' FILE" returns a "<line>:<offset=20
of first char>:<first char>" line for each line in FILE.  With this you=20
can easily calculate the offset of a match on a given line.  This will be=
=20
more efficient than calculating the offset of a match by parsing each line=
=20
with Elisp code.
--G0L0IVQL72--




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#46859; Package emacs. Full text available.

Message received at 46859 <at> debbugs.gnu.org:


Received: (at 46859) by debbugs.gnu.org; 3 Mar 2021 19:14:19 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Mar 03 14:14:19 2021
Received: from localhost ([127.0.0.1]:57001 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lHWws-0000XR-Rm
	for submit <at> debbugs.gnu.org; Wed, 03 Mar 2021 14:14:19 -0500
Received: from mail-wr1-f51.google.com ([209.85.221.51]:41692)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <raaahh@HIDDEN>) id 1lHWwm-0000X7-II
 for 46859 <at> debbugs.gnu.org; Wed, 03 Mar 2021 14:14:16 -0500
Received: by mail-wr1-f51.google.com with SMTP id f12so21125343wrx.8
 for <46859 <at> debbugs.gnu.org>; Wed, 03 Mar 2021 11:14:12 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=sender:subject:to:cc:references:from:message-id:date:user-agent
 :mime-version:in-reply-to:content-language:content-transfer-encoding;
 bh=LHPBk0XCfCXkEhAVCSvA7tVLzIRQ+NAnHhub+PslT+A=;
 b=nWcQxORZjjXTeClW8PZJ9N9J+Ng2JnoXmsuwtgS2hCxs0bdGlnEXAJOC4/Yd6U6u1H
 UF01v2izvUKUpHBuiaZ7+Knf5e7rbo8F2LsSSNyWpIS61AO5fj9IiEY0e0HWdSiwIRD1
 k9ihqCXt2YUvFTdYT59sjBpxK50xkgvxJ9RK9Y2AF1sf5O8r7rKlvSUXiiqGSxQvhLwV
 UwA/yfnXwBZAGhVBucTAqcIO+Pd1Bxzdy9inVToJgMm/0aJu46Auf0bV/f36eft+UTHK
 ieL+6bGzhVbkPILUeRMaQzcHQEr3zcofKARWx2BdF3iViCAxVoAUnr3WhTZ4KEEkLqMI
 MGJQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:sender:subject:to:cc:references:from:message-id
 :date:user-agent:mime-version:in-reply-to:content-language
 :content-transfer-encoding;
 bh=LHPBk0XCfCXkEhAVCSvA7tVLzIRQ+NAnHhub+PslT+A=;
 b=j2g9t2TaN0lYzt4DW0WfVkZaYHiNFKqoE1Cfkc8xZJubmPkvjCyNskxDW4oqdf4imD
 +8yY0r6f5UuwwkrUWQ53sHMJDtd3isGCC1BiN7iv7KfthQtWgBhmq8//44yBvDNXE8Ou
 ZQ7GEtB/kp+FynimTLdevndoc2zVYXatk7r/Dm1HhTMV88vMTy+fsoqX4XhQ1mD6ZdGA
 nDzR3GSfVuF5L6+N/Lhx6pLmYpoDxZgPL6ejJiUcPKHtIXO0LHxwijKA5mjTQMybl+mO
 dpLCr6hopPH8Zix6GnnrjPzE4KhhFMYVhYO3H44VvvNPwF33ZszZmd8jxF1QUGZfC/qG
 s64A==
X-Gm-Message-State: AOAM533SCENsHq7qqsokU62k5uRCiGBIU4CjnSqZCm6CIKZqjmb3094k
 823/NNO79LhWNc2vlnrAgZNCuR7GDQM=
X-Google-Smtp-Source: ABdhPJxoWoua+c2vh7tTYGcVZUTYzHNUaxXAZePebBPJouEfCY4eBfqzhQjo0aCFcMEs7DrZUyx+EA==
X-Received: by 2002:adf:e7cf:: with SMTP id e15mr208803wrn.346.1614798846807; 
 Wed, 03 Mar 2021 11:14:06 -0800 (PST)
Received: from [192.168.0.6] ([46.251.119.176])
 by smtp.googlemail.com with ESMTPSA id k4sm43258017wrd.9.2021.03.03.11.14.05
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Wed, 03 Mar 2021 11:14:06 -0800 (PST)
Subject: Re: bug#46859: 28.0.50; [PATCH]: Add option to truncate long lines in
 xref.el
To: Gregory Heytings <gregory@HIDDEN>
References: <m25z2azjxp.fsf@HIDDEN> <87im69uzlt.fsf@HIDDEN>
 <m2wnup9s2y.fsf@HIDDEN> <878s74fv27.fsf@HIDDEN>
 <4119ea3055ef8f306fc0@HIDDEN>
 <d52c0f52-8c8b-0688-e735-c8eacf4ebcdb@HIDDEN>
 <4119ea30557ef84ca190@HIDDEN>
 <7eb7ee0f-7dba-c90d-cb58-af42c3828643@HIDDEN>
 <4119ea30554b406efbbf@HIDDEN> <4119ea30558f1e4145b0@HIDDEN>
 <ae221795-5197-36c5-4e0e-e1cb97e2a076@HIDDEN>
 <4119ea30555e80bdcf7e@HIDDEN>
From: Dmitry Gutov <dgutov@HIDDEN>
Message-ID: <1c82e582-8b90-f3c5-5391-1e88ca4e7ab2@HIDDEN>
Date: Wed, 3 Mar 2021 21:14:02 +0200
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
 Thunderbird/68.10.0
MIME-Version: 1.0
In-Reply-To: <4119ea30555e80bdcf7e@HIDDEN>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.5 (/)
X-Debbugs-Envelope-To: 46859
Cc: 46859 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.5 (/)

On 03.03.2021 19:42, Gregory Heytings wrote:
> 
>>> I wrote too fast.  In fact you can get the column number with GNU 
>>> grep without parsing the original line:
>>>
>>> grep -nb -oE '.{0,100}PATTERN.{0,100}'
>>
>> This outputs byte offset from the beginning of the file, doesn't it?
>>
> 
> Yes.  You get, for each match: the line number (from the beginning of 
> the file), the byte offset (from the beginning of the file) of the first 
> displayed character, and the context of the match.

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.

>> Which will require at least reading the file into memory to convert.
>>
> 
> I don't understand what you mean by that, but it seems to me that in any 
> case it's much more efficient than parsing the output of grep with Elisp.

We currently don't visit the file buffer if it's not already visited, 
parsing the line in a temp buffer instead. That approach resulted in a 
nice perf improvement.

> And you can easily get the byte offset of each beginning of line with 
> "grep -nbo '^.'", so calculating the byte offset from the beginning of 
> the line is easy.

Do you mean to suggest we call grep one more time for each matching line?




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#46859; Package emacs. Full text available.

Message received at 46859 <at> debbugs.gnu.org:


Received: (at 46859) by debbugs.gnu.org; 3 Mar 2021 17:42:21 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Mar 03 12:42:21 2021
Received: from localhost ([127.0.0.1]:56916 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lHVVt-0006Yn-0U
	for submit <at> debbugs.gnu.org; Wed, 03 Mar 2021 12:42:21 -0500
Received: from heytings.org ([95.142.160.155]:41672)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <gregory@HIDDEN>) id 1lHVVr-0006Yf-5Y
 for 46859 <at> debbugs.gnu.org; Wed, 03 Mar 2021 12:42:19 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=heytings.org;
 s=20210101; t=1614793337;
 bh=RCHRnxPk7+omvb4/97UvIk1xoURPrSDYKJ4E+1F0PLo=;
 h=Date:From:To:cc:Subject:In-Reply-To:Message-ID:References:From;
 b=ARwSF0BLOnPoMZdY6X9mPlIJJiYCB8eejhn1pj6SXKcNI9FCViKmMuVekrseSqpR2
 uC930W6UTnHcf9oqdkRTpziFTqflw91WEyPqBk1/94OGzqIpqAwBI/6rzQIT0kwSYY
 OZv0XxzV2nlbE4UQKpd4UjZG3AlID74Q/vyGckeRJrJPMaa2h+AEhBUUUtVzzOmCa0
 BAbOGuzb0jp3tnUsiVQM1WDyDU/srSaRi8n9MkxHu2NZYoPI06+nKYj+OyqYT9mkvG
 jUSFib6iG2lcVId5BP66zs/k7Nir2WY58qxydZuFOfqsdaYl/FXFvEnZgnncIQyQjS
 9SwSN28YCVduw==
Date: Wed, 03 Mar 2021 17:42:17 +0000
From: Gregory Heytings <gregory@HIDDEN>
To: Dmitry Gutov <dgutov@HIDDEN>
Subject: Re: bug#46859: 28.0.50; [PATCH]: Add option to truncate long lines
 in xref.el
In-Reply-To: <ae221795-5197-36c5-4e0e-e1cb97e2a076@HIDDEN>
Message-ID: <4119ea30555e80bdcf7e@HIDDEN>
References: <m25z2azjxp.fsf@HIDDEN> <87im69uzlt.fsf@HIDDEN>
 <m2wnup9s2y.fsf@HIDDEN> <878s74fv27.fsf@HIDDEN>
 <4119ea3055ef8f306fc0@HIDDEN>
 <d52c0f52-8c8b-0688-e735-c8eacf4ebcdb@HIDDEN>
 <4119ea30557ef84ca190@HIDDEN>
 <7eb7ee0f-7dba-c90d-cb58-af42c3828643@HIDDEN>
 <4119ea30554b406efbbf@HIDDEN> <4119ea30558f1e4145b0@HIDDEN>
 <ae221795-5197-36c5-4e0e-e1cb97e2a076@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="fDXorRHs7h"
Content-ID: <4119ea30553ac6192247@HIDDEN>
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 46859
Cc: 46859 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)


--fDXorRHs7h
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: quoted-printable
Content-ID: <4119ea305512c14d3e0a@HIDDEN>


>> I wrote too fast.=C2=A0 In fact you can get the column number with GNU g=
rep=20
>> without parsing the original line:
>>=20
>> grep -nb -oE '.{0,100}PATTERN.{0,100}'
>
> This outputs byte offset from the beginning of the file, doesn't it?
>

Yes.  You get, for each match: the line number (from the beginning of the=
=20
file), the byte offset (from the beginning of the file) of the first=20
displayed character, and the context of the match.

>
> Which will require at least reading the file into memory to convert.
>

I don't understand what you mean by that, but it seems to me that in any=20
case it's much more efficient than parsing the output of grep with Elisp.

And you can easily get the byte offset of each beginning of line with=20
"grep -nbo '^.'", so calculating the byte offset from the beginning of the=
=20
line is easy.
--fDXorRHs7h--




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#46859; Package emacs. Full text available.

Message received at 46859 <at> debbugs.gnu.org:


Received: (at 46859) by debbugs.gnu.org; 3 Mar 2021 17:29:47 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Mar 03 12:29:47 2021
Received: from localhost ([127.0.0.1]:56899 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lHVJj-0006FQ-7l
	for submit <at> debbugs.gnu.org; Wed, 03 Mar 2021 12:29:47 -0500
Received: from mail-wm1-f41.google.com ([209.85.128.41]:34751)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <raaahh@HIDDEN>) id 1lHVJf-0006FB-HW
 for 46859 <at> debbugs.gnu.org; Wed, 03 Mar 2021 12:29:46 -0500
Received: by mail-wm1-f41.google.com with SMTP id
 o7-20020a05600c4fc7b029010a0247d5f0so3242341wmq.1
 for <46859 <at> debbugs.gnu.org>; Wed, 03 Mar 2021 09:29:43 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=sender:subject:to:references:from:message-id:date:user-agent
 :mime-version:in-reply-to:content-language:content-transfer-encoding;
 bh=p5HHyvSY4NXucIrogzqiI8el4iqtNQ6JrcfqERBFFhQ=;
 b=JSNwhberAGxuPUeZJPCCuqRDCQFGDBaqMO6mlu3W30UeyTe9KkTRSFn+Ssc2FLXkaN
 +k86QZvY5G04F10PmRd3U7Vrwe65ZV/CQrcfSrRe5ZTkguKjFC7/aP2EbVhAlXl9TbfF
 BkcNg2pGf20VaNDB601zPHheK6Xyvcl8aZ2Lcgy8DZ5HTz28O6T7PsN3OX/uabzf36BX
 XmSeXNagXF/l56EQpqv5slIgkSLmy8b6zogAOEDmG77VLb4BvCEzDiL9Adk2v7E9GfYv
 I3iCTgkO80uuswO5mCXeSDnCULNGGLvPJfeSv0vmaaeYGzX+B8W9HuI0Z7GrsNKTkvRh
 YZJg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:sender:subject:to:references:from:message-id
 :date:user-agent:mime-version:in-reply-to:content-language
 :content-transfer-encoding;
 bh=p5HHyvSY4NXucIrogzqiI8el4iqtNQ6JrcfqERBFFhQ=;
 b=lF/gDMCEhQSMIa4Lm5yhWgjL5ZFDKeyElMr023de83qh8Nj6+PoqBxCRNfpcXMTEed
 0TG4BLAeDjWjt+CAmuWxNF3Nh4HeZRn9rOoHFHa+l+a+Ht64N1gRhoUWUFNJJu/IQK7x
 G1Wi9Xi7rkyDvOzmOmQXT+tr4w9W2KiRIPGtX7qXqJUwJ12sR51+elkbQPuQ8Ptta5KK
 Z92kLImVgHiqoqLu6qswn+rhay1PWc0LtXBAyNwHPKnAxtPHTcVuajFiSYFxISCngSvt
 15KD+/csAAj2vv5gIuk+/K5lrjvNZ+On363Kdy7NW9MU7J8HlZPxdQqIzVgBSoRty8h/
 CTxQ==
X-Gm-Message-State: AOAM533KWbNZDVFQxRhjxBcxJrIJjEMT8vAlXA7i1JdulMFjxCF2bVAE
 wopjuPk1mMNBcgpCMPhcNqPEz34Pe04=
X-Google-Smtp-Source: ABdhPJz6QZUQCH4yAIwh2oXaGKXP8REl3ojJcWbxudvW1wAuSRaowmCZyC1qz35cUGyZOhNYK9k4gw==
X-Received: by 2002:a05:600c:2282:: with SMTP id 2mr66369wmf.93.1614792577808; 
 Wed, 03 Mar 2021 09:29:37 -0800 (PST)
Received: from [192.168.0.6] ([46.251.119.176])
 by smtp.googlemail.com with ESMTPSA id m10sm6367754wmh.13.2021.03.03.09.29.36
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Wed, 03 Mar 2021 09:29:37 -0800 (PST)
Subject: Re: bug#46859: 28.0.50; [PATCH]: Add option to truncate long lines in
 xref.el
To: Theodor Thornhill <theo@HIDDEN>, juri@HIDDEN,
 46859 <at> debbugs.gnu.org
References: <m25z2azjxp.fsf@HIDDEN> <87im69uzlt.fsf@HIDDEN>
 <m2wnup9s2y.fsf@HIDDEN>
 <db9bae17-b4ae-ac21-2550-baeb6e714559@HIDDEN>
 <m2mtvlcieg.fsf@HIDDEN>
 <25782781-4baa-5d44-99a1-2e57552ab3a0@HIDDEN>
 <m2sg5cw6yh.fsf@HIDDEN>
From: Dmitry Gutov <dgutov@HIDDEN>
Message-ID: <666564dc-0252-6bf5-04e1-58c9916cffbe@HIDDEN>
Date: Wed, 3 Mar 2021 19:29:34 +0200
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
 Thunderbird/68.10.0
MIME-Version: 1.0
In-Reply-To: <m2sg5cw6yh.fsf@HIDDEN>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 7bit
X-Spam-Score: 0.5 (/)
X-Debbugs-Envelope-To: 46859
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.5 (/)

On 03.03.2021 18:13, Theodor Thornhill via Bug reports for GNU Emacs, 
the Swiss army knife of text editors wrote:
> This long line has 25 matches, so yeah, that takes some time. With your
> hint here I tried another approach which yielded some nice results.

Thank you.

Could you also try this benchmark with an input string that has no more 
than, say, 3 matches in the big one-line file? Or maybe just 1.

I'd like to compare the relative performance in such scenario, too.

 > However, only my patch actually renders the long file as a match in the
output buffer. All the others seem to drop it altogether. IMO that is
one point in favour of my approaches.

Indeed.

 > In addition, we could add another
defcustom for the xref--collect-matches-1 function,

That can be done already by the user customizing 
xref-search-program-alist, I think.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#46859; Package emacs. Full text available.

Message received at 46859 <at> debbugs.gnu.org:


Received: (at 46859) by debbugs.gnu.org; 3 Mar 2021 17:26:17 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Mar 03 12:26:16 2021
Received: from localhost ([127.0.0.1]:56891 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lHVGK-0006AN-Nf
	for submit <at> debbugs.gnu.org; Wed, 03 Mar 2021 12:26:16 -0500
Received: from mail-wr1-f53.google.com ([209.85.221.53]:35412)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <raaahh@HIDDEN>) id 1lHVGI-0006A9-0C
 for 46859 <at> debbugs.gnu.org; Wed, 03 Mar 2021 12:26:15 -0500
Received: by mail-wr1-f53.google.com with SMTP id l12so24564074wry.2
 for <46859 <at> debbugs.gnu.org>; Wed, 03 Mar 2021 09:26:13 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=sender:subject:to:cc:references:from:message-id:date:user-agent
 :mime-version:in-reply-to:content-language:content-transfer-encoding;
 bh=gwg6tBHs4uTnZyo1Je+vMwC54F6SHSr/+fXn5nzZ31g=;
 b=k3NrpTTFZR7KAuXYAqzX3v5wX/p3g2bvzsrvkrseuNKHfE6k7080XoMX5F63YO1+wh
 aPAZ2FlAMYdCPLsJw7cYynRp4WsvGYauqT8Ha2GHQOlqAmmh6YdqPpaSIK294sfe+ZpE
 3AodMxibXECuZ7OjbxWgue6G7N5eYZIb55UL4ZC49cu5nZFyI1n/j6EF9Finfxsypi3M
 tAqCPE/fDP+o8Q16JUniMm5JJEOGYGXjcHnNX4CeIN4GvAhU3hrNXMCMCBnsxjgh+oMD
 7eSc/tyP51mHFbSCw1q1fq2ZoMUJbilxhvUn+D+FDXRtl6CiSBHuADawD7s99bSdQp5R
 2Kbg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:sender:subject:to:cc:references:from:message-id
 :date:user-agent:mime-version:in-reply-to:content-language
 :content-transfer-encoding;
 bh=gwg6tBHs4uTnZyo1Je+vMwC54F6SHSr/+fXn5nzZ31g=;
 b=gw8uzTjap/X0jGoee09g+VyagH4StizjfBqINYNEHkKcIX715vUZtLTwhT8uqoRbRd
 XDrPH1QRGcGYEe2/377uVWOn2U1InEgsI0agkKgVxdbqu7IQyBdGC+fAaIK/cHcooaGS
 /LF/VChn8PB/V3Do2ASBzd+9vxjb9h1eyWP9x1A8Ivj5FbLzrlRGrP5mIAgyriHnzUsN
 1KDUjD5g8O06VR7dSDEpN/45EcZ/XVEzAqd0+eMx4ZVxmTeY7q+YFj+rohPE6aDhe1nr
 G0butgRXgAuZVS4LRCCytzZVMlejwRu41rUC0ZULkHtx1ibdbIyc3zHbd8ox4xf9+m0v
 7C0A==
X-Gm-Message-State: AOAM5322nBEC3+sI7zi0efCpe8vMxkeB+pBl/vrh0jpEtLUgFUXrAjqh
 qIgiLC8/fCuWcP50kZ++7B918vwt3gg=
X-Google-Smtp-Source: ABdhPJzv+g24NO/VyQCNwWLaK5v0fR3rdMNyAUHaBuqRQeuNBkImkE+2ILxo4rFZHtt09alrEqiP+w==
X-Received: by 2002:a5d:4587:: with SMTP id p7mr14477004wrq.205.1614792368106; 
 Wed, 03 Mar 2021 09:26:08 -0800 (PST)
Received: from [192.168.0.6] ([46.251.119.176])
 by smtp.googlemail.com with ESMTPSA id e1sm34663728wrd.44.2021.03.03.09.26.05
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Wed, 03 Mar 2021 09:26:06 -0800 (PST)
Subject: Re: bug#46859: 28.0.50; [PATCH]: Add option to truncate long lines in
 xref.el
To: Gregory Heytings <gregory@HIDDEN>
References: <m25z2azjxp.fsf@HIDDEN> <87im69uzlt.fsf@HIDDEN>
 <m2wnup9s2y.fsf@HIDDEN> <878s74fv27.fsf@HIDDEN>
 <4119ea3055ef8f306fc0@HIDDEN>
 <d52c0f52-8c8b-0688-e735-c8eacf4ebcdb@HIDDEN>
 <4119ea30557ef84ca190@HIDDEN>
 <7eb7ee0f-7dba-c90d-cb58-af42c3828643@HIDDEN>
 <4119ea30554b406efbbf@HIDDEN> <4119ea30558f1e4145b0@HIDDEN>
From: Dmitry Gutov <dgutov@HIDDEN>
Message-ID: <ae221795-5197-36c5-4e0e-e1cb97e2a076@HIDDEN>
Date: Wed, 3 Mar 2021 19:26:03 +0200
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
 Thunderbird/68.10.0
MIME-Version: 1.0
In-Reply-To: <4119ea30558f1e4145b0@HIDDEN>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.5 (/)
X-Debbugs-Envelope-To: 46859
Cc: 46859 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.5 (/)

On 03.03.2021 19:11, Gregory Heytings wrote:
> I wrote too fast.  In fact you can get the column number with GNU grep 
> without parsing the original line:
> 
> grep -nb -oE '.{0,100}PATTERN.{0,100}'

This outputs byte offset from the beginning of the file, doesn't it?

Which will require at least reading the file into memory to convert.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#46859; Package emacs. Full text available.

Message received at 46859 <at> debbugs.gnu.org:


Received: (at 46859) by debbugs.gnu.org; 3 Mar 2021 17:11:16 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Mar 03 12:11:16 2021
Received: from localhost ([127.0.0.1]:56874 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lHV1n-0005nZ-U0
	for submit <at> debbugs.gnu.org; Wed, 03 Mar 2021 12:11:16 -0500
Received: from heytings.org ([95.142.160.155]:41640)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <gregory@HIDDEN>) id 1lHV1m-0005nR-Ma
 for 46859 <at> debbugs.gnu.org; Wed, 03 Mar 2021 12:11:15 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=heytings.org;
 s=20210101; t=1614791473;
 bh=LCgcftj7fcUBEktxdraaUo8j/bOOytLop9/p1sqeCzk=;
 h=Date:From:To:cc:Subject:In-Reply-To:Message-ID:References:From;
 b=aEnZMtaIq03fYKtozJmFYBwDqTWaX8QcAbGcg5Y+S9qfBLkBQEzI9/J2+HSRagcz4
 ldYQv9Gip+nvRu3JV/bDJiR2jQtLtnEohnC/bmJhnBD6kQmuJ2xnzyWZKOLGvfCLkG
 3lX5lR59yum7BaIdKqLf0fStQN1FQo8JUz0Eod4cII2c381CNCn2PmoI/VW7rNDkZz
 P232TQDkK3ztJsK7bu6rfjMoDfjUeDV/OKNPaWpW0r1KllAMIHQ5Crq+3uLr2V1mnO
 2QS+nX5e3AybwI6o2SryEKUk/7pAces9FZOmWghqjObN8sEXh6ploOY/QdC8SjnYmx
 Zp/DVAqfo5hPA==
Date: Wed, 03 Mar 2021 17:11:12 +0000
From: Gregory Heytings <gregory@HIDDEN>
To: Dmitry Gutov <dgutov@HIDDEN>
Subject: Re: bug#46859: 28.0.50; [PATCH]: Add option to truncate long lines
 in xref.el
In-Reply-To: <4119ea30554b406efbbf@HIDDEN>
Message-ID: <4119ea30558f1e4145b0@HIDDEN>
References: <m25z2azjxp.fsf@HIDDEN> <87im69uzlt.fsf@HIDDEN>
 <m2wnup9s2y.fsf@HIDDEN> <878s74fv27.fsf@HIDDEN>
 <4119ea3055ef8f306fc0@HIDDEN>
 <d52c0f52-8c8b-0688-e735-c8eacf4ebcdb@HIDDEN>
 <4119ea30557ef84ca190@HIDDEN>
 <7eb7ee0f-7dba-c90d-cb58-af42c3828643@HIDDEN>
 <4119ea30554b406efbbf@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="6lDZpfECT8"
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 46859
Cc: 46859 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)


--6lDZpfECT8
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: quoted-printable


>>> How so?=C2=A0 AFAICS, it's the exact same kind of output, except that i=
t=20
>>> gets truncated.=C2=A0 And it's (obviously?) better to see the context o=
f=20
>>> the pattern you are searching for, instead of the first characters of=
=20
>>> the lines on which the pattern is found, in which the pattern might=20
>>> not be present.
>>=20
>> Since Grep doesn't return the column number of the match, we get it=20
>> from parsing the string again. And if the string is now modified to be=
=20
>> truncated from both sides, the column number will become wrong.
>
> I did not understand that you need the column number of the match.=20
> That could perhaps become a feature request for GNU grep: with -o and=20
> -n, also print the column number of the first character.
>

I wrote too fast.  In fact you can get the column number with GNU grep=20
without parsing the original line:

grep -nb -oE '.{0,100}PATTERN.{0,100}'
--6lDZpfECT8--




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#46859; Package emacs. Full text available.

Message received at 46859 <at> debbugs.gnu.org:


Received: (at 46859) by debbugs.gnu.org; 3 Mar 2021 16:14:48 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Mar 03 11:14:48 2021
Received: from localhost ([127.0.0.1]:56737 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lHU9A-0004KN-C0
	for submit <at> debbugs.gnu.org; Wed, 03 Mar 2021 11:14:48 -0500
Received: from out1.migadu.com ([91.121.223.63]:18591)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <theo@HIDDEN>) id 1lHU98-0004KE-BU
 for 46859 <at> debbugs.gnu.org; Wed, 03 Mar 2021 11:14:47 -0500
X-Report-Abuse: Please report any abuse attempt to abuse@HIDDEN and
 include these headers.
From: Theodor Thornhill <theo@HIDDEN>
To: Juri Linkov <juri@HIDDEN>
Subject: Re: bug#46859: 28.0.50; [PATCH]: Add option to truncate long lines
 in xref.el
In-Reply-To: <878s74fv27.fsf@HIDDEN>
References: <m25z2azjxp.fsf@HIDDEN>
 <87im69uzlt.fsf@HIDDEN> <m2wnup9s2y.fsf@HIDDEN>
 <878s74fv27.fsf@HIDDEN>
Date: Wed, 03 Mar 2021 17:14:43 +0100
Message-ID: <m2pn0gw6x8.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Migadu-Flow: FLOW_OUT
X-Migadu-Auth-User: theo@HIDDEN
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 46859
Cc: 46859 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)

Hi Juri,

Juri Linkov <juri@HIDDEN> writes:

>>> But maybe your new option would be easier to customize.
>>
>> Yeah, maybe.  However, without benchmarking, it is quite clear that
>> adding your option is faster than my patch, since ripgrep has to search
>> the whole minified file.  I assume it short circuits, so that results
>> are delivered quicker to emacs.  Maybe this bug can be closed.
>
> Your new option is still necessary for the default case when
> 'xref-search-program' is 'grep' since GNU grep has no option
> to truncate output, so xref should do post-processing for grep.

Yeah, agreed

--
Theo




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#46859; Package emacs. Full text available.

Message received at 46859 <at> debbugs.gnu.org:


Received: (at 46859) by debbugs.gnu.org; 3 Mar 2021 16:14:07 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Mar 03 11:14:07 2021
Received: from localhost ([127.0.0.1]:56725 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lHU8U-0004In-P1
	for submit <at> debbugs.gnu.org; Wed, 03 Mar 2021 11:14:07 -0500
Received: from out0.migadu.com ([94.23.1.103]:20484)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <theo@HIDDEN>) id 1lHU8Q-0004ID-Ct
 for 46859 <at> debbugs.gnu.org; Wed, 03 Mar 2021 11:14:05 -0500
X-Report-Abuse: Please report any abuse attempt to abuse@HIDDEN and
 include these headers.
From: Theodor Thornhill <theo@HIDDEN>
To: Dmitry Gutov <dgutov@HIDDEN>, juri@HIDDEN, 46859 <at> debbugs.gnu.org
Subject: Re: bug#46859: 28.0.50; [PATCH]: Add option to truncate long lines
 in xref.el
In-Reply-To: <25782781-4baa-5d44-99a1-2e57552ab3a0@HIDDEN>
References: <m25z2azjxp.fsf@HIDDEN>
 <87im69uzlt.fsf@HIDDEN> <m2wnup9s2y.fsf@HIDDEN>
 <db9bae17-b4ae-ac21-2550-baeb6e714559@HIDDEN>
 <m2mtvlcieg.fsf@HIDDEN>
 <25782781-4baa-5d44-99a1-2e57552ab3a0@HIDDEN>
Date: Wed, 03 Mar 2021 17:13:58 +0100
Message-ID: <m2sg5cw6yh.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Migadu-Flow: FLOW_OUT
X-Migadu-Auth-User: theo@HIDDEN
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 46859
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)

Hi again!
Dmitry Gutov <dgutov@HIDDEN> writes:

> On 03.03.2021 00:14, Theodor Thornhill via Bug reports for GNU Emacs, 
> the Swiss army knife of text editors wrote:
>> I'm interested in seeing if I could gain some more
>> performance by short circuiting after the first iteration of a match on
>> the same line.  In my test scenario there are a lot of matches on the
>> same huge line.  What do you think?

I couldn't really find any approaches that yielded better results with
short-circuiting in mind, so I dropped that idea.

> You probably mean to short-circuit as soon as you reach the target 

>
> ...of course, ideally we would keep all contents of the line somewhere 
> in memory and truncate with (setq truncate-line t). But IIRC Juri said 
> this didn't give us as much of a speedup as we'd want.
>
> Another question: how many hits do you usually have in that huge 
> one-line file? If it's more than 2-3, it might be that our current 
> algorithm which creates "match objects" will duplicate this string 
> unnecessarily N times (which is the number of hits), in 
> xref--collect-matches-1, to then cut it up and merge into one line again 
> when printing the buffer. In which case the patch above should also show 
> a healthy improvement, but we could figure out something better instead.
>

This long line has 25 matches, so yeah, that takes some time. With your
hint here I tried another approach which yielded some nice results.

Ok, some benchmarks:

;; With nothing
(benchmark-run 10 (project-find-regexp "UrlChange")) ;; (11.748253 14 0.23526199999999997)

;; With -M 500
(benchmark-run 10 (project-find-regexp "UrlChange")) ;; (0.293626 0 0.0)

;; My first patch
(benchmark-run 10 (project-find-regexp "UrlChange")) ;; (1.230833 8 0.13783999999999996)

;; Dmitrys patch
(benchmark-run 10 (project-find-regexp "UrlChange")) ;; (1.007787 0 0.0)

;; Latest diff (attached at the bottom)
(benchmark-run 10 (project-find-regexp "UrlChange")) ;; (1.0351299999999999 0 0.0)


So there are some interesting findings here:

- There are some improvements to gain
- None so far kills "-M 500"
- Pretty close between Dmitrys and my last patch

However, only my patch actually renders the long file as a match in the
output buffer. All the others seem to drop it altogether. IMO that is
one point in favour of my approaches. In addition, we could add another
defcustom for the xref--collect-matches-1 function,
"xref--collect-all-matches-p" or something like that. Retrofitting the
current variable seems a little off. That means you could customize xref
to render the whole long line if you want, while not bothering about
multiple matches. Not sure if that has a great benefit, though.

What do you think? Are any of these approaches worth pursuing further?

--
Theo


diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index 18fdd963fb..fb422dcffa 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -872,6 +872,18 @@ beginning of the line."
       (xref--search-property 'xref-item))
   (xref-show-location-at-point))
 
+(defcustom xref-truncate-line-to 500
+  "Max number of columns to display in xref buffer."
+  :type '(choice
+          (fixnum :tag "Number of lines")
+          (null :tag "Don't truncate"))
+  :version "28.1"
+  :package-version '(xref . "1.0.5"))
+
+(defun xref--truncate-long-lines-p (summary)
+  (and (numberp xref-truncate-line-to)
+       (> (length summary) xref-truncate-line-to)))
+
 (defun xref--insert-xrefs (xref-alist)
   "Insert XREF-ALIST in the current-buffer.
 XREF-ALIST is of the form ((GROUP . (XREF ...)) ...), where
@@ -902,14 +914,22 @@ GROUP is a string for decoration purposes and XREF is an
                                 "  ")))
                         ;; Render multiple matches on the same line, together.
                         (when (and line (equal prev-line-key line-key))
-                          (when-let ((column (xref-location-column location)))
-                            (delete-region
-                             (save-excursion
-                               (forward-line -1)
-                               (move-to-column (+ (length prefix) column))
+                          (if (xref--truncate-long-lines-p summary)
+                              (delete-region
+                               (save-excursion (forward-line -1) (point))
+                               (point))
+                            (when-let ((column (xref-location-column location)))
+                              (delete-region
+                               (save-excursion
+                                 (forward-line -1)
+                                 (move-to-column (+ (length prefix) column))
+                                 (point))
                                (point))
-                             (point))
-                            (setq new-summary (substring summary column) prefix "")))
+                              (setq new-summary (substring summary column) prefix ""))))
+                        (when (xref--truncate-long-lines-p new-summary)
+                          (setq new-summary
+                                (concat (substring new-summary 0 xref-truncate-line-to)
+                                        " (...truncated)")))
                         (xref--insert-propertized
                          (list 'xref-item xref
                                'mouse-face 'highlight
@@ -1678,7 +1698,7 @@ Such as the current syntax table and the applied syntax properties."
                                  syntax-needed)))))
 
 (defun xref--collect-matches-1 (regexp file line line-beg line-end syntax-needed)
-  (let (matches)
+  (let (matches prev-line)
     (when syntax-needed
       (syntax-propertize line-end))
     ;; FIXME: This results in several lines with the same
@@ -1688,14 +1708,18 @@ Such as the current syntax table and the applied syntax properties."
             (or (null matches)
                 (> (point) line-beg))
             (re-search-forward regexp line-end t))
-      (let* ((beg-column (- (match-beginning 0) line-beg))
-             (end-column (- (match-end 0) line-beg))
-             (loc (xref-make-file-location file line beg-column))
-             (summary (buffer-substring line-beg line-end)))
-        (add-face-text-property beg-column end-column 'xref-match
-                                t summary)
-        (push (xref-make-match summary loc (- end-column beg-column))
-              matches)))
+
+      (unless (and (eq prev-line line)
+                   (numberp xref-truncate-line-to))
+        (let* ((beg-column (- (match-beginning 0) line-beg))
+               (end-column (- (match-end 0) line-beg))
+               (loc (xref-make-file-location file line beg-column))
+               (summary (buffer-substring line-beg line-end)))
+          (add-face-text-property beg-column end-column 'xref-match
+                                  t summary)
+          (push (xref-make-match summary loc (- end-column beg-column))
+                matches)))
+      (setq prev-line line))
     (nreverse matches)))
 
 (defun xref--find-file-buffer (file)




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#46859; Package emacs. Full text available.

Message received at 46859 <at> debbugs.gnu.org:


Received: (at 46859) by debbugs.gnu.org; 3 Mar 2021 15:04:25 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Mar 03 10:04:25 2021
Received: from localhost ([127.0.0.1]:56603 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lHT33-0000L5-AA
	for submit <at> debbugs.gnu.org; Wed, 03 Mar 2021 10:04:25 -0500
Received: from heytings.org ([95.142.160.155]:41470)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <gregory@HIDDEN>) id 1lHT31-0000Kx-Jg
 for 46859 <at> debbugs.gnu.org; Wed, 03 Mar 2021 10:04:24 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=heytings.org;
 s=20210101; t=1614783862;
 bh=gvlZQhi64dHvbleT13x4EmschqlJ2ZJNlAIzvg5U4a8=;
 h=Date:From:To:cc:Subject:In-Reply-To:Message-ID:References:From;
 b=n3BsQVWD48Rl01SaGwwOGJyoDVW//aJCYinXtNp6crqm8eoKsJE1MwjwyKN1rVdvu
 iPz0DId+8fEn04q0XHjhCnLbQwYQ5gxuaXLtkbjnZCxRmEQuKM9RTp2PQ5sgDINuyG
 rwu+3y6rAc+g2v0fsdFo2cQ98UFiClxX+kmYaGcwmBpOw4yrWa6Dvo+7SVbh8DfE5/
 3kgkgXCUNfmCZ2o+nQ9wyPGjb1go15VBquHHZi0SbG9tUB57PGOUrh6wIzrRdoKqTV
 5a8bCY4pn/Y/s9D4bEw6592GY/VuXmXwZCDrmSRCaUlcabt697qkxuve8ii4ABiuCE
 ZEt3WsOJNtxBQ==
Date: Wed, 03 Mar 2021 15:04:22 +0000
From: Gregory Heytings <gregory@HIDDEN>
To: Dmitry Gutov <dgutov@HIDDEN>
Subject: Re: bug#46859: 28.0.50; [PATCH]: Add option to truncate long lines
 in xref.el
In-Reply-To: <7eb7ee0f-7dba-c90d-cb58-af42c3828643@HIDDEN>
Message-ID: <4119ea30554b406efbbf@HIDDEN>
References: <m25z2azjxp.fsf@HIDDEN> <87im69uzlt.fsf@HIDDEN>
 <m2wnup9s2y.fsf@HIDDEN> <878s74fv27.fsf@HIDDEN>
 <4119ea3055ef8f306fc0@HIDDEN>
 <d52c0f52-8c8b-0688-e735-c8eacf4ebcdb@HIDDEN>
 <4119ea30557ef84ca190@HIDDEN>
 <7eb7ee0f-7dba-c90d-cb58-af42c3828643@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="6ZRdvFg1td"
Content-ID: <4119ea3055bd958c98f8@HIDDEN>
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 46859
Cc: 46859 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)


--6ZRdvFg1td
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: quoted-printable
Content-ID: <4119ea30556dcf8da8d0@HIDDEN>


>> How so?=C2=A0 AFAICS, it's the exact same kind of output, except that it=
=20
>> gets truncated.=C2=A0 And it's (obviously?) better to see the context of=
 the=20
>> pattern you are searching for, instead of the first characters of the=20
>> lines on which the pattern is found, in which the pattern might not be=
=20
>> present.
>
> Since Grep doesn't return the column number of the match, we get it from=
=20
> parsing the string again. And if the string is now modified to be=20
> truncated from both sides, the column number will become wrong.
>

I did not understand that you need the column number of the match.  That=20
could perhaps become a feature request for GNU grep: with -o and -n, also=
=20
print the column number of the first character.

That being said, if you truncate the N first characters of the matching=20
line, you have to parse the original line (that is, not the line that grep=
=20
or another tool outputs) to find the matches anyway.
--6ZRdvFg1td--




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#46859; Package emacs. Full text available.

Message received at 46859 <at> debbugs.gnu.org:


Received: (at 46859) by debbugs.gnu.org; 3 Mar 2021 14:01:07 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Mar 03 09:01:07 2021
Received: from localhost ([127.0.0.1]:55426 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lHS3m-0004pw-Rc
	for submit <at> debbugs.gnu.org; Wed, 03 Mar 2021 09:01:07 -0500
Received: from mail-wm1-f48.google.com ([209.85.128.48]:39301)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <raaahh@HIDDEN>) id 1lHS3k-0004pK-9l
 for 46859 <at> debbugs.gnu.org; Wed, 03 Mar 2021 09:01:04 -0500
Received: by mail-wm1-f48.google.com with SMTP id u125so6429096wmg.4
 for <46859 <at> debbugs.gnu.org>; Wed, 03 Mar 2021 06:01:04 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=sender:subject:to:cc:references:from:message-id:date:user-agent
 :mime-version:in-reply-to:content-language:content-transfer-encoding;
 bh=T4Y+TKmLrCYoNyuSyp5ZFciorkbm2yis+/A57ViYieY=;
 b=TkUPMr7xLjjNXWUTsSJDWtaJiIsVb8DmiAGCWhcrfCvbvIs/ZSJeaeThelHgXqcK8y
 bYbnJMQaqDhYmnh4eiVvsXJBfxeyn3ohvgnRBugs+72Zb0g7Q1fIFdlCPByWHZBPUqmd
 0he9qs30ze0YUJOj+ckpKr6M9jxiUcxx5ARg0DhyjA42VNm7zNnzHCzHNWW9R8Cryyec
 opAQrzLW4cQ9lQELD69Yyh3c+WfW5DvLUt2oMrywluL5hj3Sj8ZPZ4oB+/n9jOItpnWa
 GoJPgQV/9Xt+8sCTud6hD7+b99bGQfjSlA23xUMet1ahBxtsd9oZaP2Mva1g70FtEjox
 uvhw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:sender:subject:to:cc:references:from:message-id
 :date:user-agent:mime-version:in-reply-to:content-language
 :content-transfer-encoding;
 bh=T4Y+TKmLrCYoNyuSyp5ZFciorkbm2yis+/A57ViYieY=;
 b=nnuIVxZ+f7PrjoJrxGf9YYvUqS7NuEHAy2PUgXvgoZQ9dJppGR68w87J2tNq3fOMyA
 Ze9MBwzH4LGbCjsFXZomFiup9FIOjiIVPUh9s47WLpxcNfvQo72UckiA3SUemq4PbEqW
 OPrXW6rUaFYY0CIywfokhie/qTxU3ZMuURaMrwA1U24X7ukEM55wRnRcbVGmSSID7xkt
 yjy9uBiuVJa075O81km+E0Bm3kS8nff5oGDj8KKoIa4NTIKU0Mf4tMuRNGzCf/rf0Eze
 tzAgYm+ZRqFenC7/yl2NiN4Q5fKw+RDxunRDWXeaUiIGOnQEYiab0o6jcauX5IDmB03V
 rSiw==
X-Gm-Message-State: AOAM532qE4gVVe4Af78zTsCCH9fJBeiiD/05PZsmYk66CeIc6363SBLd
 9lzpQIm3iNXcV6n5Z8vU+VFpUAyxMh0=
X-Google-Smtp-Source: ABdhPJzcKTTZaiPYO2j8x7zRcIj77V3XbcoUSQkyRerxKMmQ0tZTk/FBlj/pxANrRMZugT8HGnC/zA==
X-Received: by 2002:a1c:2155:: with SMTP id h82mr9436256wmh.169.1614780058317; 
 Wed, 03 Mar 2021 06:00:58 -0800 (PST)
Received: from [192.168.0.6] ([46.251.119.176])
 by smtp.googlemail.com with ESMTPSA id x25sm7724540wmj.14.2021.03.03.06.00.56
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Wed, 03 Mar 2021 06:00:57 -0800 (PST)
Subject: Re: bug#46859: 28.0.50; [PATCH]: Add option to truncate long lines in
 xref.el
To: Gregory Heytings <gregory@HIDDEN>
References: <m25z2azjxp.fsf@HIDDEN> <87im69uzlt.fsf@HIDDEN>
 <m2wnup9s2y.fsf@HIDDEN> <878s74fv27.fsf@HIDDEN>
 <4119ea3055ef8f306fc0@HIDDEN>
 <d52c0f52-8c8b-0688-e735-c8eacf4ebcdb@HIDDEN>
 <4119ea30557ef84ca190@HIDDEN>
From: Dmitry Gutov <dgutov@HIDDEN>
Message-ID: <7eb7ee0f-7dba-c90d-cb58-af42c3828643@HIDDEN>
Date: Wed, 3 Mar 2021 16:00:55 +0200
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
 Thunderbird/68.10.0
MIME-Version: 1.0
In-Reply-To: <4119ea30557ef84ca190@HIDDEN>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.5 (/)
X-Debbugs-Envelope-To: 46859
Cc: 46859 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.5 (/)

On 03.03.2021 15:53, Gregory Heytings wrote:
> How so?  AFAICS, it's the exact same kind of output, except that it gets 
> truncated.  And it's (obviously?) better to see the context of the 
> pattern you are searching for, instead of the first characters of the 
> lines on which the pattern is found, in which the pattern might not be 
> present.

Since Grep doesn't return the column number of the match, we get it from 
parsing the string again. And if the string is now modified to be 
truncated from both sides, the column number will become wrong.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#46859; Package emacs. Full text available.

Message received at 46859 <at> debbugs.gnu.org:


Received: (at 46859) by debbugs.gnu.org; 3 Mar 2021 13:54:08 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Mar 03 08:54:08 2021
Received: from localhost ([127.0.0.1]:55422 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lHRwy-0004dU-B2
	for submit <at> debbugs.gnu.org; Wed, 03 Mar 2021 08:54:08 -0500
Received: from heytings.org ([95.142.160.155]:41388)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <gregory@HIDDEN>) id 1lHRws-0004d1-AW
 for 46859 <at> debbugs.gnu.org; Wed, 03 Mar 2021 08:54:02 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=heytings.org;
 s=20210101; t=1614779636;
 bh=zy8Ydqx+6csVq8aAuj3N7PorcTaHh4gT6va1uhwBl9w=;
 h=Date:From:To:cc:Subject:In-Reply-To:Message-ID:References:From;
 b=c6zTzzPdzJEorR59ACOP6g9Du7pa2RYTRmc7VvRkQayxWLdBu+f3dJ4HIVeDjWUCO
 KwuEOR84QzAT3/081Gr7jPcEkwzkYtSsiMQHoajbP1UdU/55fk+LyZnsxK/4J3JaW3
 LjjI81rJuXU8ebRv8IUnNoin10fP7wukA3KYovZJGq3aeQKzAA/lIzPLVJWBdJvGgC
 Dgj9MKOqfWo6n5EODbbYC6/0Bmq01ukMBDhnVMcMiLhii3xy4I96Z/rdu8mtnsQZ0m
 W5zu77dzYXmArNOL9a7omRNbyGl2C13HQ8t3OJ7jzpMuhk9M7qf98IWfgWJXywFUDc
 aRnFz4Xa/lmrg==
Date: Wed, 03 Mar 2021 13:53:56 +0000
From: Gregory Heytings <gregory@HIDDEN>
To: Dmitry Gutov <dgutov@HIDDEN>
Subject: Re: bug#46859: 28.0.50; [PATCH]: Add option to truncate long lines
 in xref.el
In-Reply-To: <d52c0f52-8c8b-0688-e735-c8eacf4ebcdb@HIDDEN>
Message-ID: <4119ea30557ef84ca190@HIDDEN>
References: <m25z2azjxp.fsf@HIDDEN> <87im69uzlt.fsf@HIDDEN>
 <m2wnup9s2y.fsf@HIDDEN> <878s74fv27.fsf@HIDDEN>
 <4119ea3055ef8f306fc0@HIDDEN>
 <d52c0f52-8c8b-0688-e735-c8eacf4ebcdb@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="rQ53CY9bon"
Content-ID: <4119ea3055caa77083e0@HIDDEN>
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 46859
Cc: 46859 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)


--rQ53CY9bon
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: quoted-printable
Content-ID: <4119ea3055f423fb8702@HIDDEN>


>> Actually, it is possible to truncate output with GNU grep:
>>=20
>> grep -oE '.{0,100}PATTERN.{0,100}'
>>=20
>> prints at most 100 characters before and after PATTERN.=C2=A0 I find thi=
s=20
>> much better than ripgrep -M.
>
> I'm not sure how to parse that output (it would be quite different from=
=20
> what we get now),
>

How so?  AFAICS, it's the exact same kind of output, except that it gets=20
truncated.  And it's (obviously?) better to see the context of the pattern=
=20
you are searching for, instead of the first characters of the lines on=20
which the pattern is found, in which the pattern might not be present.

>
> and if the one-long-line file has many matches inside, we'll still get=20
> them all, which we might or might not want.
>

Indeed, if one-long-line has many matches inside, you'll get them all,=20
which IMO makes perfect sense.

Note that this does not happen when all matches are inside the boundaries.=
=20
For example, if your search for '.{0,100}b.{0,100}' on "aaaabbbbcccc", you=
=20
get a single match; if you search for '.{0,1}b.{0,1}' on that same string=
=20
you get two matches.
--rQ53CY9bon--




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#46859; Package emacs. Full text available.

Message received at 46859 <at> debbugs.gnu.org:


Received: (at 46859) by debbugs.gnu.org; 3 Mar 2021 12:47:18 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Mar 03 07:47:18 2021
Received: from localhost ([127.0.0.1]:55345 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lHQuM-0000jL-C7
	for submit <at> debbugs.gnu.org; Wed, 03 Mar 2021 07:47:18 -0500
Received: from mail-wm1-f43.google.com ([209.85.128.43]:34336)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <raaahh@HIDDEN>) id 1lHQuJ-0000j2-JN
 for 46859 <at> debbugs.gnu.org; Wed, 03 Mar 2021 07:47:16 -0500
Received: by mail-wm1-f43.google.com with SMTP id
 o7-20020a05600c4fc7b029010a0247d5f0so2777215wmq.1
 for <46859 <at> debbugs.gnu.org>; Wed, 03 Mar 2021 04:47:15 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=sender:subject:to:cc:references:from:message-id:date:user-agent
 :mime-version:in-reply-to:content-language:content-transfer-encoding;
 bh=ntVYEkF70JwxJqv7jsDix2Y7zPgxcdHnZf8s8RyL5SE=;
 b=Bcte3cZiNItwWAhAT5T4ADeTOX9o/HezR907XmyQ4I/C4l7HOkdOC9JupEc/C/llUK
 YKUuo7RH8xfECzlZ8FP104O84NxbLjuJKhWpY1OGJ5Vj4WC6ixtbGge+BiwS0T0Xuiu7
 i8ZEi+kMU0DzUALluwVnfqhJnt9tpgRdQwI1QWV4zZht3Ul8j84Mj7bdjPW6lBofUDdX
 2H2Eq6EINgfl0KKeHLDdioxpKJhHa7wVixevACbf8PuPXVlBm093EWsiKGYP3neUDBA7
 mA49u5V5l0Y6CrUtMxZWJQClhD7buZgLqljwnBCvqWVvhF+N+eFSX5ljZNrg7L0u6gbK
 lYsQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:sender:subject:to:cc:references:from:message-id
 :date:user-agent:mime-version:in-reply-to:content-language
 :content-transfer-encoding;
 bh=ntVYEkF70JwxJqv7jsDix2Y7zPgxcdHnZf8s8RyL5SE=;
 b=XKOF2LfpmxuVPZZpDwFDNc/6q6lIezcmqe8JH6QoTY7yciPVKI8hECKaotIJV1eSul
 xR5FJ6FleokzKqJZtUGgozBCgY46nHsWwIyEhM6pz1Qb8ZeiR6JlLBbw8JgYhmXtkDSe
 1OAmbNExMEOlnji/8lGSEbsRpRJl4iJgJqq47T7crkq2iXEW+SUHXbMrB/NeAp6ocESP
 AZRLRoBnMYyKnQzJ6fjp9/Dn618YQiEGGWCgjJJU6ZZF90/5WPkIxY0a7d47bYz3/ZsS
 Ashr9huPRuZCCvBUAw6MWVj50tS17oCEo32zeYANUdM4xYZgybVwCYSC02lyV7+2Sn2Q
 aPmg==
X-Gm-Message-State: AOAM532nrXLm0lERRKijT7TL8iHhODzRItEGAw1YADR4cVbINFMNxVPT
 FZkXpFIZtT3BhX9/6caYodpzsvlw2JY=
X-Google-Smtp-Source: ABdhPJyLJ8rSrg2Q7ggU5jDMPAcjI57Dkrj5mDmFkhcsczksvXspLhDC1jSbcB83HciZtPWziuly0w==
X-Received: by 2002:a1c:4382:: with SMTP id q124mr9196371wma.16.1614775629685; 
 Wed, 03 Mar 2021 04:47:09 -0800 (PST)
Received: from [192.168.0.6] ([46.251.119.176])
 by smtp.googlemail.com with ESMTPSA id i8sm37560688wry.90.2021.03.03.04.47.07
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Wed, 03 Mar 2021 04:47:08 -0800 (PST)
Subject: Re: bug#46859: 28.0.50; [PATCH]: Add option to truncate long lines in
 xref.el
To: Gregory Heytings <gregory@HIDDEN>, Juri Linkov <juri@HIDDEN>
References: <m25z2azjxp.fsf@HIDDEN> <87im69uzlt.fsf@HIDDEN>
 <m2wnup9s2y.fsf@HIDDEN> <878s74fv27.fsf@HIDDEN>
 <4119ea3055ef8f306fc0@HIDDEN>
From: Dmitry Gutov <dgutov@HIDDEN>
Message-ID: <d52c0f52-8c8b-0688-e735-c8eacf4ebcdb@HIDDEN>
Date: Wed, 3 Mar 2021 14:47:05 +0200
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
 Thunderbird/68.10.0
MIME-Version: 1.0
In-Reply-To: <4119ea3055ef8f306fc0@HIDDEN>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.5 (/)
X-Debbugs-Envelope-To: 46859
Cc: 46859 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.5 (/)

On 03.03.2021 11:52, Gregory Heytings wrote:
> Actually, it is possible to truncate output with GNU grep:
> 
> grep -oE '.{0,100}PATTERN.{0,100}'
> 
> prints at most 100 characters before and after PATTERN.  I find this 
> much better than ripgrep -M.

I'm not sure how to parse that output (it would be quite different from 
what we get now), and if the one-long-line file has many matches inside, 
we'll still get them all, which we might or might not want.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#46859; Package emacs. Full text available.

Message received at 46859 <at> debbugs.gnu.org:


Received: (at 46859) by debbugs.gnu.org; 3 Mar 2021 09:52:43 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Mar 03 04:52:43 2021
Received: from localhost ([127.0.0.1]:55206 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lHOBP-0000dZ-0P
	for submit <at> debbugs.gnu.org; Wed, 03 Mar 2021 04:52:43 -0500
Received: from heytings.org ([95.142.160.155]:41174)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <gregory@HIDDEN>) id 1lHOBM-0000dO-U7
 for 46859 <at> debbugs.gnu.org; Wed, 03 Mar 2021 04:52:41 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=heytings.org;
 s=20210101; t=1614765159;
 bh=YYgOc0gHcS0ato+zRr/MXUaAGmAK2Gs5QaJ/hv/DBLY=;
 h=Date:From:To:cc:Subject:In-Reply-To:Message-ID:References:From;
 b=wMAZkhtJ+IWqGCCoBEoeCMeaKY7VWMWAv/HgtYjpxzLIJa4+2lvlgaOXtqYWj3gLe
 AGTh0ircyWHb3CjR7o23HI08WB26G+7TUyrOxCNxJoQGhIcUzFnMlu6OEwNmistbUI
 Cqmotgj2wDxMwXutkxpPDFQnx+vp3IAj8FQ9s0Fw60/30QU4L3ZzHcraz6/lcGT5Ut
 bbqchkXYVdvpruK/+pVpAiqgj+Fwm3sDtvgasSVucP7lRlIfGcjP8eN4H1/nnX5Vhp
 mzCdHKLcn7LHOjNYC/DH1EnZc34NDCKBeoBtx8o15Y+8pM1PIjm/65aWf7FW8xtE+p
 FK3q7KEdC/0Jw==
Date: Wed, 03 Mar 2021 09:52:38 +0000
From: Gregory Heytings <gregory@HIDDEN>
To: Juri Linkov <juri@HIDDEN>
Subject: Re: bug#46859: 28.0.50; [PATCH]: Add option to truncate long lines
 in xref.el
In-Reply-To: <878s74fv27.fsf@HIDDEN>
Message-ID: <4119ea3055ef8f306fc0@HIDDEN>
References: <m25z2azjxp.fsf@HIDDEN> <87im69uzlt.fsf@HIDDEN>
 <m2wnup9s2y.fsf@HIDDEN> <878s74fv27.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; format=flowed; charset=us-ascii
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 46859
Cc: 46859 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)


>>> But maybe your new option would be easier to customize.
>>
>> Yeah, maybe.  However, without benchmarking, it is quite clear that 
>> adding your option is faster than my patch, since ripgrep has to search 
>> the whole minified file.  I assume it short circuits, so that results 
>> are delivered quicker to emacs.  Maybe this bug can be closed.
>
> Your new option is still necessary for the default case when 
> 'xref-search-program' is 'grep' since GNU grep has no option to truncate 
> output, so xref should do post-processing for grep.
>

Actually, it is possible to truncate output with GNU grep:

grep -oE '.{0,100}PATTERN.{0,100}'

prints at most 100 characters before and after PATTERN.  I find this much 
better than ripgrep -M.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#46859; Package emacs. Full text available.

Message received at 46859 <at> debbugs.gnu.org:


Received: (at 46859) by debbugs.gnu.org; 3 Mar 2021 09:29:58 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Mar 03 04:29:58 2021
Received: from localhost ([127.0.0.1]:55145 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lHNpO-0008Vd-Al
	for submit <at> debbugs.gnu.org; Wed, 03 Mar 2021 04:29:58 -0500
Received: from relay5-d.mail.gandi.net ([217.70.183.197]:58205)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <juri@HIDDEN>) id 1lHNpK-0008VC-Tk
 for 46859 <at> debbugs.gnu.org; Wed, 03 Mar 2021 04:29:57 -0500
X-Originating-IP: 91.129.96.116
Received: from mail.gandi.net (m91-129-96-116.cust.tele2.ee [91.129.96.116])
 (Authenticated sender: juri@HIDDEN)
 by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id A4DDA1C000B;
 Wed,  3 Mar 2021 09:29:47 +0000 (UTC)
From: Juri Linkov <juri@HIDDEN>
To: Theodor Thornhill <theo@HIDDEN>
Subject: Re: bug#46859: 28.0.50; [PATCH]: Add option to truncate long lines
 in xref.el
Organization: LINKOV.NET
References: <m25z2azjxp.fsf@HIDDEN> <87im69uzlt.fsf@HIDDEN>
 <m2wnup9s2y.fsf@HIDDEN>
Date: Wed, 03 Mar 2021 11:05:20 +0200
In-Reply-To: <m2wnup9s2y.fsf@HIDDEN> (Theodor Thornhill's message of
 "Tue, 02 Mar 2021 22:13:57 +0100")
Message-ID: <878s74fv27.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 46859
Cc: 46859 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)

>> But maybe your new option would be easier to customize.
>
> Yeah, maybe.  However, without benchmarking, it is quite clear that
> adding your option is faster than my patch, since ripgrep has to search
> the whole minified file.  I assume it short circuits, so that results
> are delivered quicker to emacs.  Maybe this bug can be closed.

Your new option is still necessary for the default case when
'xref-search-program' is 'grep' since GNU grep has no option
to truncate output, so xref should do post-processing for grep.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#46859; Package emacs. Full text available.

Message received at 46859 <at> debbugs.gnu.org:


Received: (at 46859) by debbugs.gnu.org; 2 Mar 2021 22:37:21 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 02 17:37:21 2021
Received: from localhost ([127.0.0.1]:54470 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lHDdp-0001B2-JT
	for submit <at> debbugs.gnu.org; Tue, 02 Mar 2021 17:37:21 -0500
Received: from mail-wr1-f46.google.com ([209.85.221.46]:35165)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <raaahh@HIDDEN>) id 1lHDdm-0001An-Qm
 for 46859 <at> debbugs.gnu.org; Tue, 02 Mar 2021 17:37:20 -0500
Received: by mail-wr1-f46.google.com with SMTP id l12so21558463wry.2
 for <46859 <at> debbugs.gnu.org>; Tue, 02 Mar 2021 14:37:18 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=sender:subject:to:references:from:message-id:date:user-agent
 :mime-version:in-reply-to:content-language:content-transfer-encoding;
 bh=eUYonnpzxtQqtiTFzlyrxWIzWhGKce5o2bVb6/cGDwI=;
 b=fG+02pkVeKSxf2XtJwZhW4UMoGo8pqRT7xs+uuzqV6hTqeTrhSimSunEfI5qJity+A
 QSOCr5qfXUbmgu70EAcrWj4NSXUyrcxrYFaag+KDEFDTITQdrEcdA0oT2xjx4o4lHZUx
 kmqlnlKgz6Xj7g/y1F+sVsXtr8tz61FnRFxcev94hPJHhJui0WKwjoF9emN5eNk5igi8
 2zrO4Fw19hZACIGLGVO+sllRegULTzvh0nxDRgpv1W1g2rpgEFqO2GIgIImJQj8q3ql8
 gvv/XG8an75sPjtxXZX4kt5KYtG3tC7yonlFekgdmzF+BU8jBlHOcU65BiRbv2WgohBd
 gtXw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:sender:subject:to:references:from:message-id
 :date:user-agent:mime-version:in-reply-to:content-language
 :content-transfer-encoding;
 bh=eUYonnpzxtQqtiTFzlyrxWIzWhGKce5o2bVb6/cGDwI=;
 b=r51YGjqhTACrWp/sCTp8aKxlDYiGthMC6mGJT8tjhH5m/n9g4OQn+pzCj9AhLorwJ/
 eqvmOJNeBXH87iMIftlBOcm8s2t8m5VoDTs0tHOuH5mw8Womrv1hrcKTyByqHzJUD+D/
 Eyv0anQFwK8qauiQQHY/v7mJb5T69Ra2Iid58olZGoBsw9+4O2de7V8YCagEHBTx402S
 NvB53crsXcvF99DgUv4abGG39PUYXi3mrkQCjTqjirbaExjBzCtpWtmzzBXYhFe0Oo+k
 YhH+1V9cDEn57o3fZRNU+NK32J99oFZz4U3T4c1Vswpm6pURAxH2PX19eGokh7YTGQtP
 FQlA==
X-Gm-Message-State: AOAM5339DLPSTIUSNqAJwS6i8PWlqOv2T4KQd1ba33gbVscIvSbg8lt/
 t6WrjCoGxYb1tFwWLZK1A1JJKQBx89M=
X-Google-Smtp-Source: ABdhPJxM/unBl4msrM9a2vHFdOzPG43578iSw7rDRpGv03xuceUZi8SBq/HAnV1EhhcbrnaVZKhpEA==
X-Received: by 2002:adf:ed06:: with SMTP id a6mr18120970wro.208.1614724632858; 
 Tue, 02 Mar 2021 14:37:12 -0800 (PST)
Received: from [192.168.0.6] ([46.251.119.176])
 by smtp.googlemail.com with ESMTPSA id g17sm28700727wru.60.2021.03.02.14.37.11
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Tue, 02 Mar 2021 14:37:12 -0800 (PST)
Subject: Re: bug#46859: 28.0.50; [PATCH]: Add option to truncate long lines in
 xref.el
To: Theodor Thornhill <theo@HIDDEN>, juri@HIDDEN,
 46859 <at> debbugs.gnu.org
References: <m25z2azjxp.fsf@HIDDEN> <87im69uzlt.fsf@HIDDEN>
 <m2wnup9s2y.fsf@HIDDEN>
 <db9bae17-b4ae-ac21-2550-baeb6e714559@HIDDEN>
 <m2mtvlcieg.fsf@HIDDEN>
From: Dmitry Gutov <dgutov@HIDDEN>
Message-ID: <25782781-4baa-5d44-99a1-2e57552ab3a0@HIDDEN>
Date: Wed, 3 Mar 2021 00:37:08 +0200
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
 Thunderbird/68.10.0
MIME-Version: 1.0
In-Reply-To: <m2mtvlcieg.fsf@HIDDEN>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 7bit
X-Spam-Score: 0.5 (/)
X-Debbugs-Envelope-To: 46859
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.5 (/)

On 03.03.2021 00:14, Theodor Thornhill via Bug reports for GNU Emacs, 
the Swiss army knife of text editors wrote:
> I'm interested in seeing if I could gain some more
> performance by short circuiting after the first iteration of a match on
> the same line.  In my test scenario there are a lot of matches on the
> same huge line.  What do you think?

You probably mean to short-circuit as soon as you reach the target 
column (there might be multiple matches within those 500 chars), 
skipping the rest of the matches on the same line.

Sounds worth a try.

Another approach would be to truncate the line sometime earlier, like:

diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index 18fdd963fb..63a17a8521 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -1531,7 +1531,10 @@ xref-matches-in-files
        (while (re-search-forward grep-re nil t)
          (push (list (string-to-number (match-string line-group))
                      (match-string file-group)
-                    (buffer-substring-no-properties (point) 
(line-end-position)))
+                    (buffer-substring-no-properties (point)
+                                                    (min
+                                                     (+ (point) 500)
+                                                     (line-end-position))))
                hits)))
      (xref--convert-hits (nreverse hits) regexp)))


...of course, ideally we would keep all contents of the line somewhere 
in memory and truncate with (setq truncate-line t). But IIRC Juri said 
this didn't give us as much of a speedup as we'd want.

Another question: how many hits do you usually have in that huge 
one-line file? If it's more than 2-3, it might be that our current 
algorithm which creates "match objects" will duplicate this string 
unnecessarily N times (which is the number of hits), in 
xref--collect-matches-1, to then cut it up and merge into one line again 
when printing the buffer. In which case the patch above should also show 
a healthy improvement, but we could figure out something better instead.

Anyway, please benchmark your "earlier short-circuit" approach and then 
the above patch too.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#46859; Package emacs. Full text available.

Message received at 46859 <at> debbugs.gnu.org:


Received: (at 46859) by debbugs.gnu.org; 2 Mar 2021 22:14:53 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 02 17:14:53 2021
Received: from localhost ([127.0.0.1]:54455 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lHDI5-0000cx-6F
	for submit <at> debbugs.gnu.org; Tue, 02 Mar 2021 17:14:53 -0500
Received: from out2.migadu.com ([188.165.223.204]:59215)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <theo@HIDDEN>) id 1lHDI2-0000co-FP
 for 46859 <at> debbugs.gnu.org; Tue, 02 Mar 2021 17:14:51 -0500
X-Report-Abuse: Please report any abuse attempt to abuse@HIDDEN and
 include these headers.
From: Theodor Thornhill <theo@HIDDEN>
To: Dmitry Gutov <dgutov@HIDDEN>, juri@HIDDEN, 46859 <at> debbugs.gnu.org
Subject: Re: bug#46859: 28.0.50; [PATCH]: Add option to truncate long lines
 in xref.el
In-Reply-To: <db9bae17-b4ae-ac21-2550-baeb6e714559@HIDDEN>
References: <m25z2azjxp.fsf@HIDDEN>
 <87im69uzlt.fsf@HIDDEN> <m2wnup9s2y.fsf@HIDDEN>
 <db9bae17-b4ae-ac21-2550-baeb6e714559@HIDDEN>
Date: Tue, 02 Mar 2021 23:14:47 +0100
Message-ID: <m2mtvlcieg.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Migadu-Flow: FLOW_OUT
X-Migadu-Auth-User: theo@HIDDEN
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 46859
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)


Hi, Dmitry,

Dmitry Gutov <dgutov@HIDDEN> writes:

> Hi Theodor,
>
> On 02.03.2021 23:13, Theodor Thornhill via Bug reports for GNU Emacs, 
> the Swiss army knife of text editors wrote:
>> Yeah, maybe.  However, without benchmarking, it is quite clear that
>> adding your option is faster than my patch, since ripgrep has to search
>> the whole minified file.  I assume it short circuits, so that results
>> are delivered quicker to emacs.  Maybe this bug can be closed.
>
> Could you try benchmarking both approaches?
>
Ok, so here are some numbers:

;; With nothing
(benchmark-run 10 (project-find-regexp "UrlChange")) ;; (11.748253 14 0.23526199999999997)

;; With -M 500
(benchmark-run 10 (project-find-regexp "UrlChange")) ;; (0.293626 0 0.0)

;; My patch
(benchmark-run 10 (project-find-regexp "UrlChange")) ;; (1.230833 8 0.13783999999999996)

> If the performance improvement from yours is at all comparable with 
> Juri's, I'm inclined to prefer that direction for reasons described in 
> https://debbugs.gnu.org/cgi/bugreport.cgi?bug=44983#71.
>

So, now it looks like my patch is an improvement, but not as much as
limiting from ripgrep.  I think that is because in my version, we still
loop over the whole file, we just delete the contents so that we always
show 500 columns.  I'm interested in seeing if I could gain some more
performance by short circuiting after the first iteration of a match on
the same line.  In my test scenario there are a lot of matches on the
same huge line.  What do you think?

--
Theo




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#46859; Package emacs. Full text available.

Message received at 46859 <at> debbugs.gnu.org:


Received: (at 46859) by debbugs.gnu.org; 2 Mar 2021 21:45:51 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 02 16:45:51 2021
Received: from localhost ([127.0.0.1]:54414 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lHCpy-0008N2-Nt
	for submit <at> debbugs.gnu.org; Tue, 02 Mar 2021 16:45:50 -0500
Received: from out2.migadu.com ([188.165.223.204]:45033)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <theo@HIDDEN>) id 1lHCpv-0008Ms-I3
 for 46859 <at> debbugs.gnu.org; Tue, 02 Mar 2021 16:45:49 -0500
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Report-Abuse: Please report any abuse attempt to abuse@HIDDEN and
 include these headers.
From: Theodor Thornhill <theo@HIDDEN>
MIME-Version: 1.0
Subject: Re: bug#46859: 28.0.50;
 [PATCH]: Add option to truncate long lines in xref.el
Date: Tue, 2 Mar 2021 22:45:43 +0100
Message-Id: <E7D38E80-2A38-4A1A-8719-B9ABFF98F471@HIDDEN>
References: <db9bae17-b4ae-ac21-2550-baeb6e714559@HIDDEN>
In-Reply-To: <db9bae17-b4ae-ac21-2550-baeb6e714559@HIDDEN>
To: Dmitry Gutov <dgutov@HIDDEN>
X-Migadu-Flow: FLOW_OUT
X-Migadu-Auth-User: theo@HIDDEN
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 46859
Cc: 46859 <at> debbugs.gnu.org, juri@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)



> 2. mar. 2021 kl. 22:37 skrev Dmitry Gutov <dgutov@HIDDEN>:
>=20
> =EF=BB=BFHi Theodor,
>=20
>> On 02.03.2021 23:13, Theodor Thornhill via Bug reports for GNU Emacs, the=
 Swiss army knife of text editors wrote:
>> Yeah, maybe.  However, without benchmarking, it is quite clear that
>> adding your option is faster than my patch, since ripgrep has to search
>> the whole minified file.  I assume it short circuits, so that results
>> are delivered quicker to emacs.  Maybe this bug can be closed.
>=20
> Could you try benchmarking both approaches?
>=20

Absolutely, I will see what I can come up with.

> If the performance improvement from yours is at all comparable with Juri's=
, I'm inclined to prefer that direction for reasons described in https://deb=
bugs.gnu.org/cgi/bugreport.cgi?bug=3D44983#71.
>=20

Yeah, that was my initial motivation for this change as well.=20

> In both cases Ripgrep (or Grep) will search the whole file. The -M flag ju=
st affects its output.

Oh, ok!

Ill get back to you.

=E2=80=94
Theo=




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#46859; Package emacs. Full text available.

Message received at 46859 <at> debbugs.gnu.org:


Received: (at 46859) by debbugs.gnu.org; 2 Mar 2021 21:37:58 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 02 16:37:58 2021
Received: from localhost ([127.0.0.1]:54410 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lHCiL-0008Bn-H5
	for submit <at> debbugs.gnu.org; Tue, 02 Mar 2021 16:37:58 -0500
Received: from mail-wr1-f43.google.com ([209.85.221.43]:36205)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <raaahh@HIDDEN>) id 1lHCiJ-0008Ba-Je
 for 46859 <at> debbugs.gnu.org; Tue, 02 Mar 2021 16:37:56 -0500
Received: by mail-wr1-f43.google.com with SMTP id u14so21441765wri.3
 for <46859 <at> debbugs.gnu.org>; Tue, 02 Mar 2021 13:37:55 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=sender:subject:to:references:from:message-id:date:user-agent
 :mime-version:in-reply-to:content-language:content-transfer-encoding;
 bh=4f3UzxTDdTbybWja9EjOzou+OxvJlKdmUPRaaJ/bOg4=;
 b=QXCsAHlz7F6ySL10wrJp4phTU/fDLtj5hVhK5t/4E7DtnVVuiV/nvjG203NfEWM6+2
 vAR6gGoe3KUdckv67mFmN9ntcdmINFaQrQrFiRDpOWGa7kjXOkNz9+LEe+/35sgoySRK
 hl9SHwT7MDiW6waKobo2mSYCwFcXi+1vUJopxReb3+Hwx2TCFHSUBz+azSD8oUp6Ih1u
 lQHfBeiQq1t1Zv4MWk5SFTkgQwxSCxB6G3jgCD+Az12vm8v0Ld2ZjDrdiSeDNXAfBdX0
 EheKQYw9nuajoTLJjTbH0+1jVl3yzr41+mzM0vBoyzl+HwvRpja+vwgvlvyyLoZIQJfy
 zMEQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:sender:subject:to:references:from:message-id
 :date:user-agent:mime-version:in-reply-to:content-language
 :content-transfer-encoding;
 bh=4f3UzxTDdTbybWja9EjOzou+OxvJlKdmUPRaaJ/bOg4=;
 b=OvaBONbTwazQTFMiKS1EWaqn8/0OpXXSaJCMp1V2ool+b+Kg65Fun0fr+ReHr9eBHb
 6DQtTo4q24xbndEvt958efZ/ZJojX05fDqyXONnb7kgA8eO3ysLsCESNqEeORafarau9
 42/ybha04Rn5bLGSV60oYP6g32S7mevfiK+tXAB5PJvxkXlGkgnRHRDq8Su6On/4dF+f
 3iby74RBgHtVj9tgBl5p7zlFRpd4wYGiwYTED9xXIUaNYC8pDpEL3oQO62dMq6/nz7W/
 4jnLWs2z20JqA/yUJ1/+etFKiG9Rt8J9BB/PubUrxumlaFKmBqtPS9Tw6PSUV1q38zFW
 Sn8Q==
X-Gm-Message-State: AOAM531bfcTX+WcVTsUSANvhlxIsHoitFAJGcEwk9IiAOnxSqTLYzV59
 gpIcNL64d/glj0mMUHnCxM2ptf+mbYM=
X-Google-Smtp-Source: ABdhPJxCOZHFQL9YthPfZOJOvw9nbaiGO5n2iti1sOtpZtdz+YAMoa6fz40/f0tPkrtven4lXZ+g2w==
X-Received: by 2002:a5d:6951:: with SMTP id r17mr23417396wrw.279.1614721069548; 
 Tue, 02 Mar 2021 13:37:49 -0800 (PST)
Received: from [192.168.0.6] ([46.251.119.176])
 by smtp.googlemail.com with ESMTPSA id g202sm3824467wme.20.2021.03.02.13.37.48
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Tue, 02 Mar 2021 13:37:49 -0800 (PST)
Subject: Re: bug#46859: 28.0.50; [PATCH]: Add option to truncate long lines in
 xref.el
To: Theodor Thornhill <theo@HIDDEN>, juri@HIDDEN,
 46859 <at> debbugs.gnu.org
References: <m25z2azjxp.fsf@HIDDEN> <87im69uzlt.fsf@HIDDEN>
 <m2wnup9s2y.fsf@HIDDEN>
From: Dmitry Gutov <dgutov@HIDDEN>
Message-ID: <db9bae17-b4ae-ac21-2550-baeb6e714559@HIDDEN>
Date: Tue, 2 Mar 2021 23:37:45 +0200
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
 Thunderbird/68.10.0
MIME-Version: 1.0
In-Reply-To: <m2wnup9s2y.fsf@HIDDEN>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 7bit
X-Spam-Score: 0.5 (/)
X-Debbugs-Envelope-To: 46859
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.5 (/)

Hi Theodor,

On 02.03.2021 23:13, Theodor Thornhill via Bug reports for GNU Emacs, 
the Swiss army knife of text editors wrote:
> Yeah, maybe.  However, without benchmarking, it is quite clear that
> adding your option is faster than my patch, since ripgrep has to search
> the whole minified file.  I assume it short circuits, so that results
> are delivered quicker to emacs.  Maybe this bug can be closed.

Could you try benchmarking both approaches?

If the performance improvement from yours is at all comparable with 
Juri's, I'm inclined to prefer that direction for reasons described in 
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=44983#71.

In both cases Ripgrep (or Grep) will search the whole file. The -M flag 
just affects its output.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#46859; Package emacs. Full text available.

Message received at 46859 <at> debbugs.gnu.org:


Received: (at 46859) by debbugs.gnu.org; 2 Mar 2021 21:14:04 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 02 16:14:04 2021
Received: from localhost ([127.0.0.1]:54364 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lHCLD-0005Wy-TT
	for submit <at> debbugs.gnu.org; Tue, 02 Mar 2021 16:14:04 -0500
Received: from out1.migadu.com ([91.121.223.63]:35451)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <theo@HIDDEN>) id 1lHCLB-0005WH-0L
 for 46859 <at> debbugs.gnu.org; Tue, 02 Mar 2021 16:14:02 -0500
X-Report-Abuse: Please report any abuse attempt to abuse@HIDDEN and
 include these headers.
From: Theodor Thornhill <theo@HIDDEN>
To: Juri Linkov <juri@HIDDEN>, "Theodor Thornhill via Bug reports for
 GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@HIDDEN>
Subject: Re: bug#46859: 28.0.50; [PATCH]: Add option to truncate long lines
 in xref.el
In-Reply-To: <87im69uzlt.fsf@HIDDEN>
References: <m25z2azjxp.fsf@HIDDEN> <87im69uzlt.fsf@HIDDEN>
Date: Tue, 02 Mar 2021 22:13:57 +0100
Message-ID: <m2wnup9s2y.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Migadu-Flow: FLOW_OUT
X-Migadu-Auth-User: theo@HIDDEN
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 46859
Cc: 46859 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)


Hi!

Juri Linkov <juri@HIDDEN> writes:
>
> I've customized 'xref-search-program-alist' that defines ripgrep
> command line to contain additional options:
>
>   -M 500 --max-columns-preview
>
Oh, right. That's pretty smart - and fast!

> that truncates long lines of ripgrep output
> after we discussed this in https://debbugs.gnu.org/44983
>

I'm sorry - completely missed that bug, it seems.

> But maybe your new option would be easier to customize.

Yeah, maybe.  However, without benchmarking, it is quite clear that
adding your option is faster than my patch, since ripgrep has to search
the whole minified file.  I assume it short circuits, so that results
are delivered quicker to emacs.  Maybe this bug can be closed.

Thanks for linking to that thread, and sorry for the noise :)

--
Theo




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#46859; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 2 Mar 2021 21:14:15 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 02 16:14:15 2021
Received: from localhost ([127.0.0.1]:54367 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lHCLP-0005XM-6M
	for submit <at> debbugs.gnu.org; Tue, 02 Mar 2021 16:14:15 -0500
Received: from lists.gnu.org ([209.51.188.17]:43466)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <theo@HIDDEN>) id 1lHCLM-0005XE-QY
 for submit <at> debbugs.gnu.org; Tue, 02 Mar 2021 16:14:14 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:51424)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <theo@HIDDEN>) id 1lHCLL-0005fv-1F
 for bug-gnu-emacs@HIDDEN; Tue, 02 Mar 2021 16:14:12 -0500
Received: from out1.migadu.com ([2001:41d0:2:863f::]:35449)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <theo@HIDDEN>) id 1lHCLD-0002vU-UY
 for bug-gnu-emacs@HIDDEN; Tue, 02 Mar 2021 16:14:10 -0500
X-Report-Abuse: Please report any abuse attempt to abuse@HIDDEN and
 include these headers.
From: Theodor Thornhill <theo@HIDDEN>
To: Juri Linkov <juri@HIDDEN>, "Theodor Thornhill via Bug reports for
 GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@HIDDEN>
Subject: Re: bug#46859: 28.0.50; [PATCH]: Add option to truncate long lines
 in xref.el
In-Reply-To: <87im69uzlt.fsf@HIDDEN>
References: <m25z2azjxp.fsf@HIDDEN> <87im69uzlt.fsf@HIDDEN>
Date: Tue, 02 Mar 2021 22:13:57 +0100
Message-ID: <m2wnup9s2y.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Migadu-Flow: FLOW_OUT
X-Migadu-Auth-User: theo@HIDDEN
Received-SPF: pass client-ip=2001:41d0:2:863f::;
 envelope-from=theo@HIDDEN; helo=out1.migadu.com
X-Spam_score_int: -18
X-Spam_score: -1.9
X-Spam_bar: -
X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -1.4 (-)
X-Debbugs-Envelope-To: submit
Cc: 46859 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.4 (--)


Hi!

Juri Linkov <juri@HIDDEN> writes:
>
> I've customized 'xref-search-program-alist' that defines ripgrep
> command line to contain additional options:
>
>   -M 500 --max-columns-preview
>
Oh, right. That's pretty smart - and fast!

> that truncates long lines of ripgrep output
> after we discussed this in https://debbugs.gnu.org/44983
>

I'm sorry - completely missed that bug, it seems.

> But maybe your new option would be easier to customize.

Yeah, maybe.  However, without benchmarking, it is quite clear that
adding your option is faster than my patch, since ripgrep has to search
the whole minified file.  I assume it short circuits, so that results
are delivered quicker to emacs.  Maybe this bug can be closed.

Thanks for linking to that thread, and sorry for the noise :)

--
Theo




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#46859; Package emacs. Full text available.

Message received at 46859 <at> debbugs.gnu.org:


Received: (at 46859) by debbugs.gnu.org; 2 Mar 2021 19:43:12 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 02 14:43:12 2021
Received: from localhost ([127.0.0.1]:54258 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lHAvI-0003GN-0d
	for submit <at> debbugs.gnu.org; Tue, 02 Mar 2021 14:43:12 -0500
Received: from relay12.mail.gandi.net ([217.70.178.232]:43329)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <juri@HIDDEN>) id 1lHAvF-0003G3-Ry
 for 46859 <at> debbugs.gnu.org; Tue, 02 Mar 2021 14:43:10 -0500
Received: from mail.gandi.net (m91-129-96-116.cust.tele2.ee [91.129.96.116])
 (Authenticated sender: juri@HIDDEN)
 by relay12.mail.gandi.net (Postfix) with ESMTPSA id DB26820000A;
 Tue,  2 Mar 2021 19:43:02 +0000 (UTC)
From: Juri Linkov <juri@HIDDEN>
To: Theodor Thornhill via "Bug reports for GNU Emacs, the Swiss army knife
 of text editors" <bug-gnu-emacs@HIDDEN>
Subject: Re: bug#46859: 28.0.50; [PATCH]: Add option to truncate long lines
 in xref.el
Organization: LINKOV.NET
References: <m25z2azjxp.fsf@HIDDEN>
Date: Tue, 02 Mar 2021 21:25:50 +0200
In-Reply-To: <m25z2azjxp.fsf@HIDDEN> (Theodor Thornhill via's
 message of "Mon, 01 Mar 2021 21:40:50 +0100")
Message-ID: <87im69uzlt.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu)
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 46859
Cc: 46859 <at> debbugs.gnu.org, Theodor Thornhill <theo@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)

> The added functionality is created to not kick in before a certain
> threshold, where 500 columns seems reasonably long. Anything above that
> will be truncated, but xref will still show that there was a hit.
>
> I'm sure the patch can be improved, so please, don't hesitate to tell
> me.
>
> I consider this a great improvement, and I hope you will to

I've customized 'xref-search-program-alist' that defines ripgrep
command line to contain additional options:

  -M 500 --max-columns-preview

that truncates long lines of ripgrep output
after we discussed this in https://debbugs.gnu.org/44983

But maybe your new option would be easier to customize.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#46859; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 2 Mar 2021 19:43:12 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 02 14:43:12 2021
Received: from localhost ([127.0.0.1]:54260 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lHAvI-0003GP-87
	for submit <at> debbugs.gnu.org; Tue, 02 Mar 2021 14:43:12 -0500
Received: from lists.gnu.org ([209.51.188.17]:60900)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <juri@HIDDEN>) id 1lHAvG-0003GG-Us
 for submit <at> debbugs.gnu.org; Tue, 02 Mar 2021 14:43:11 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:59236)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <juri@HIDDEN>) id 1lHAvG-00028p-Mn
 for bug-gnu-emacs@HIDDEN; Tue, 02 Mar 2021 14:43:10 -0500
Received: from relay12.mail.gandi.net ([217.70.178.232]:60349)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <juri@HIDDEN>) id 1lHAvE-0006ZW-0G
 for bug-gnu-emacs@HIDDEN; Tue, 02 Mar 2021 14:43:10 -0500
Received: from mail.gandi.net (m91-129-96-116.cust.tele2.ee [91.129.96.116])
 (Authenticated sender: juri@HIDDEN)
 by relay12.mail.gandi.net (Postfix) with ESMTPSA id DB26820000A;
 Tue,  2 Mar 2021 19:43:02 +0000 (UTC)
From: Juri Linkov <juri@HIDDEN>
To: Theodor Thornhill via "Bug reports for GNU Emacs, the Swiss army knife
 of text editors" <bug-gnu-emacs@HIDDEN>
Subject: Re: bug#46859: 28.0.50; [PATCH]: Add option to truncate long lines
 in xref.el
Organization: LINKOV.NET
References: <m25z2azjxp.fsf@HIDDEN>
Date: Tue, 02 Mar 2021 21:25:50 +0200
In-Reply-To: <m25z2azjxp.fsf@HIDDEN> (Theodor Thornhill via's
 message of "Mon, 01 Mar 2021 21:40:50 +0100")
Message-ID: <87im69uzlt.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu)
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
Received-SPF: pass client-ip=217.70.178.232; envelope-from=juri@HIDDEN;
 helo=relay12.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,
 RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -1.6 (-)
X-Debbugs-Envelope-To: submit
Cc: 46859 <at> debbugs.gnu.org, Theodor Thornhill <theo@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.6 (--)

> The added functionality is created to not kick in before a certain
> threshold, where 500 columns seems reasonably long. Anything above that
> will be truncated, but xref will still show that there was a hit.
>
> I'm sure the patch can be improved, so please, don't hesitate to tell
> me.
>
> I consider this a great improvement, and I hope you will to

I've customized 'xref-search-program-alist' that defines ripgrep
command line to contain additional options:

  -M 500 --max-columns-preview

that truncates long lines of ripgrep output
after we discussed this in https://debbugs.gnu.org/44983

But maybe your new option would be easier to customize.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#46859; Package emacs. Full text available.

Message received at 46859 <at> debbugs.gnu.org:


Received: (at 46859) by debbugs.gnu.org; 1 Mar 2021 22:07:42 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Mar 01 17:07:42 2021
Received: from localhost ([127.0.0.1]:51100 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lGqha-0002Ko-1O
	for submit <at> debbugs.gnu.org; Mon, 01 Mar 2021 17:07:42 -0500
Received: from out2.migadu.com ([188.165.223.204]:19569)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <theo@HIDDEN>) id 1lGqhX-0002Kf-Nm
 for 46859 <at> debbugs.gnu.org; Mon, 01 Mar 2021 17:07:40 -0500
X-Report-Abuse: Please report any abuse attempt to abuse@HIDDEN and
 include these headers.
From: Theodor Thornhill <theo@HIDDEN>
To: 46859 <at> debbugs.gnu.org
Subject: 28.0.50; [PATCH]: Add option to truncate long lines in xref.el
Date: Mon, 01 Mar 2021 23:07:36 +0100
Message-ID: <m235xezfx3.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
X-Migadu-Flow: FLOW_OUT
X-Migadu-Auth-User: theo@HIDDEN
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 46859
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

--=-=-=
Content-Type: text/plain


There was a typo in the previous patch, sorry about that!

--
Theo



--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=0001-Add-option-to-truncate-long-lines.patch

From 1697033f216a9792e374bda20816ff91491aa38e Mon Sep 17 00:00:00 2001
From: Theodor Thornhill <theo@HIDDEN>
Date: Mon, 1 Mar 2021 23:05:32 +0100
Subject: [PATCH] Add option to truncate long lines

* (xref-truncate-line-to): New option.  Set cut-off point for long
lines in xref buffer

* (xref--truncate-long-lines-p): Helper function for xref--insert-xrefs.

* (xref--insert-xrefs): By truncating long lines we get a huge speedup
both when invoking xref, and while navigating the xref buffer.
---
 lisp/progmodes/xref.el | 37 ++++++++++++++++++++++++++++++-------
 1 file changed, 30 insertions(+), 7 deletions(-)

diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index 18fdd963fb..c893137973 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -872,6 +872,19 @@ beginning of the line."
       (xref--search-property 'xref-item))
   (xref-show-location-at-point))
 
+(defcustom xref-truncate-line-to 500
+  "Max number of columns to display in xref buffer."
+  :type '(choice
+          (fixnum :tag "Number of lines")
+          (null :tag "Don't truncate"))
+  :version "28.1"
+  :package-version '(xref . "1.0.5"))
+
+(defun xref--truncate-long-lines-p (summary)
+  (cl-check-type summary xref-item)
+  (and (numberp xref-truncate-line-to)
+       (> (length summary) xref-truncate-line-to)))
+
 (defun xref--insert-xrefs (xref-alist)
   "Insert XREF-ALIST in the current-buffer.
 XREF-ALIST is of the form ((GROUP . (XREF ...)) ...), where
@@ -902,14 +915,24 @@ GROUP is a string for decoration purposes and XREF is an
                                 "  ")))
                         ;; Render multiple matches on the same line, together.
                         (when (and line (equal prev-line-key line-key))
-                          (when-let ((column (xref-location-column location)))
-                            (delete-region
-                             (save-excursion
-                               (forward-line -1)
-                               (move-to-column (+ (length prefix) column))
+                          ;; Overwrite if we want to truncate long lines.
+                          (if (xref--truncate-long-lines-p new-summary)
+                              (delete-region
+                               (save-excursion (forward-line -1) (point))
+                               (point))
+                            (when-let ((column (xref-location-column location)))
+                              (delete-region
+                               (save-excursion
+                                 (forward-line -1)
+                                 (move-to-column (+ (length prefix) column))
+                                 (point))
                                (point))
-                             (point))
-                            (setq new-summary (substring summary column) prefix "")))
+                              (setq new-summary (substring summary column) prefix ""))))
+                        ;; Truncate
+                        (when (xref--truncate-long-lines-p new-summary)
+                          (setq new-summary
+                                (concat (substring new-summary 0 xref-truncate-line-to)
+                                        " (...truncated)")))
                         (xref--insert-propertized
                          (list 'xref-item xref
                                'mouse-face 'highlight
-- 
2.24.3 (Apple Git-128)


--=-=-=--




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#46859; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 1 Mar 2021 20:41:09 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Mar 01 15:41:09 2021
Received: from localhost ([127.0.0.1]:51010 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lGpLp-0006NY-1D
	for submit <at> debbugs.gnu.org; Mon, 01 Mar 2021 15:41:09 -0500
Received: from lists.gnu.org ([209.51.188.17]:39218)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <theo@HIDDEN>) id 1lGpLn-0006NR-FR
 for submit <at> debbugs.gnu.org; Mon, 01 Mar 2021 15:41:07 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:34322)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <theo@HIDDEN>) id 1lGpLm-0006Ne-3X
 for bug-gnu-emacs@HIDDEN; Mon, 01 Mar 2021 15:41:07 -0500
Received: from out2.migadu.com ([2001:41d0:2:aacc::]:18389)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <theo@HIDDEN>) id 1lGpLe-0006xU-Ed
 for bug-gnu-emacs@HIDDEN; Mon, 01 Mar 2021 15:41:05 -0500
X-Report-Abuse: Please report any abuse attempt to abuse@HIDDEN and
 include these headers.
From: Theodor Thornhill <theo@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: 28.0.50; [PATCH]: Add option to truncate long lines in xref.el
Date: Mon, 01 Mar 2021 21:40:50 +0100
Message-ID: <m25z2azjxp.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
X-Migadu-Flow: FLOW_OUT
X-Migadu-Auth-User: theo@HIDDEN
Received-SPF: pass client-ip=2001:41d0:2:aacc::;
 envelope-from=theo@HIDDEN; helo=out2.migadu.com
X-Spam_score_int: -18
X-Spam_score: -1.9
X-Spam_bar: -
X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -1.4 (-)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.4 (--)

--=-=-=
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable


Hi!

When using the xref buffer, especially in combination with
'project-find-regexp', sometimes my projects has huge one-line
files. The simplest example of these kind of files are the minified
".js" files that are compiled. Right now I have one at 500 000 columns,
which admittedly is a lot. However, when 'project-find-regexp' searches
these files and finds a hit in one of them, the search takes a long
time. In addition, navigating the xref buffer when the results show up
also takes a long time, because of the troubles emacs has with long
lines.

Before the supplied patch, one search with 'project-find-regexp' with
ripgrep enabled takes around 3-4 seconds. With the supplied patch, the
search is almost instantaneous.

The added functionality is created to not kick in before a certain
threshold, where 500 columns seems reasonably long. Anything above that
will be truncated, but xref will still show that there was a hit.

I'm sure the patch can be improved, so please, don't hesitate to tell
me.


I consider this a great improvement, and I hope you will to=C2=A7

Have a nice day,

--
Theodor Thornhill


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=0001-Add-option-to-truncate-long-lines.patch

From dcc2078c20d8edd32407498c16d65ea46d44a3a0 Mon Sep 17 00:00:00 2001
From: Theodor Thornhill <theo@HIDDEN>
Date: Mon, 1 Mar 2021 21:26:44 +0100
Subject: [PATCH] Add option to truncate long lines

* (xref-truncate-line-to): New option.  Set cut-off point for long
lines in xref buffer

* (xref--truncate-long-lines-p): Helper function for xref--insert-xrefs.

* (xref--insert-xrefs): By truncating long lines we get a huge speedup
both when invoking xref, and while navigating the xref buffer.
---
 lisp/progmodes/xref.el | 37 ++++++++++++++++++++++++++++++-------
 1 file changed, 30 insertions(+), 7 deletions(-)

diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index 18fdd963fb..98dacef94f 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -872,6 +872,19 @@ beginning of the line."
       (xref--search-property 'xref-item))
   (xref-show-location-at-point))
 
+(defcustom xref-truncate-line-to 500
+  "Max number of columns to display in xref buffer."
+  :type '(choice
+          (fixnum :tag "Number of lines")
+          (null :tag "Don't truncate"))
+  :version "28.1"
+  :package-version '(xref . "1.0.5"))
+
+(defun xref--truncate-long-lines-p (summary)
+  (cl-check-type summary xref-item)
+  (and (numberp xref-truncate-line-to)
+       (> (length summary) xref-truncate-line-to)))
+
 (defun xref--insert-xrefs (xref-alist)
   "Insert XREF-ALIST in the current-buffer.
 XREF-ALIST is of the form ((GROUP . (XREF ...)) ...), where
@@ -902,14 +915,24 @@ GROUP is a string for decoration purposes and XREF is an
                                 "  ")))
                         ;; Render multiple matches on the same line, together.
                         (when (and line (equal prev-line-key line-key))
-                          (when-let ((column (xref-location-column location)))
-                            (delete-region
-                             (save-excursion
-                               (forward-line -1)
-                               (move-to-column (+ (length prefix) column))
+                          ;; Overwrite if we want to truncate long lines.
+                          (if (xref-truncate-long-lines-p new-summary)
+                              (delete-region
+                               (save-excursion (forward-line -1) (point))
+                               (point))
+                            (when-let ((column (xref-location-column location)))
+                              (delete-region
+                               (save-excursion
+                                 (forward-line -1)
+                                 (move-to-column (+ (length prefix) column))
+                                 (point))
                                (point))
-                             (point))
-                            (setq new-summary (substring summary column) prefix "")))
+                              (setq new-summary (substring summary column) prefix ""))))
+                        ;; Truncate
+                        (when (xref-truncate-long-lines-p new-summary)
+                          (setq new-summary
+                                (concat (substring new-summary 0 xref-truncate-line-to)
+                                        " (...truncated)")))
                         (xref--insert-propertized
                          (list 'xref-item xref
                                'mouse-face 'highlight
-- 
2.24.3 (Apple Git-128)


--=-=-=--




Acknowledgement sent to Theodor Thornhill <theo@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#46859; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Sat, 6 Mar 2021 13:00:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.