GNU bug report logs - #46933
Possible bugs in filepos-to-bufferpos / bufferpos-to-filepos

Previous Next

Package: emacs;

Reported by: Gregory Heytings <gregory <at> heytings.org>

Date: Thu, 4 Mar 2021 21:22:02 UTC

Severity: normal

Full log


Message #47 received at 46933 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: handa <at> gnu.org, gregory <at> heytings.org, 46933 <at> debbugs.gnu.org
Subject: Re: bug#46933: Possible bugs in filepos-to-bufferpos /
 bufferpos-to-filepos
Date: Mon, 20 Jun 2022 14:52:12 +0300
> From: Lars Ingebrigtsen <larsi <at> gnus.org>
> Cc: Eli Zaretskii <eliz <at> gnu.org>,  gregory <at> heytings.org,  46933 <at> debbugs.gnu.org
> Date: Mon, 20 Jun 2022 02:59:52 +0200
> 
> handa <handa <at> gnu.org> 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".




This bug report was last modified 3 years and 52 days ago.

Previous Next


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