emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Emacs-diffs] master c4782ea: Improve and extend filepos-to-bufferpo


From: Stefan Monnier
Subject: Re: [Emacs-diffs] master c4782ea: Improve and extend filepos-to-bufferpos
Date: Thu, 18 Jun 2015 23:17:28 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)

> +            (if (<= byte eol-offset)
> +                (setq pos (point-min))
> +              (setq pos (point-max))))

Aka (setq pos (if (<= byte eol-offset) (point-min) (point-max)))

>    (let ((eol (coding-system-eol-type coding-system))
>          (type (coding-system-type coding-system))
> +        (base (coding-system-base coding-system))
>          (pm (save-restriction (widen) (point-min))))
> +    (and (eq type 'utf-8-emacs)
> +         (setq type 'utf-8))

(coding-system-type 'utf-8-emacs) returns `utf-8', so how/when can
`type' be `utf-8-emacs'?

> +    (and (eq type 'utf-8)
> +         ;; Any post-read/pre-write conversions mean it's not really UTF-8.
> +         (not (null (coding-system-get coding-system :pos-read-conversion)))
> +         (setq type 'not-utf-8))

I guess this also applies for latin-N and utf-16, IOW for any value of
`type', right?

> +    (and (not (eq type 'utf-8))
> +         (eq quality 'exact)
> +         (setq type 'use-exact))

IIUC this makes us use the slow exact code for latin-N.  Why is it needed?

> +      (`utf-16
> +       ;; Account for BOM, which is always 2 bytes in UTF-16.
> +       (setq byte (- byte 2))

Should that only be done for utf1-16B-with-signature?

> +       ;; In approximate mode, assume all characters are within the
> +       ;; BMP, i.e. take up 2 bytes.
> +       (setq byte (/ byte 2))
> +       (if (= eol 1)
> +           (filepos-to-bufferpos--dos (+ pm byte) #'byte-to-position)
> +         (byte-to-position (+ pm byte))))

Shouldn't this use `identity' rather than `byte-to-position'?


        Stefan



reply via email to

[Prev in Thread] Current Thread [Next in Thread]