From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#46859: 28.0.50; [PATCH]: Add option to truncate long lines in xref.el Date: Thu, 04 Mar 2021 16:08:49 +0200 Message-ID: <83y2f3huz2.fsf@gnu.org> References: <87im69uzlt.fsf@mail.linkov.net> <878s74fv27.fsf@mail.linkov.net> <4119ea3055ef8f306fc0@heytings.org> <4119ea30557ef84ca190@heytings.org> <7eb7ee0f-7dba-c90d-cb58-af42c3828643@yandex.ru> <4119ea30554b406efbbf@heytings.org> <4119ea30558f1e4145b0@heytings.org> <4119ea30555e80bdcf7e@heytings.org> <1c82e582-8b90-f3c5-5391-1e88ca4e7ab2@yandex.ru> <4119ea30553e3f90ab8c@heytings.org> <87y2f42ex5.fsf@mail.linkov.net> <4119ea30552873ab9870@heytings.org> <83eegvk2u0.fsf@gnu.org> <9cff0f8894658f3b50c8@heytings.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="5650"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 46859@debbugs.gnu.org To: Gregory Heytings Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Mar 04 15:10:16 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lHogC-0001If-1R for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 04 Mar 2021 15:10:16 +0100 Original-Received: from localhost ([::1]:44422 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lHogA-0006JW-Ux for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 04 Mar 2021 09:10:14 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:48584) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lHofy-0006HZ-Rb for bug-gnu-emacs@gnu.org; Thu, 04 Mar 2021 09:10:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:46640) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lHofy-0006qu-Jd for bug-gnu-emacs@gnu.org; Thu, 04 Mar 2021 09:10:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lHofy-0005ca-EO for bug-gnu-emacs@gnu.org; Thu, 04 Mar 2021 09:10:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 04 Mar 2021 14:10:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 46859 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 46859-submit@debbugs.gnu.org id=B46859.161486695721516 (code B ref 46859); Thu, 04 Mar 2021 14:10:02 +0000 Original-Received: (at 46859) by debbugs.gnu.org; 4 Mar 2021 14:09:17 +0000 Original-Received: from localhost ([127.0.0.1]:58186 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lHofF-0005ay-ES for submit@debbugs.gnu.org; Thu, 04 Mar 2021 09:09:17 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:58686) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lHofB-0005aT-Km for 46859@debbugs.gnu.org; Thu, 04 Mar 2021 09:09:16 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:60069) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lHof6-0006WH-6a; Thu, 04 Mar 2021 09:09:08 -0500 Original-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 ) id 1lHof5-0008A5-Mq; Thu, 04 Mar 2021 09:09:08 -0500 In-Reply-To: <9cff0f8894658f3b50c8@heytings.org> (message from Gregory Heytings on Thu, 04 Mar 2021 09:19:50 +0000) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:201395 Archived-At: > Date: Thu, 04 Mar 2021 09:19:50 +0000 > From: Gregory Heytings > cc: 46859@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.