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