From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: "Basil L. Contovounesios" Newsgroups: gmane.emacs.devel Subject: Re: Automatically set eww-download-directory according xdg dir Date: Tue, 30 Oct 2018 02:25:15 +0000 Message-ID: <87h8h4tblg.fsf@tcd.ie> References: <87woq0sf4a.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: quoted-printable X-Trace: blaine.gmane.org 1540866269 15854 195.159.176.226 (30 Oct 2018 02:24:29 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 30 Oct 2018 02:24:29 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: emacs-devel To: "Garreau\, Alexandre" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Oct 30 03:24:24 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 1gHJhg-000402-Nr for ged-emacs-devel@m.gmane.org; Tue, 30 Oct 2018 03:24:24 +0100 Original-Received: from localhost ([::1]:50320 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHJjn-00023H-9N for ged-emacs-devel@m.gmane.org; Mon, 29 Oct 2018 22:26:35 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35014) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHJim-00022w-Ko for emacs-devel@gnu.org; Mon, 29 Oct 2018 22:25:36 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gHJia-0006nJ-PP for emacs-devel@gnu.org; Mon, 29 Oct 2018 22:25:27 -0400 Original-Received: from mail-ed1-x52e.google.com ([2a00:1450:4864:20::52e]:44110) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gHJiY-0006mf-Dx for emacs-devel@gnu.org; Mon, 29 Oct 2018 22:25:19 -0400 Original-Received: by mail-ed1-x52e.google.com with SMTP id z21-v6so9103114edb.11 for ; Mon, 29 Oct 2018 19:25:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tcd-ie.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-transfer-encoding; bh=3Ae4niOxafb3jQ0Ti59xfnoLMv4//qADhzKT/Sz0l4k=; b=AqFH5v/F55mxGrzRwhZ3ALEOT9U062MOA2J+eIRBWb6JufZGKp09CpQgaBafLnSEer qp6WtTqln+dhp6zTtMY1e2SfAZpy4S2nRlllJ5g4Pk1brd1docw3o7442Kek1F7TjMy6 mAPoMY2opEusuJDrwCCWmVA1vV5xZIo4ZV/Fox3SQ4IWGsihWOIaRBzRv8pMsQv5HGam W+YAgJ7eu9C+xBxpvguEBIh+ILEIaaKBuBruoTSYxAwkjHIkLRHyQyAQoekCxXLZM9sL qO/YdxIoTXLhk1BF0FILo5wYquhmzMljjYhEaH4gTvvUrImEQae6CrRliW8ylQQf7pW0 e1PQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=3Ae4niOxafb3jQ0Ti59xfnoLMv4//qADhzKT/Sz0l4k=; b=q7s8/nb1FyJ++uXK9+PuZjOWnYY++miRv3FQplTotfVwe9sUqwW6wRmWF0LKBILNf4 eqsWjSzwd7fpUqGUb4xfIhdi70s34yx+F4LF4vCB+WpDgZWFDcex8pwt+0ZHS5tHbjvN fQPNjUh7jK+XauGRQ4jWTkwsvNl06KdIXEfjA8nAjeKI1i+hDTClLMtFdJVH9ZYsfqrN 7DGZ1GJetct31HHl7Pcw4GWxiWyci3ELA+4eK6XyZXOBG5y9B+Jn6hNdG3zKy+ntFAEs NA0yF2xuQBHvkm7BqoaAcOf4TwsS71f+SHii/ZoEbxCS4nicg2ST4V3BA6E9MlH4KqsR CkBQ== X-Gm-Message-State: AGRZ1gLHp1B6nF1baVanjQDyeLURLkbt+HR5a+MpvDoImWYR0nPA5ds+ Nvo/yathtlRbtHzg2un5dHqA3J8PFYA= X-Google-Smtp-Source: AJdET5cpL+5Ts3UboUBjlv2h6pSTWkeOwz8rYnM4PC7sB2kyem7x6E4sGvkmpiPfK2PHTnkEDKMVTQ== X-Received: by 2002:a50:93e5:: with SMTP id o92-v6mr4060013eda.57.1540866317165; Mon, 29 Oct 2018 19:25:17 -0700 (PDT) Original-Received: from localhost (51-171-243-2-dynamic.agg2.clk.blp-srl.eircom.net. [51.171.243.2]) by smtp.gmail.com with ESMTPSA id h1-v6sm1072273eja.45.2018.10.29.19.25.16 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 29 Oct 2018 19:25:16 -0700 (PDT) In-Reply-To: <87woq0sf4a.fsf@portable.galex-713.eu> (Garreau, Alexandre's message of "Mon, 29 Oct 2018 20:54:29 +0100") X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::52e 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:230794 Archived-At: "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. It would also need to handle the case where xdg-user-dir is not found in exec-path. > Or should, instead, a xdg.el file be created where to put variables (or > functions) referring to correct (and up-to-date) names of XDG variables: > desktop, download, templates, publicshare, documents, music, pictures, > and videos, and maybe =E2=80=9Cxdg-settings get default-url-scheme-handle= r=E2=80=9D. > Maybe among other xdg stuff, such as localization language, or=E2=80=A6 d= unno > yet, but there must be things to get. FWIW, Emacs 26 includes the file lisp/xdg.el, which provides, amongst other things, the function xdg-user-dir: (require 'xdg) (xdg-user-dir "DOWNLOAD") See also the following thread for some discussion of XDG support: https://lists.gnu.org/archive/html/emacs-devel/2018-05/msg00081.html --=20 Basil