* Obtaining a Lisp form from a file
@ 2017-07-25 17:20 Udyant Wig
2017-07-25 17:31 ` John Mastro
2017-07-25 18:22 ` Emanuel Berg
0 siblings, 2 replies; 4+ messages in thread
From: Udyant Wig @ 2017-07-25 17:20 UTC (permalink / raw
To: help-gnu-emacs
Is there a better way to write this?
(let ((foo-buffer (get-buffer-create "*foo*"))
foo-form)
(with-current-buffer foo-buffer
(insert-file-contents foo-file))
(setq foo-form (read foo-buffer))
(kill-buffer foo-buffer)
foo-form)
--
... while the ways of art are hard at the best, they will break you if
you go unsustained by belief in what you are trying to do.
-- Arthur Quiller-Couch
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Obtaining a Lisp form from a file
2017-07-25 17:20 Obtaining a Lisp form from a file Udyant Wig
@ 2017-07-25 17:31 ` John Mastro
2017-07-26 7:22 ` Udyant Wig
2017-07-25 18:22 ` Emanuel Berg
1 sibling, 1 reply; 4+ messages in thread
From: John Mastro @ 2017-07-25 17:31 UTC (permalink / raw
To: help-gnu-emacs@gnu.org; +Cc: Udyant Wig
Udyant Wig <udyant.wig@gmail.com> wrote:
> Is there a better way to write this?
>
> (let ((foo-buffer (get-buffer-create "*foo*"))
> foo-form)
> (with-current-buffer foo-buffer
> (insert-file-contents foo-file))
> (setq foo-form (read foo-buffer))
> (kill-buffer foo-buffer)
> foo-form)
(with-temp-buffer
(insert-file-contents file)
(read (current-buffer)))
Hope that helps
John
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Obtaining a Lisp form from a file
2017-07-25 17:20 Obtaining a Lisp form from a file Udyant Wig
2017-07-25 17:31 ` John Mastro
@ 2017-07-25 18:22 ` Emanuel Berg
1 sibling, 0 replies; 4+ messages in thread
From: Emanuel Berg @ 2017-07-25 18:22 UTC (permalink / raw
To: help-gnu-emacs
Udyant Wig wrote:
> Is there a better way to write this?
>
> (let ((foo-buffer (get-buffer-create "*foo*"))
> foo-form) (with-current-buffer foo-buffer
> (insert-file-contents foo-file)) (setq foo-form
> (read foo-buffer)) (kill-buffer foo-buffer)
> foo-form)
If nothing else, stop using the foobar stuff.
Always give proper names. I understand it is
just for testing but 1) it tends to make
testing worse as it decreases the mental
discipline, and 2) often enough such supposedly
testing code makes it into the real thing (or
bugs occur at the point when "OK, now it works,
let's just rename it right").
--
underground experts united
http://user.it.uu.se/~embe8573
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Obtaining a Lisp form from a file
2017-07-25 17:31 ` John Mastro
@ 2017-07-26 7:22 ` Udyant Wig
0 siblings, 0 replies; 4+ messages in thread
From: Udyant Wig @ 2017-07-26 7:22 UTC (permalink / raw
To: help-gnu-emacs@gnu.org
On 07/25/2017 11:01 PM, John Mastro wrote:
> (with-temp-buffer
> (insert-file-contents file)
> (read (current-buffer)))
>
> Hope that helps
>
> John
That is much better. Thanks a lot.
--
... while the ways of art are hard at the best, they will break you if
you go unsustained by belief in what you are trying to do.
-- Arthur Quiller-Couch
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-07-26 7:22 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-25 17:20 Obtaining a Lisp form from a file Udyant Wig
2017-07-25 17:31 ` John Mastro
2017-07-26 7:22 ` Udyant Wig
2017-07-25 18:22 ` Emanuel Berg
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.