From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Jeff Clough Newsgroups: gmane.emacs.help Subject: Re: Emacs Lisp - Reading a sequence of bytes as one integer Date: Sat, 13 Mar 2010 13:10:29 -0500 (EST) Message-ID: <20100313.131029.39330337.jeff@chaosphere.com> References: <20100313.115617.104330838.jeff@chaosphere.com> <87hbokgn22.fsf@mithlond.arda> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1268503674 4110 80.91.229.12 (13 Mar 2010 18:07:54 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 13 Mar 2010 18:07:54 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Mar 13 19:07:49 2010 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.69) (envelope-from ) id 1NqVka-0006ba-VV for geh-help-gnu-emacs@m.gmane.org; Sat, 13 Mar 2010 19:07:49 +0100 Original-Received: from localhost ([127.0.0.1]:60278 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NqVka-00014A-9A for geh-help-gnu-emacs@m.gmane.org; Sat, 13 Mar 2010 13:07:48 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NqVkC-00012n-5O for help-gnu-emacs@gnu.org; Sat, 13 Mar 2010 13:07:24 -0500 Original-Received: from [140.186.70.92] (port=57478 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NqVkA-00012D-UG for help-gnu-emacs@gnu.org; Sat, 13 Mar 2010 13:07:23 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1NqVk9-0006J7-7p for help-gnu-emacs@gnu.org; Sat, 13 Mar 2010 13:07:22 -0500 Original-Received: from hrndva-omtalb.mail.rr.com ([71.74.56.123]:58097) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NqVk9-0006Ip-5l for help-gnu-emacs@gnu.org; Sat, 13 Mar 2010 13:07:21 -0500 X-Authority-Analysis: v=1.0 c=1 a=NZNNiAkOFsgA:10 a=kj9zAlcOel0A:10 a=WKFwXhbB9Tjpz6scLBYA:9 a=3Lp6CfjEa1ranDwxY78A:7 a=atfJnnOmyUWTsKKP0uIfLMnCMcYA:4 a=CjuIK1q_8ugA:10 X-Cloudmark-Score: 0 X-Originating-IP: 74.70.71.134 Original-Received: from [74.70.71.134] ([74.70.71.134:57173] helo=localhost) by hrndva-oedge03.mail.rr.com (envelope-from ) (ecelerity 2.2.2.39 r()) with ESMTP id E9/C8-01194-854DB9B4; Sat, 13 Mar 2010 18:07:20 +0000 In-Reply-To: <87hbokgn22.fsf@mithlond.arda> X-Mailer: Mew version 6.3 on Emacs 23.1 / Mule 6.0 (HANACHIRUSATO) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. 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:72418 Archived-At: From: Teemu Likonen Date: Sat, 13 Mar 2010 19:15:49 +0200 > You can use the Lisp reader: > > (read "123") => 123 > > The argument for READ can also be a buffer or a marker, for example. See > its documentation for more info. This is not seeming to work, and I'm not seeing how to make it work. I can't tell if this is just my not getting something, or if it isn't the right tool for the job. Just in case, here's an example of what I'm needing... At certain positions in the file (and I can already find them), I need to read a sequence of three bytes as an integer. If I do a "hexdump -c" on the file, I can see that those three bytes look like this "\0 \0 \t", which would give me a decimal value of 9 if read as a single integer. If I grab this sequence from the file using buffer-substring and pass it to read, I get an end-of-file error. Is there some general way I can tell emacs "Take the three bytes following point and make one integer out of them"? Thanks! Jeff