help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Reading file in emacs


From: Kevin Rodgers
Subject: Re: Reading file in emacs
Date: Wed, 23 Jun 2010 00:38:49 -0600
User-agent: Thunderbird 2.0.0.24 (Macintosh/20100228)

Qiang Guo wrote:

I'm wondering if there is a way to read the content of files, say, to a
variable rather than a buffer ? Of course, one way to do
this is first read file into buffer and then edit the
buffer.

That is the best way to do it.  To get the content into a variable:

(let ((file-content (with-temp-buffer
                      (insert-file-contents "/path/to/file.txt")
                      (buffer-string))))
  ...
)

? Here comes my second question, how to process file
in a byte-by-byte fashion, for instance, instead of editing
a line of text, I'd like to edit directly their binary
representations ?

Use insert-file-contents-literally above.

I know this is best done by C/C++, or some other
languages. However, I just wonder the possibility of doing
this in emacs, the greatest editor ever :-)

The best tool for a job also depends on the craftsman using it.  For me
it is Emacs, not C/C++.

--
Kevin Rodgers
Denver, Colorado, USA




reply via email to

[Prev in Thread] Current Thread [Next in Thread]