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#46933: Possible bugs in filepos-to-bufferpos / bufferpos-to-filepos Date: Mon, 20 Jun 2022 14:52:12 +0300 Message-ID: <838rprmu1f.fsf@gnu.org> References: <9cff0f8894f167925251@heytings.org> <87im53ny95.fsf@gnu.org> <87r13kqhdj.fsf@gnus.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="6018"; mail-complaints-to="usenet@ciao.gmane.io" Cc: handa@gnu.org, gregory@heytings.org, 46933@debbugs.gnu.org To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Jun 20 13:53:10 2022 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 1o3Fxt-0001R9-UN for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 20 Jun 2022 13:53:10 +0200 Original-Received: from localhost ([::1]:34538 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o3Fxs-0007zE-JR for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 20 Jun 2022 07:53:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:47776) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3Fxm-0007yx-Pt for bug-gnu-emacs@gnu.org; Mon, 20 Jun 2022 07:53:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:60719) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o3Fxm-0001o1-HC for bug-gnu-emacs@gnu.org; Mon, 20 Jun 2022 07:53:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1o3Fxm-0008T6-GE for bug-gnu-emacs@gnu.org; Mon, 20 Jun 2022 07:53:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 20 Jun 2022 11:53:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 46933 X-GNU-PR-Package: emacs Original-Received: via spool by 46933-submit@debbugs.gnu.org id=B46933.165572596132522 (code B ref 46933); Mon, 20 Jun 2022 11:53:02 +0000 Original-Received: (at 46933) by debbugs.gnu.org; 20 Jun 2022 11:52:41 +0000 Original-Received: from localhost ([127.0.0.1]:54616 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o3FxJ-0008SL-Ai for submit@debbugs.gnu.org; Mon, 20 Jun 2022 07:52:41 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:34412) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o3FxI-0008S4-6u for 46933@debbugs.gnu.org; Mon, 20 Jun 2022 07:52:32 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:46596) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3FxC-0001l4-QL; Mon, 20 Jun 2022 07:52:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=mbmNIOzHA4KW+PfXwN8uc2dcapwWJ83dz1/u0K1Nu78=; b=BSovpf1exrys AXP1SCeXGw+kNAf7mCzweZC+3A/0V6xm7whf47Vs8CZOj19LNz/8lNiEo7vNtW6vIybaFu2/7p9Qh KQfwSUmQC2dri8G/pTvSZYaY3atWQpJTOTKA6VS1izKMUd5eKOuAHiR1VRMt391i1CfLFvya9ZYz6 t4/+Rx3KO8pzbx0V2DiQYeeYo3slSLUr7qJKIByRPMBuV0NsTJrAi3cTBqc7X6E6DR6ftcgeRO+pd B0rsQaR4HNMjzqqI46rvnoHpgf6yewhtpukcdOUhIQ51z3YYh3pTQwiU9vRboagnr6vDEiiHFhlmE C2TwwpD1HIcw7MXBSX103Q==; Original-Received: from [87.69.77.57] (port=1805 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3FxC-0004pQ-5s; Mon, 20 Jun 2022 07:52:26 -0400 In-Reply-To: <87r13kqhdj.fsf@gnus.org> (message from Lars Ingebrigtsen on Mon, 20 Jun 2022 02:59:52 +0200) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:234874 Archived-At: > From: Lars Ingebrigtsen > Cc: Eli Zaretskii , gregory@heytings.org, 46933@debbugs.gnu.org > Date: Mon, 20 Jun 2022 02:59:52 +0200 > > handa writes: > > > For the latter case, perhaps something like the following code works. > > > > ;; Return the buffer position correspoinding to the byte position > > ;; FILEPOS in FILE provided that FILE is decoded by CODING-SYSTEM. > > (defun temp (file filepos coding-system) > > (with-temp-buffer > > (set-buffer-multibyte nil) > > (insert-file-contents-literally file) > > (let ((full (decode-coding-region 1 (point-max) coding-system t)) > > partial) > > (while (and (setq partial (decode-coding-region 1 (1+ filepos) > > coding-system t)) > > (not (eq (compare-strings full 0 (length partial) > > partial 0 (length partial)) > > t))) > > (setq filepos (1+ filepos))) > > (1+ (length partial))))) > > > > If it is too slow, there are a few ways to make it faster. > > (I'm going through old bug reports that unfortunately weren't resolved > at the time.) > > If I understand correctly, the suggestion here is to use this function > in Info-find-node-2 instead of `filepos-to-bufferpos'? "Unless it's too slow".