From xemacs-m  Thu Feb 27 06:50:16 1997
Received: from jagor.srce.hr (hniksic@jagor.srce.hr [161.53.2.130])
	by xemacs.org (8.8.5/8.8.5) with ESMTP id GAA25252
	for <xemacs-beta@xemacs.org>; Thu, 27 Feb 1997 06:50:06 -0600 (CST)
Received: (from hniksic@localhost)
          by jagor.srce.hr (8.8.5/8.8.4)
	  id NAA16705; Thu, 27 Feb 1997 13:49:54 +0100 (MET)
Sender: hniksic@public.srce.hr
To: xemacs-beta@xemacs.org
Subject: [comp.emacs] Re: calling a unix prog from elisp
X-URL: ftp://gnjilux.cc.fer.hr/pub/unix/util/wget/
X-Attribution: Hrv
X-Face: &}4JQk=L;e.~x+|eo]#DGk@x3~ed!.~lZ}YQcYb7f[WL9L'Z*+OyA\nAEL1M(".[qvI#a2E
 6WYI5>>e7'@_)3Ol9p|Nn2wNa/;~06jL*B%tTcn/XvhAu7qeES0\|MF%$;sI#yn1+y"
From: Hrvoje Niksic <hniksic@srce.hr>
Date: 27 Feb 1997 13:49:53 +0100
Message-ID: <kigrai2xvke.fsf@jagor.srce.hr>
Lines: 61
X-Mailer: Gnus v5.4.15/XEmacs 19.14

How about adding `with-temp-buffer' to prim/somewhere?  I have
evaluated it, and

(with-temp-buffer (call-process "ls" "/dev/null" t nil "-al") (buffer-string))

works fine for me.  I'd hate to see Erik's work go unattended in
XEmacs. ;-)

-- 
Hrvoje Niksic <hniksic@srce.hr> | Student at FER Zagreb, Croatia
--------------------------------+--------------------------------
Thou Who might be our Father Who perhaps may be in Heaven...
                                                  -- Zelazny
------- Start of forwarded message -------
From: Erik Naggum <erik@naggum.no>
Newsgroups: comp.emacs
Subject: Re: calling a unix prog from elisp
Date: 27 Feb 1997 10:22:23 +0000
Organization: Naggum Software; +47 2295 0313; http://www.naggum.no
Message-ID: <3066027743283776@naggum.no>
References: <5f2lhm$edm@news3.texas.net>
mail-copies-to: never

* Dan Lipofsky
| I want to call a unix program from inside my .emacs file, and set a
| variable to the string that results from the call.  How do I do this?

Emacs cannot collect process output into a string directly, but must go
through a buffer.  this form collects the output as a string.  note that
standard output and standard error of the process are merged.  if this
doesn't suit you, read up on the documentation for `call-process'.

    (with-temp-buffer
      (call-process <program> <input-file> t nil <args>...)
      (buffer-string))

I think the `with-temp-buffer' was added after 19.34 was released.  here is
a version for 19.34 and earlier:

    (defmacro with-temp-buffer (&rest forms)
      "Create a temporary buffer, and evaluate FORMS there like `progn'."
      (let ((temp-buffer (make-symbol "temp-buffer")))
	`(let ((,temp-buffer
		(get-buffer-create (generate-new-buffer-name " *temp*"))))
	   (unwind-protect
	       (save-excursion
		 (set-buffer ,temp-buffer)
		 ,@forms)
	     (and (buffer-name ,temp-buffer)
		  (kill-buffer ,temp-buffer))))))

caveat: it's possible that this use of `make-symbol' is not fully supported
by the byte-compiler in 19.34.  I did something to print uninterned symbols
(as are returned by `make-symbol') right, but I forget when.

anyway, I hope you get the idea.

#\Erik
-- 
if you think big enough, you never have to do it
------- End of forwarded message -------

