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: docs for insert-file-contents use 'bytes' Date: Thu, 02 Oct 2008 14:55:10 -0400 Message-ID: References: <86ljxa67xi.fsf@lifelogs.com> <86hc7y64vm.fsf@lifelogs.com> <8663od68yb.fsf@lifelogs.com> <868wt845op.fsf@lifelogs.com> <864p3v2jwt.fsf@lifelogs.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1222981792 27939 80.91.229.12 (2 Oct 2008 21:09:52 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 2 Oct 2008 21:09:52 +0000 (UTC) Cc: emacs-devel@gnu.org To: Ted Zlatanov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Oct 02 23:10:50 2008 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1KlVRT-0002GD-H3 for ged-emacs-devel@m.gmane.org; Thu, 02 Oct 2008 23:10:35 +0200 Original-Received: from localhost ([127.0.0.1]:40252 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KlVQQ-0000fm-C3 for ged-emacs-devel@m.gmane.org; Thu, 02 Oct 2008 17:09:30 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KlVPX-00009y-FR for emacs-devel@gnu.org; Thu, 02 Oct 2008 17:08:35 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KlVPW-00009G-Cj for emacs-devel@gnu.org; Thu, 02 Oct 2008 17:08:34 -0400 Original-Received: from [199.232.76.173] (port=57015 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KlVPW-00009D-3J for emacs-devel@gnu.org; Thu, 02 Oct 2008 17:08:34 -0400 Original-Received: from chene.dit.umontreal.ca ([132.204.246.20]:45129) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KlVPU-0002VV-EE for emacs-devel@gnu.org; Thu, 02 Oct 2008 17:08:32 -0400 Original-Received: from ceviche.home (vpn-132-204-232-44.acd.umontreal.ca [132.204.232.44]) by chene.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id m92L8TV5005028; Thu, 2 Oct 2008 17:08:29 -0400 Original-Received: by ceviche.home (Postfix, from userid 20848) id 7F6CCB453F; Thu, 2 Oct 2008 14:55:10 -0400 (EDT) In-Reply-To: <864p3v2jwt.fsf@lifelogs.com> (Ted Zlatanov's message of "Thu, 02 Oct 2008 08:42:09 -0500") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 1 Rules triggered RV3117=0 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:104311 Archived-At: KH> How about reading a file in a unibyte buffer with KH> no-conversion, and decode one page by one into a view KH> buffer. Except for UTF-16 encoding, it is safe to set the KH> decoding boundary at newline positions. > That could work, but I'd have to grab more than one page every time, so > the math could get tricky. I'll have to play with this when it comes up > on my TODO list :) I'm not sure why you'd need such trick anyway. Supposedly when you need to read a new chunk, it's because the user bumped into the end of the previous chunk, so you've read the previous chunk and from that read you should be able to compute the byte-position of the last complete character. If that doesn't work in some cases (e.g. because the encoding has state so you can't just start reading from the byte position of the last complete char), maybe insert-file-contents should return a "decoder state" object when can then be passed back in. Stefan