From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.help Subject: Re: Byte offset from point Date: Wed, 12 Aug 2009 22:47:39 +0300 Message-ID: <83k518ke5g.fsf@gnu.org> References: <87y6pouagb.fsf@iki.fi> <2c08d46a-482d-4c99-b815-f06a97f6e9de@d4g2000yqa.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: QUOTED-PRINTABLE X-Trace: ger.gmane.org 1250106641 8799 80.91.229.12 (12 Aug 2009 19:50:41 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 12 Aug 2009 19:50:41 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Aug 12 21:50:35 2009 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1MbJqE-0003l1-Jr for geh-help-gnu-emacs@m.gmane.org; Wed, 12 Aug 2009 21:50:34 +0200 Original-Received: from localhost ([127.0.0.1]:50969 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MbJqC-0000LP-3U for geh-help-gnu-emacs@m.gmane.org; Wed, 12 Aug 2009 15:50:32 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MbJnP-000806-Pm for help-gnu-emacs@gnu.org; Wed, 12 Aug 2009 15:47:39 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MbJnO-0007zh-S6 for help-gnu-emacs@gnu.org; Wed, 12 Aug 2009 15:47:39 -0400 Original-Received: from [199.232.76.173] (port=36279 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MbJnO-0007zc-Mn for help-gnu-emacs@gnu.org; Wed, 12 Aug 2009 15:47:38 -0400 Original-Received: from mtaout4.012.net.il ([84.95.2.10]:44796 helo=mtaout3.012.net.il) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MbJnO-0005Of-4A for help-gnu-emacs@gnu.org; Wed, 12 Aug 2009 15:47:38 -0400 Original-Received: from conversion-daemon.i_mtaout3.012.net.il by i_mtaout3.012.net.il (HyperSendmail v2004.12) id <0KOA00500415MZ00@i_mtaout3.012.net.il> for help-gnu-emacs@gnu.org; Wed, 12 Aug 2009 22:47:36 +0300 (IDT) Original-Received: from HOME-C4E4A596F7 ([77.127.68.70]) by i_mtaout3.012.net.il (HyperSendmail v2004.12) with ESMTPA id <0KOA00DYZ4BBD010@i_mtaout3.012.net.il> for help-gnu-emacs@gnu.org; Wed, 12 Aug 2009 22:47:36 +0300 (IDT) In-reply-to: <2c08d46a-482d-4c99-b815-f06a97f6e9de@d4g2000yqa.googlegroups.com> X-012-Sender: halo1@inter.net.il X-detected-operating-system: by monty-python.gnu.org: Solaris 9.1 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:67099 Archived-At: > From: senny > Date: Wed, 12 Aug 2009 12:06:26 -0700 (PDT) >=20 > > =A0 =A0 (position-bytes (point)) >=20 > I tried that but it gave me incorrect results when dealing with > newlines on windows. The lisp function counted them as 1 byte but t= he > service i was calling counted them as 2 bytes. If you want Emacs to account for the (potentially stripped) CR characters, you need to visit the file without any code conversions, e.g. with `find-file-literally' or with `insert-file-contents-literally'. Then position-bytes will count correctly. Alternatively, you could call count-lines-region and add one characte= r for each line before point. If this does not help, perhaps consider telling more about the proble= m you are trying to solve.