Redirecting output to file with elisp 
Author Message
 Redirecting output to file with elisp

Hello,

        I'm writing a little program in emacs lisp, and I need to
redirect the output of, say, the print function to a file WITHOUT
executing a shell command to do it. Just pure elisp. Kind of the
equivalent of the shell command:

echo "arbitrary output" > /some_file.whatever

Except with pure elisp. How is this done?

Thanks very much.

--

Bryan Hoyt

-----------------------------------

Rock'n'Roll is to music what Etch-A-Sketch is to art.



Fri, 22 Aug 2003 05:10:42 GMT  
 Redirecting output to file with elisp

|       I'm writing a little program in emacs lisp, and I need to

You should ask Emacs Lisp questions in Emacs newsgroups such as
gnu.emacs.help.  Followups set.

| redirect the output of, say, the print function to a file WITHOUT
| executing a shell command to do it. Just pure elisp. Kind of the

I wrote the following convenience macro for this purpose:

(defmacro with-output-to-file (file &rest body)
  `(with-temp-file ,file
    (let ((standard-output (current-buffer)))

Study the documentation of with-temp-file, standard-output and
print to see how/why this works if it's not obvious to you.  With
that you can say, for example:

(with-output-to-file "foo"
  (print '(bar baz)))

--
Hannu



Fri, 22 Aug 2003 07:05:18 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Redirecting Output to files

2. Redirecting to TWO output files

3. Redirecting program output to file

4. how to redirect lpt1 to file-output

5. redirect g77 output into a file under windows xp

6. redirect output of functions to a string or file

7. Redirect file output into variables

8. redirect g77 under DOS 6.22- need output file

9. expect: redirect output into file called `uname -n'.txt

10. redirect exec output to a file

11. Redirecting output to a scratch file

12. Redirecting TCL script output to a file

 

 
Powered by phpBB® Forum Software