unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Maybe we can improve this function call-process-to-string?
@ 2021-04-08  7:40 Jean Louis
  2021-04-08  7:55 ` Eli Zaretskii
                   ` (2 more replies)
  0 siblings, 3 replies; 19+ messages in thread
From: Jean Louis @ 2021-04-08  7:40 UTC (permalink / raw)
  To: Help GNU Emacs

Hello,

There is function `shell-command-to-string' which is very handy. But
when there are problems with quoting it is better to use
`call-process'. Yet there is no function `call-process-to-string',
which I have made as below.

Maybe people can tell me how to improve this function?

(defun call-process-to-string (program &optional infile display &rest args)
  (let* ((buffer-name "Output")
	 (buffer (generate-new-buffer buffer-name))
	 (status (apply #'call-process program infile buffer display args))
	 (current-buffer (current-buffer))
	 (output (if status
		     (progn 
		       (switch-to-buffer buffer)
		       (buffer-string))
		   "")))
    (switch-to-buffer current-buffer)
    output))

(call-process-to-string "identify" nil nil "/home/data1/protected/2021-03-27-10:02:52.png")

Is there maybe some other function that can give me string from
buffer?


Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

Sign an open letter in support of Richard M. Stallman
https://rms-support-letter.github.io/





^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2021-04-09 10:07 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

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).