unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
To: Qiang Guo <mcknight0219@gmail.com>
Cc: Emacs mailing list <help-gnu-emacs@gnu.org>
Subject: Re: Reading file in emacs
Date: Wed, 23 Jun 2010 08:11:59 +0300	[thread overview]
Message-ID: <20100623051159.C69E0456004@djcbsoftware.nl> (raw)
In-Reply-To: <m2aaqmjsw1.wl%Mcknight@Qiang-Guos-MacBook-Pro.local>

>>>>> 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



  reply	other threads:[~2010-06-23  5:11 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-23  4:05 Reading file in emacs Qiang Guo
2010-06-23  5:11 ` Dirk-Jan C. Binnema [this message]
2010-06-23  5:13 ` Dirk-Jan C. Binnema
2010-06-23  6:38 ` Kevin Rodgers
2010-06-23 11:28 ` Deniz Dogan
2010-06-23 14:38 ` Gary
     [not found] ` <mailman.4.1277292530.15366.help-gnu-emacs@gnu.org>
2010-06-24 10:26   ` Pascal J. Bourguignon
2010-06-24 11:20     ` Andreas Politz
2010-06-24 11:50       ` Pascal J. Bourguignon
     [not found] <mailman.0.1277266011.21451.help-gnu-emacs@gnu.org>
2010-06-23  9:05 ` John McCabe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100623051159.C69E0456004@djcbsoftware.nl \
    --to=djcb@djcbsoftware.nl \
    --cc=help-gnu-emacs@gnu.org \
    --cc=mcknight0219@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).