From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#20704: info.el bug fix; Interprets Info format wrongly Date: Tue, 09 Jun 2015 17:29:09 +0300 Message-ID: <83mw09t0p6.fsf@gnu.org> References: <87d21gpzle.fsf@tower.recompile.se> <83382btqcc.fsf@gnu.org> <87h9qhf8a3.fsf@tower.recompile.se> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1433860246 4191 80.91.229.3 (9 Jun 2015 14:30:46 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 9 Jun 2015 14:30:46 +0000 (UTC) Cc: 20704@debbugs.gnu.org To: Teddy Hogeborn Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Jun 09 16:30:30 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1Z2KXm-00004s-NK for geb-bug-gnu-emacs@m.gmane.org; Tue, 09 Jun 2015 16:30:22 +0200 Original-Received: from localhost ([::1]:35440 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z2KXl-0000u9-IS for geb-bug-gnu-emacs@m.gmane.org; Tue, 09 Jun 2015 10:30:21 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38993) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z2KXb-0000jd-SF for bug-gnu-emacs@gnu.org; Tue, 09 Jun 2015 10:30:17 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z2KXY-0000DO-ID for bug-gnu-emacs@gnu.org; Tue, 09 Jun 2015 10:30:11 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:36361) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z2KXY-0000D1-Fj for bug-gnu-emacs@gnu.org; Tue, 09 Jun 2015 10:30:08 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1Z2KXX-00065b-1F for bug-gnu-emacs@gnu.org; Tue, 09 Jun 2015 10:30:07 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 09 Jun 2015 14:30:06 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 20704 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 20704-submit@debbugs.gnu.org id=B20704.143386017523345 (code B ref 20704); Tue, 09 Jun 2015 14:30:06 +0000 Original-Received: (at 20704) by debbugs.gnu.org; 9 Jun 2015 14:29:35 +0000 Original-Received: from localhost ([127.0.0.1]:46335 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Z2KX0-00064T-5Q for submit@debbugs.gnu.org; Tue, 09 Jun 2015 10:29:34 -0400 Original-Received: from mtaout21.012.net.il ([80.179.55.169]:49948) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Z2KWw-00064D-Pg for 20704@debbugs.gnu.org; Tue, 09 Jun 2015 10:29:31 -0400 Original-Received: from conversion-daemon.a-mtaout21.012.net.il by a-mtaout21.012.net.il (HyperSendmail v2007.08) id <0NPO00000LKUV600@a-mtaout21.012.net.il> for 20704@debbugs.gnu.org; Tue, 09 Jun 2015 17:29:21 +0300 (IDT) Original-Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout21.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0NPO00098LKWU940@a-mtaout21.012.net.il>; Tue, 09 Jun 2015 17:29:21 +0300 (IDT) In-reply-to: <87h9qhf8a3.fsf@tower.recompile.se> X-012-Sender: halo1@inter.net.il X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:103766 Archived-At: > From: Teddy Hogeborn > Cc: Stefan Monnier , 20704@debbugs.gnu.org > Date: Tue, 09 Jun 2015 13:09:08 +0200 > > Eli Zaretskii writes: > > > > > + (+ (point-min) (byte-to-position > > > > + (read (current-buffer)))) > > > > > > Hmm... this only works if the Info file is encoded in UTF-8. I > > > guess in the case of Info, 99% of the files are just ASCII and > > > there's a chance that the vast majority of the rest is (or will be) > > > UTF-8, so maybe this hack works well in practice. > > > > Using byte-to-position would make things worse for Latin-1 and the > > likes. > > No, byte-to-position already checks for that: > > ---- src/marker.c, line 302 > /* If this buffer has as many characters as bytes, > each character must be one byte. > This takes care of the case where enable-multibyte-characters is nil. */ > if (best_above == best_above_byte) > return bytepos; > ---- I think you are misreading the code: the above snippet is for unibyte buffers, whereas a Latin-1 encoded Info file will be read into a multibyte buffer (and decoded into the internal Emacs representation of characters during the read). So this optimization is not going to work in that case. IOW, what matters for byte-to-position is the encoding used in representing characters in Emacs buffers, not the one used externally by the Info file on disk. > Therefore, an Info file in Latin-1 should work just fine. > > > But it shouldn't be hard to add a simple test of > > buffer-file-coding-system: if it states fixed-size encoding, like any > > of the 8-bit encodings, or UTF-16, > > the conversion to character position is trivial. > > I think you mean UTF-32 instead of UTF-16, since UTF-16 is variable- > length. UTF-16 is fixed length for characters in the BMP.