From xemacs-m  Thu Feb 27 07:02:23 1997
Received: from mgate.uni-hannover.de (mgate.uni-hannover.de [130.75.2.3])
	by xemacs.org (8.8.5/8.8.5) with SMTP id HAA26485
	for <xemacs-beta@xemacs.org>; Thu, 27 Feb 1997 07:02:21 -0600 (CST)
Received: from helios (actually helios.tnt.uni-hannover.de) by mgate 
          with SMTP (PP); Thu, 27 Feb 1997 14:02:12 +0100
Received: from daedalus.tnt.uni-hannover.de by helios (SMI-8.6/SMI-SVR4) 
          id OAA04597; Thu, 27 Feb 1997 14:01:27 +0100
Received: by daedalus.tnt.uni-hannover.de (SMI-8.6/SMI-SVR4) id OAA09860;
          Thu, 27 Feb 1997 14:01:27 +0100
Date: Thu, 27 Feb 1997 14:01:27 +0100
Message-Id: <199702271301.OAA09860@daedalus.tnt.uni-hannover.de>
From: Heiko Muenkel <muenkel@tnt.uni-hannover.de>
MIME-Version: 1.0
To: hniksic@srce.hr
Cc: xemacs-beta@xemacs.org
Subject: Re: [comp.emacs] Re: calling a unix prog from elisp
In-Reply-To: <kigrai2xvke.fsf@jagor.srce.hr>
References: <kigrai2xvke.fsf@jagor.srce.hr>
X-Face: n}R'l6CHRf>pi&bj7[x0CW3:kmXm@1)7m+l*9[fp;-Ow4Xe~=5E;skf?2> 
        y]f{HzB|Q(\V9+y$PP~.4G[2n4W7{6Ilm[AMY9B:0kj.K_$-d%p4YIF*bX;=ADp6{ 
        HS@NEv9c.VII+9PgXHASx}K(jy^t=q%qzZ72q1e4E;O!$A$`&wgtLk"1%p.nC_G!] 
        4d1!+J4Q#YD_iXeEy`1x)d\r$1Qn\'23n|[8Y_xzuXJJ7W(EGqnzB]`]aq??;+z=) 
        DW~\'Vq&F'g%QU[Mv2:}nS>SdZFTEC2GsgB=Q,:~H<R5S[:ZN%B:s0;|v1x"Jb
Content-Type: text/plain; charset=US-ASCII

>>>>> "Hrv" == Hrvoje Niksic <hniksic@srce.hr> writes:

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

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

What's the difference to with-output-to-temp-buffer or
with-output-to-temp-buffer-in-window?

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

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

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

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

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

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

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

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

    Hrv> anyway, I hope you get the idea.

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

