[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)
> #+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 “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:
https://lists.gnu.org/archive/html/emacs-devel/2018-05/msg00081.html
--
Basil
- Re: `call-process', to a string [Was: Re: Automatically set eww-download-directory according xdg dir], (continued)
- Re: `call-process', to a string [Was: Re: Automatically set eww-download-directory according xdg dir], Basil L. Contovounesios, 2018/10/29
- Re: `call-process', to a string, Garreau\, Alexandre, 2018/10/29
- Re: `call-process', to a string [Was: Re: Automatically set eww-download-directory according xdg dir], Eli Zaretskii, 2018/10/30
- Re: `call-process', to a string, Garreau\, Alexandre, 2018/10/30
- Re: `call-process', to a string, Eli Zaretskii, 2018/10/30
- Re: `call-process', to a string, Garreau\, Alexandre, 2018/10/30
- Re: `call-process', to a string, Eli Zaretskii, 2018/10/30
- `call-process', to a string, Garreau\, Alexandre, 2018/10/30
- Re: `call-process', to a string [Was: Re: Automatically set eww-download-directory according xdg dir], Basil L. Contovounesios, 2018/10/31
Re: `call-process', to a string [Was: Re: Automatically set eww-download-directory according xdg dir], Eli Zaretskii, 2018/10/30
Re: Automatically set eww-download-directory according xdg dir,
Basil L. Contovounesios <=
Re: Automatically set eww-download-directory according xdg dir, Eli Zaretskii, 2018/10/30