[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: `with-temp-buffer', `with-output-to-string': `with-temp-buffer-to-st

From: Basil L. Contovounesios
Subject: Re: `with-temp-buffer', `with-output-to-string': `with-temp-buffer-to-string' / `with-current-buffer-to-string' [Was: Re: `call-process', to a string]
Date: Tue, 30 Oct 2018 02:26:04 +0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

"Garreau, Alexandre" <address@hidden> writes:

> On 2018-10-29 at 21:08, Garreau, Alexandre wrote:
>> On 2018-10-29 at 20:54, Garreau, Alexandre wrote:
>>>     (substring
>>>      (with-temp-buffer
>>>        (call-process "xdg-user-dir" nil t nil "DOWNLOAD")
>>>        (buffer-string))
>>>      0 -1)
>>> I am not sure this is the simplest way to call a process and get its
>>> output as string, without using the shell (there seem to be a
>>> shell-command-to-string, but no call-process-to-string, writing another
>>> mail about this).
> Searching for a better form, I found `with-output-to-string', which, in
> name, looks like what I want, but is for standard-output, for when emacs
> is ran without a frame I guess.

No, standard-output is just bound to a buffer, which is always a valid
input or output stream:

    (call-process "xdg-user-dir" nil standard-output nil "DOWNLOAD"))


reply via email to

[Prev in Thread] Current Thread [Next in Thread]