help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Maybe we can improve this function call-process-to-string?


From: Eli Zaretskii
Subject: Re: Maybe we can improve this function call-process-to-string?
Date: Thu, 08 Apr 2021 19:25:51 +0300

> Date: Thu, 8 Apr 2021 18:56:30 +0300
> From: Jean Louis <bugs@gnu.support>
> Cc: help-gnu-emacs@gnu.org
> 
> > Why do you need a string?  The string is a means to an end, right?
> > What is that end?
> 
> Hahaha, I am not sure if you are joking, but of course string is a
> mean to an end... funny. Now, I need it for example, to get widht and
> height from a image by using system command `identify', sometimes I
> will extract GPS coordinate from an image, so I call system commands
> from Emacs Lisp that processes bunch of images.

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?

> > > Because none of `buffer-substring' nor `buffer-string' can specify the
> > > buffer name then I have to switch temporarily to other buffer, get
> > > string with `buffer-string' and return back. I was thinking there is
> > > some function doing that straight, like (buffer-string BUFFER), but I
> > > don't find such.
> > 
> > I suggest to look up with-current-buffer and with-temp-buffer.
> 
> 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 ...))



reply via email to

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