From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: `call-process', to a string [Was: Re: Automatically set eww-download-directory according xdg dir] Date: Tue, 30 Oct 2018 08:57:03 +0200 Message-ID: <83k1lzly68.fsf@gnu.org> References: <87woq0sf4a.fsf@portable.galex-713.eu> <87pnvssegv.fsf@portable.galex-713.eu> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1540882500 22611 195.159.176.226 (30 Oct 2018 06:55:00 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 30 Oct 2018 06:55:00 +0000 (UTC) Cc: emacs-devel@gnu.org To: "Garreau\, Alexandre" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Oct 30 07:54:55 2018 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gHNvT-0005lo-Jt for ged-emacs-devel@m.gmane.org; Tue, 30 Oct 2018 07:54:55 +0100 Original-Received: from localhost ([::1]:51217 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHNxZ-0005OE-PY for ged-emacs-devel@m.gmane.org; Tue, 30 Oct 2018 02:57:05 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:41689) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHNxP-0005N6-Hh for emacs-devel@gnu.org; Tue, 30 Oct 2018 02:56:56 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gHNxM-0006s9-CJ for emacs-devel@gnu.org; Tue, 30 Oct 2018 02:56:55 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:58832) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHNxM-0006rs-8M; Tue, 30 Oct 2018 02:56:52 -0400 Original-Received: from [176.228.60.248] (port=1568 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1gHNxL-0003Pp-RO; Tue, 30 Oct 2018 02:56:52 -0400 In-reply-to: <87pnvssegv.fsf@portable.galex-713.eu> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:230804 Archived-At: > From: "Garreau\, Alexandre" > Date: Mon, 29 Oct 2018 21:08:32 +0100 > > 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). > > What would it be? > > In the `call-process' docstring related to the argument about output, > there’s nothing related to a string: My advice: don't build your process-related applications around strings, build them around buffers, temporary or otherwise. Emacs is much better with buffers than with strings, notably in the memory-management department; and making a string from a (portion of a) buffer is trivial, if you for some reason do need a string eventually.