* how to read file's content using elisp?
@ 2004-09-15 11:34 Rokia
2004-09-15 12:07 ` Barry Margolin
` (2 more replies)
0 siblings, 3 replies; 11+ messages in thread
From: Rokia @ 2004-09-15 11:34 UTC (permalink / raw)
I want get a file's content. I didn't find the right function.
I has RTFM. there is only a function which can read file's content to
the buffer's position.
thanks for your help.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: how to read file's content using elisp?
2004-09-15 11:34 how to read file's content using elisp? Rokia
@ 2004-09-15 12:07 ` Barry Margolin
2004-09-15 16:03 ` Rokia
2004-09-15 12:10 ` Eli Zaretskii
2004-09-15 12:53 ` Miguel Frasson
2 siblings, 1 reply; 11+ messages in thread
From: Barry Margolin @ 2004-09-15 12:07 UTC (permalink / raw)
In article <uacvrix5e.fsf@yahoo.com.cn.discuss>,
Rokia <Rokiadd@yahoo.com.cn.discuss> wrote:
> I want get a file's content. I didn't find the right function.
>
> I has RTFM. there is only a function which can read file's content to
> the buffer's position.
What you generally do is load the file into a buffer and process it
there.
--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: how to read file's content using elisp?
2004-09-15 12:07 ` Barry Margolin
@ 2004-09-15 16:03 ` Rokia
2004-09-15 17:30 ` Henrik Enberg
` (3 more replies)
0 siblings, 4 replies; 11+ messages in thread
From: Rokia @ 2004-09-15 16:03 UTC (permalink / raw)
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)
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: how to read file's content using elisp?
2004-09-15 16:03 ` Rokia
@ 2004-09-15 17:30 ` Henrik Enberg
2004-09-15 18:10 ` John Sullivan
` (2 subsequent siblings)
3 siblings, 0 replies; 11+ messages in thread
From: Henrik Enberg @ 2004-09-15 17:30 UTC (permalink / raw)
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)
(setq dddstring (with-temp-buffer
(insert-file-contents "dd.txt")
(buffer-string)))
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: how to read file's content using elisp?
2004-09-15 16:03 ` Rokia
2004-09-15 17:30 ` Henrik Enberg
@ 2004-09-15 18:10 ` John Sullivan
[not found] ` <mailman.2915.1095289010.1998.help-gnu-emacs@gnu.org>
2004-09-16 10:43 ` Eli Zaretskii
3 siblings, 0 replies; 11+ messages in thread
From: John Sullivan @ 2004-09-15 18:10 UTC (permalink / raw)
[-- Attachment #1.1: Type: text/plain, Size: 501 bytes --]
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 #1.2: Type: application/pgp-signature, Size: 188 bytes --]
[-- Attachment #2: Type: text/plain, Size: 152 bytes --]
_______________________________________________
Help-gnu-emacs mailing list
Help-gnu-emacs@gnu.org
http://lists.gnu.org/mailman/listinfo/help-gnu-emacs
^ permalink raw reply [flat|nested] 11+ messages in thread
[parent not found: <mailman.2915.1095289010.1998.help-gnu-emacs@gnu.org>]
* Re: how to read file's content using elisp?
2004-09-15 16:03 ` Rokia
` (2 preceding siblings ...)
[not found] ` <mailman.2915.1095289010.1998.help-gnu-emacs@gnu.org>
@ 2004-09-16 10:43 ` Eli Zaretskii
3 siblings, 0 replies; 11+ messages in thread
From: Eli Zaretskii @ 2004-09-16 10:43 UTC (permalink / raw)
> From: Rokia <Rokiadd@yahoo.com.cn.discuss>
> Date: Thu, 16 Sep 2004 00:03:09 +0800
>
>
> what I want to do is reading a file's content into a string
> variable.
That is actually not a very good idea in Emacs Lisp. In Emacs Lisp,
it is much easier to manipulate text in a buffer than to manipulate
text in a string. For starters, buffers are managed memory-wise much
more efficiently (so the code that uses a buffer is generally faster),
and there are many functions that only work on buffers.
So I suggest to redesign the solution to whatever problem you are
trying to deal with, such that you use a buffer (perhaps a temporary
one) instead of a string.
What problem was that, anyway?
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: how to read file's content using elisp?
2004-09-15 11:34 how to read file's content using elisp? Rokia
2004-09-15 12:07 ` Barry Margolin
@ 2004-09-15 12:10 ` Eli Zaretskii
2004-09-15 12:53 ` Miguel Frasson
2 siblings, 0 replies; 11+ messages in thread
From: Eli Zaretskii @ 2004-09-15 12:10 UTC (permalink / raw)
> From: Rokia <Rokiadd@yahoo.com.cn.discuss>
> Date: Wed, 15 Sep 2004 19:34:05 +0800
>
>
> I want get a file's content. I didn't find the right function.
>
> I has RTFM. there is only a function which can read file's content to
> the buffer's position.
If you mean insert-file-contents, then that's how you read a file into
Emacs. Please explain why this is not good for you, and someone will
show you how to overcome the difficulties.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: how to read file's content using elisp?
2004-09-15 11:34 how to read file's content using elisp? Rokia
2004-09-15 12:07 ` Barry Margolin
2004-09-15 12:10 ` Eli Zaretskii
@ 2004-09-15 12:53 ` Miguel Frasson
2 siblings, 0 replies; 11+ messages in thread
From: Miguel Frasson @ 2004-09-15 12:53 UTC (permalink / raw)
Rokia <Rokiadd@yahoo.com.cn.discuss> writes:
> I want get a file's content. I didn't find the right function.
>
> I has RTFM. there is only a function which can read file's content to
> the buffer's position.
>
> thanks for your help.
find-file (C-x C-f) is the more common way to read the file's content
(into a NEW buffer). Try to see the `File' menu.
--
Miguel Vinicius Santini Frasson
http://www.math.leidenuniv.nl/~frasson
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2004-09-16 10:43 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-09-15 11:34 how to read file's content using elisp? Rokia
2004-09-15 12:07 ` Barry Margolin
2004-09-15 16:03 ` Rokia
2004-09-15 17:30 ` Henrik Enberg
2004-09-15 18:10 ` John Sullivan
[not found] ` <mailman.2915.1095289010.1998.help-gnu-emacs@gnu.org>
2004-09-16 0:50 ` Rokia
2004-09-16 1:25 ` Rokia
2004-09-16 2:17 ` Barry Margolin
2004-09-16 10:43 ` Eli Zaretskii
2004-09-15 12:10 ` Eli Zaretskii
2004-09-15 12:53 ` Miguel Frasson
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.