unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: emacs-devel@gnu.org
Cc: Eli Zaretskii <eliz@gnu.org>
Subject: Re: [Emacs-diffs] master c4782ea: Improve and extend filepos-to-bufferpos
Date: Thu, 18 Jun 2015 23:17:28 -0400	[thread overview]
Message-ID: <jwvpp4s8kci.fsf-monnier+emacsdiffs@gnu.org> (raw)
In-Reply-To: <E1Z5Yc4-0005ti-Ic@vcs.savannah.gnu.org> (Eli Zaretskii's message of "Thu, 18 Jun 2015 12:08:08 +0000")

> +            (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	other threads:[~2015-06-19  3:17 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20150618120808.22624.13860@vcs.savannah.gnu.org>
     [not found] ` <E1Z5Yc4-0005ti-Ic@vcs.savannah.gnu.org>
2015-06-19  3:17   ` Stefan Monnier [this message]
2015-06-19  6:59     ` [Emacs-diffs] master c4782ea: Improve and extend filepos-to-bufferpos Eli Zaretskii
2015-06-19  8:20       ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvpp4s8kci.fsf-monnier+emacsdiffs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).