all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: "Basil L. Contovounesios" <contovob@tcd.ie>,
	Lars Ingebrigtsen <larsi@gnus.org>
Cc: galex-713@galex-713.eu, emacs-devel@gnu.org
Subject: Re: Automatically set eww-download-directory according xdg dir
Date: Tue, 30 Oct 2018 09:16:38 +0200	[thread overview]
Message-ID: <83ftwnlx9l.fsf@gnu.org> (raw)
In-Reply-To: <87h8h4tblg.fsf@tcd.ie> (contovob@tcd.ie)

> From: "Basil L. Contovounesios" <contovob@tcd.ie>
> Date: Tue, 30 Oct 2018 02:25:15 +0000
> Cc: emacs-devel <emacs-devel@gnu.org>
> 
> "Garreau, Alexandre" <galex-713@galex-713.eu> 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?).



      parent reply	other threads:[~2018-10-30  7:16 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-29 19:54 Automatically set eww-download-directory according xdg dir Garreau, Alexandre
2018-10-29 20:08 ` `call-process', to a string [Was: Re: Automatically set eww-download-directory according xdg dir] Garreau, Alexandre
2018-10-29 20:37   ` `with-temp-buffer', `with-output-to-string': `with-temp-buffer-to-string' / `with-current-buffer-to-string' [Was: Re: `call-process', to a string] Garreau, Alexandre
2018-10-30  2:26     ` Basil L. Contovounesios
2018-10-30  2:25   ` `call-process', to a string [Was: Re: Automatically set eww-download-directory according xdg dir] Basil L. Contovounesios
2018-10-30  3:59     ` `call-process', to a string Garreau, Alexandre
2018-10-30  7:19     ` `call-process', to a string [Was: Re: Automatically set eww-download-directory according xdg dir] Eli Zaretskii
2018-10-30 10:21       ` `call-process', to a string Garreau, Alexandre
2018-10-30 11:10         ` Eli Zaretskii
2018-10-30 11:32           ` Garreau, Alexandre
2018-10-30 12:32             ` Eli Zaretskii
2018-10-30 13:46               ` Garreau, Alexandre
2018-10-31 12:44       ` `call-process', to a string [Was: Re: Automatically set eww-download-directory according xdg dir] Basil L. Contovounesios
2018-10-30  6:57   ` Eli Zaretskii
2018-10-30  2:25 ` Automatically set eww-download-directory according xdg dir Basil L. Contovounesios
2018-10-30  3:57   ` xdg.el and eww custom load [Was: Re: Automatically set eww-download-directory according xdg dir] Garreau, Alexandre
2018-10-31 12:41     ` Basil L. Contovounesios
2018-10-31 22:52       ` Garreau, Alexandre
2018-11-01 14:29         ` Basil L. Contovounesios
2018-11-01 14:56           ` xdg.el and eww custom load Garreau, Alexandre
2018-11-01 18:54             ` Basil L. Contovounesios
2018-10-30  7:16   ` Eli Zaretskii [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83ftwnlx9l.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=contovob@tcd.ie \
    --cc=emacs-devel@gnu.org \
    --cc=galex-713@galex-713.eu \
    --cc=larsi@gnus.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.