[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:
(with-output-to-string
(call-process "xdg-user-dir" nil standard-output nil "DOWNLOAD"))
--
Basil
- Automatically set eww-download-directory according xdg dir, Garreau\, Alexandre, 2018/10/29
- `call-process', to a string [Was: Re: Automatically set eww-download-directory according xdg dir], Garreau\, Alexandre, 2018/10/29
- `with-temp-buffer', `with-output-to-string': `with-temp-buffer-to-string' / `with-current-buffer-to-string' [Was: Re: `call-process', to a string], Garreau\, Alexandre, 2018/10/29
- 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],
Basil L. Contovounesios <=
- Re: `call-process', to a string [Was: Re: Automatically set eww-download-directory according xdg dir], Basil L. Contovounesios, 2018/10/29
- Re: `call-process', to a string, Garreau\, Alexandre, 2018/10/29
- Re: `call-process', to a string [Was: Re: Automatically set eww-download-directory according xdg dir], Eli Zaretskii, 2018/10/30
- Re: `call-process', to a string, Garreau\, Alexandre, 2018/10/30
- Re: `call-process', to a string, Eli Zaretskii, 2018/10/30
- Re: `call-process', to a string, Garreau\, Alexandre, 2018/10/30
- Re: `call-process', to a string, Eli Zaretskii, 2018/10/30
- `call-process', to a string, Garreau\, Alexandre, 2018/10/30
- Re: `call-process', to a string [Was: Re: Automatically set eww-download-directory according xdg dir], Basil L. Contovounesios, 2018/10/31
Re: `call-process', to a string [Was: Re: Automatically set eww-download-directory according xdg dir], Eli Zaretskii, 2018/10/30