From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: [Emacs-diffs] master c4782ea: Improve and extend filepos-to-bufferpos Date: Thu, 18 Jun 2015 23:17:28 -0400 Message-ID: References: <20150618120808.22624.13860@vcs.savannah.gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1434683869 19984 80.91.229.3 (19 Jun 2015 03:17:49 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 19 Jun 2015 03:17:49 +0000 (UTC) Cc: Eli Zaretskii To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Jun 19 05:17:40 2015 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Z5moF-0006rA-RH for ged-emacs-devel@m.gmane.org; Fri, 19 Jun 2015 05:17:39 +0200 Original-Received: from localhost ([::1]:55691 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z5moF-0006QE-4k for ged-emacs-devel@m.gmane.org; Thu, 18 Jun 2015 23:17:39 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:37705) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z5moB-0006Pt-PT for emacs-devel@gnu.org; Thu, 18 Jun 2015 23:17:36 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z5moA-0005wV-S1 for emacs-devel@gnu.org; Thu, 18 Jun 2015 23:17:35 -0400 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.181]:53834) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z5mo7-0005vO-6E; Thu, 18 Jun 2015 23:17:31 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0ArEwA731xV//lyoWxTCYMQhAKFVbs3CYdLBAICgTw5FAEBAQEBAQGBCkEFg10BAQRWIxALLQcSFBgNiGPPIwEBAQEGAQEBAR6LOoQpXAcKDIQXBZ8XhmmNP4FFI4IHH4FuIoJ4AQEB X-IPAS-Result: A0ArEwA731xV//lyoWxTCYMQhAKFVbs3CYdLBAICgTw5FAEBAQEBAQGBCkEFg10BAQRWIxALLQcSFBgNiGPPIwEBAQEGAQEBAR6LOoQpXAcKDIQXBZ8XhmmNP4FFI4IHH4FuIoJ4AQEB X-IronPort-AV: E=Sophos;i="5.13,465,1427774400"; d="scan'208";a="127316260" Original-Received: from 108-161-114-249.dsl.teksavvy.com (HELO ceviche.home) ([108.161.114.249]) by ironport2-out.teksavvy.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 18 Jun 2015 23:17:29 -0400 Original-Received: by ceviche.home (Postfix, from userid 20848) id E14AC6610A; Thu, 18 Jun 2015 23:17:28 -0400 (EDT) In-Reply-To: (Eli Zaretskii's message of "Thu, 18 Jun 2015 12:08:08 +0000") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 206.248.154.181 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:187301 Archived-At: > + (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