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

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

Re: how to read file's content using elisp?


From: John Sullivan
Subject: Re: how to read file's content using elisp?
Date: Wed, 15 Sep 2004 14:10:34 -0400
User-agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux)

Rokia <Rokiadd@yahoo.com.cn.discuss> writes:

> what I want to do is reading a file's content into a string
> variable. like this.
>
> (setq dddstring (foo-read-file "dd.txt"))
> (prin1 dddstring)

I'm not trustworthy on these matters, but here's a once-tested
quickie:

(defun foo-read-file (full-filename)
  "Read a file and return foo-file as a string."
  (with-temp-buffer
    (insert-file-contents full-filename)
    (buffer-string)))

This should work with the syntax you used.

-John


       

Attachment: pgpAk3vKEmLqw.pgp
Description: PGP signature


reply via email to

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