[Top][All Lists]

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

Re: Automatically set eww-download-directory according xdg dir

From: Basil L. Contovounesios
Subject: Re: Automatically set eww-download-directory according xdg dir
Date: Tue, 30 Oct 2018 02:25:15 +0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

"Garreau, Alexandre" <address@hidden> 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)
> 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

> 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 “xdg-settings get default-url-scheme-handler”.
> Maybe among other xdg stuff, such as localization language, or… dunno
> 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:


reply via email to

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