From: Jean Louis <bugs@gnu.support>
To: Eli Zaretskii <eliz@gnu.org>
Cc: help-gnu-emacs@gnu.org
Subject: Re: Maybe we can improve this function call-process-to-string?
Date: Thu, 8 Apr 2021 21:17:15 +0300 [thread overview]
Message-ID: <YG9Iq4NkB5RZC8n4@protected.localdomain> (raw)
In-Reply-To: <83o8eo920g.fsf@gnu.org>
* Eli Zaretskii <eliz@gnu.org> [2021-04-08 19:30]:
> So you actually need the numbers reported by those commands? if so,
> you can read them from the buffer into which the command's output is
> stored, right? You don't actually need the numbers in their string
> form, right?
In that particular example numbers are just used as string, but
sometimes I need numbers. That may not be most important. I do not
understand your method of getting output from external command.
How practically to do it?
I understood reading it from buffer is different than reading from
shell-command-to-string.
Then to have output in buffer, I need call-process, but then again I
need to enter that buffer and read string out of it. Example is here:
(defun call-process-to-string (program &optional infile display &rest args)
(let* ((buffer-name "RCD Emacs Lisp output")
(buffer (generate-new-buffer buffer-name))
(status (apply #'call-process program infile buffer display args))
(current-buffer (current-buffer))
(output (buffer-to-string buffer)))
(kill-buffer buffer)
output))
Again I have to use strings there.
> > I would not know how to get output from system command by using those
> > functions without using shell-command-to-string or call-process
>
> You said buffer-substring doesn't take a buffer as an argument. I'm
> suggesting something like
>
> (with-current-buffer (get-buffer "foo")
> (buffer-substring ...))
That again comes back as a string, right? I do use that type, in the
above function for example.
Jean
next prev parent reply other threads:[~2021-04-08 18:17 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-08 7:40 Maybe we can improve this function call-process-to-string? Jean Louis
2021-04-08 7:55 ` Eli Zaretskii
2021-04-08 11:53 ` Jean Louis
2021-04-08 13:39 ` Eli Zaretskii
2021-04-08 15:56 ` Jean Louis
2021-04-08 16:25 ` Eli Zaretskii
2021-04-08 18:17 ` Jean Louis [this message]
2021-04-08 18:36 ` Eli Zaretskii
2021-04-08 18:44 ` Jean Louis
2021-04-08 17:18 ` Arthur Miller
2021-04-08 18:32 ` Jean Louis
2021-04-08 19:41 ` Arthur Miller
2021-04-09 8:52 ` Jean Louis
2021-04-09 10:07 ` tomas
2021-04-08 13:08 ` Michael Albinus
2021-04-08 15:50 ` Jean Louis
2021-04-08 17:49 ` Stefan Monnier
2021-04-08 18:33 ` Jean Louis
2021-04-08 18:40 ` Jean Louis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YG9Iq4NkB5RZC8n4@protected.localdomain \
--to=bugs@gnu.support \
--cc=eliz@gnu.org \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).