From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ted Zlatanov Newsgroups: gmane.emacs.devel Subject: Re: docs for insert-file-contents use 'bytes' Date: Tue, 30 Sep 2008 08:48:28 -0500 Organization: =?utf-8?B?0KLQtdC+0LTQvtGAINCX0LvQsNGC0LDQvdC+0LI=?= @ Cienfuegos Message-ID: <8663od68yb.fsf@lifelogs.com> References: <86ljxa67xi.fsf@lifelogs.com> <86hc7y64vm.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 1222782560 7491 80.91.229.12 (30 Sep 2008 13:49:20 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 30 Sep 2008 13:49:20 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Sep 30 15:50:18 2008 connect(): Connection refused 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 1Kkfbr-00057q-D6 for ged-emacs-devel@m.gmane.org; Tue, 30 Sep 2008 15:49:51 +0200 Original-Received: from localhost ([127.0.0.1]:60924 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Kkfao-000836-NG for ged-emacs-devel@m.gmane.org; Tue, 30 Sep 2008 09:48:46 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Kkfak-00082u-8X for emacs-devel@gnu.org; Tue, 30 Sep 2008 09:48:42 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Kkfai-00082S-EW for emacs-devel@gnu.org; Tue, 30 Sep 2008 09:48:41 -0400 Original-Received: from [199.232.76.173] (port=37632 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Kkfai-00082P-95 for emacs-devel@gnu.org; Tue, 30 Sep 2008 09:48:40 -0400 Original-Received: from main.gmane.org ([80.91.229.2]:35073 helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Kkfah-0004ee-Ks for emacs-devel@gnu.org; Tue, 30 Sep 2008 09:48:40 -0400 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1Kkfaf-0008En-KH for emacs-devel@gnu.org; Tue, 30 Sep 2008 13:48:37 +0000 Original-Received: from 38.98.147.130 ([38.98.147.130]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 30 Sep 2008 13:48:37 +0000 Original-Received: from tzz by 38.98.147.130 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 30 Sep 2008 13:48:37 +0000 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 64 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 38.98.147.130 X-Face: bd.DQ~'29fIs`T_%O%C\g%6jW)yi[zuz6; d4V0`@y-~$#3P_Ng{@m+e4o<4P'#(_GJQ%TT= D}[Ep*b!\e,fBZ'j_+#"Ps?s2!4H2-Y"sx" User-Agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.0.60 (gnu/linux) Cancel-Lock: sha1:oW8Wd11NYQGCzu71f/qiyEYMl+o= X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) 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:104258 Archived-At: On Tue, 30 Sep 2008 10:19:26 +0300 Eli Zaretskii wrote: >> From: Ted Zlatanov >> Date: Mon, 29 Sep 2008 16:04:13 -0500 >> >> This is not a safe operation mode with multibyte sequences; is there a >> way to DTRT? I'm specifically thinking about a paged buffer mode where >> you only see a small portion of the file (for editing large files, as we >> discussed in another newsgroup a while ago). EZ> How about this idea: read a bit more than you want, then find safe EZ> place to end this page-full? How do I find the next safe position in the byte flow? >> I don't know if this is the right wording, but it's a pretty essential >> operation so it should give some warning about this common (nowadays) >> case. EZ> Is it really a common case that insert-file-contents is used to read a EZ> portion of a file? Where is this used? I want to use it to implement a paged view of large files. We discussed this in emacs-help and you suggested using insert-file-contents IIRC. Anyhow, the point is the docs don't mention this issue, let's fix that first. I mention one possible way to do the code below. On Tue, 30 Sep 2008 15:06:17 +0900 Miles Bader wrote: MB> Ted Zlatanov writes: EZ> Like with any other random bytes, I think: it will produce eight-bit-* EZ> characters in the buffer. IOW, you get garbled text. >> >> This is not a safe operation mode with multibyte sequences; is there a >> way to DTRT? I'm specifically thinking about a paged buffer mode where >> you only see a small portion of the file (for editing large files, as we >> discussed in another newsgroup a while ago). MB> Why is it "not safe"? Because the text will be corrupted if you seek in the middle of a multibyte sequence, and there's no way to know in advance if a position is safe without at least some scanning. MB> How would you do things differently? I don't know, I'm just saying the docs don't mention the possibility of corrupted text. Can we fix that, if possible? The docs just need to warn, not solve the issue. MB> In conjunction with _file_ contents, a byte offset seems certainly the MB> most natural thing. An "encoded character offset", for instance, would MB> be far less efficient, much more complex to implement (and thus MB> buggier), and harder to use in general. Agreed. Still, encoding schemes like UTF-8 are so popular today that the docs should at least warn about careless seeking to a byte offset. There could be a insert-file-decoded-contents that seeks to a byte position and gets the next character at or after that position. That's not too hard to implement and it's fast. Ted