From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dirk-Jan C. Binnema Newsgroups: gmane.emacs.help Subject: Re: Reading file in emacs Date: Wed, 23 Jun 2010 08:11:59 +0300 Organization: DJCBSoftware Message-ID: <20100623051159.C69E0456004@djcbsoftware.nl> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII X-Trace: dough.gmane.org 1277269958 27809 80.91.229.12 (23 Jun 2010 05:12:38 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 23 Jun 2010 05:12:38 +0000 (UTC) Cc: Emacs mailing list To: Qiang Guo Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Jun 23 07:12:37 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 1ORIGK-0005og-FL for geh-help-gnu-emacs@m.gmane.org; Wed, 23 Jun 2010 07:12:36 +0200 Original-Received: from localhost ([127.0.0.1]:57609 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ORIGJ-0005z5-Ek for geh-help-gnu-emacs@m.gmane.org; Wed, 23 Jun 2010 01:12:35 -0400 Original-Received: from [140.186.70.92] (port=43790 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ORIFs-0005vo-Mb for help-gnu-emacs@gnu.org; Wed, 23 Jun 2010 01:12:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1ORIFr-0006pI-H4 for help-gnu-emacs@gnu.org; Wed, 23 Jun 2010 01:12:08 -0400 Original-Received: from vs12.mail.saunalahti.fi ([195.197.172.107]:59982) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1ORIFr-0006ou-9N for help-gnu-emacs@gnu.org; Wed, 23 Jun 2010 01:12:07 -0400 Original-Received: from saunalahti-vams (localhost [127.0.0.1]) by vs12.mail.saunalahti.fi (Postfix) with SMTP id 66BFD1A9038; Wed, 23 Jun 2010 08:12:02 +0300 (EEST) Original-Received: from vs12.mail.saunalahti.fi ([127.0.0.1]) by vs12.mail.saunalahti.fi ([195.197.172.107]) with SMTP (gateway) id A02D3764087; Wed, 23 Jun 2010 08:12:02 +0300 Original-Received: from gw02.mail.saunalahti.fi (gw02.mail.saunalahti.fi [195.197.172.116]) by vs12.mail.saunalahti.fi (Postfix) with ESMTP id 592221A9038; Wed, 23 Jun 2010 08:12:02 +0300 (EEST) Original-Received: from djcbsoftware.nl (a88-114-89-181.elisa-laajakaista.fi [88.114.89.181]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by gw02.mail.saunalahti.fi (Postfix) with ESMTP id 628951395DF; Wed, 23 Jun 2010 08:12:00 +0300 (EEST) Original-Received: from cthulhu.mindcrime.djcbsoftware.nl (localhost [127.0.0.1]) by djcbsoftware.nl (Postfix) with ESMTP id C69E0456004; Wed, 23 Jun 2010 08:11:59 +0300 (EEST) In-Reply-To: Mail-Reply-To: djcb@djcbsoftware.nl User-Agent: Wanderlust/2.15.9 (Almost Unreal) Emacs/24.0 Mule/6.0 (HANACHIRUSATO) X-Antivirus: VAMS X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) 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:73963 Archived-At: >>>>> On Tue, 22 Jun 2010 22:05:18 -0600, Qiang Guo ("QG") wrote: QG> Hi, QG> I'm wondering if there is a way to read the content of files, say, to a QG> variable rather than a buffer ? Of course, one way to do QG> this is first read file into buffer and then edit the QG> buffer. Here comes my second question, how to process file QG> in a byte-by-byte fashion, for instance, instead of editing QG> a line of text, I'd like to edit directly their binary QG> representations ? I'd bet there are more elegant (elispy) ways to do this, but to read a file into a variable, you could do something like: (setq filedata (shell-command-to-string "cat /foo/bar/myfile")) Best wishes, Dirk. -- Dirk-Jan C. Binnema Helsinki, Finland e:djcb@djcbsoftware.nl w:www.djcbsoftware.nl pgp: D09C E664 897D 7D39 5047 A178 E96A C7A1 017D DA3C