emacs-devel
[Top][All Lists]
Advanced

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

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


From: Eli Zaretskii
Subject: Re: Automatically set eww-download-directory according xdg dir
Date: Tue, 30 Oct 2018 09:16:38 +0200

> From: "Basil L. Contovounesios" <address@hidden>
> Date: Tue, 30 Oct 2018 02:25:15 +0000
> Cc: emacs-devel <address@hidden>
> 
> "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.

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?).



reply via email to

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