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: Automatically set eww-download-directory according xdg dir Date: Tue, 30 Oct 2018 09:16:38 +0200 Message-ID: <83ftwnlx9l.fsf@gnu.org> References: <87woq0sf4a.fsf@portable.galex-713.eu> <87h8h4tblg.fsf@tcd.ie> NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1540883672 5889 195.159.176.226 (30 Oct 2018 07:14:32 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 30 Oct 2018 07:14:32 +0000 (UTC) Cc: galex-713@galex-713.eu, emacs-devel@gnu.org To: "Basil L. Contovounesios" , Lars Ingebrigtsen Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Oct 30 08:14:27 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 1gHOEN-0001R3-FJ for ged-emacs-devel@m.gmane.org; Tue, 30 Oct 2018 08:14:27 +0100 Original-Received: from localhost ([::1]:51302 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHOGT-0004yr-Tn for ged-emacs-devel@m.gmane.org; Tue, 30 Oct 2018 03:16:37 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:46453) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHOGO-0004yb-7o for emacs-devel@gnu.org; Tue, 30 Oct 2018 03:16:32 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gHOGJ-0005Ha-FT for emacs-devel@gnu.org; Tue, 30 Oct 2018 03:16:32 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:59128) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHOGJ-0005HS-Bi; Tue, 30 Oct 2018 03:16:27 -0400 Original-Received: from [176.228.60.248] (port=2775 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1gHOGI-0002h4-Vh; Tue, 30 Oct 2018 03:16:27 -0400 In-reply-to: <87h8h4tblg.fsf@tcd.ie> (contovob@tcd.ie) 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:230805 Archived-At: > From: "Basil L. Contovounesios" > Date: Tue, 30 Oct 2018 02:25:15 +0000 > Cc: emacs-devel > > "Garreau, Alexandre" writes: > > > #+BEGIN_SRC emacs-lisp > > (defcustom eww-download-directory > > (substring > > (with-temp-buffer > > (call-process "xdg-user-dir" nil t nil "DOWNLOAD") > > (buffer-string)) > > 0 -1) > > "Directory where files will downloaded." > > :version "24.4" > > :group 'eww > > :type 'string) > > #+END_SRC > > > > 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). > > I think the simplest (often too simple) way to synchronously get process > output without using the shell is via the function process-lines: > > (car (process-lines "xdg-user-dir" "DOWNLOAD")) > > But you wouldn't want to use this to set the value of > eww-download-directory in its defcustom declaration as that would slow > down or potentially cause other issues when loading eww.el. Indeed, calling a subprocess in a defcustom should be avoided, to put it mildly. > FWIW, Emacs 26 includes the file lisp/xdg.el, which provides, amongst > other things, the function xdg-user-dir: Right, so that facility should be used if we want EWW to default to that place (which I'm not sure we should, btw; Lars?).