all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#41030: [PATCH] Make EWW respect XDG download directory by default
@ 2020-05-02 16:58 Philip K
  2020-05-03 22:52 ` Stefan Kangas
  0 siblings, 1 reply; 10+ messages in thread
From: Philip K @ 2020-05-02 16:58 UTC (permalink / raw)
  To: 41030

---
 lisp/net/eww.el | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index c83884fd25..0d0aa9f3bc 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -32,6 +32,7 @@
 (require 'thingatpt)
 (require 'mm-url)
 (require 'puny)
+(require 'xdg)
 (eval-when-compile (require 'subr-x)) ;; for string-trim
 
 (defgroup eww nil
@@ -55,7 +56,8 @@ eww-search-prefix
   :group 'eww
   :type 'string)
 
-(defcustom eww-download-directory "~/Downloads/"
+(defcustom eww-download-directory (or (xdg-user-dir "DOWNLOAD")
+                                      "~/Downloads/")
   "Directory where files will downloaded."
   :version "24.4"
   :group 'eww
-- 
2.20.1






^ permalink raw reply related	[flat|nested] 10+ messages in thread

* bug#41030: [PATCH] Make EWW respect XDG download directory by default
  2020-05-02 16:58 bug#41030: [PATCH] Make EWW respect XDG download directory by default Philip K
@ 2020-05-03 22:52 ` Stefan Kangas
  2020-05-03 23:28   ` Basil L. Contovounesios
  0 siblings, 1 reply; 10+ messages in thread
From: Stefan Kangas @ 2020-05-03 22:52 UTC (permalink / raw)
  To: Philip K; +Cc: Lars Ingebrigtsen, 41030

Philip K <philip@warpmail.net> writes:

> -(defcustom eww-download-directory "~/Downloads/"
> +(defcustom eww-download-directory (or (xdg-user-dir "DOWNLOAD")
> +                                      "~/Downloads/")

This makes sense conceptually.  However, on my machine, evaluating
(xdg-user-dir "DOWNLOAD") just returns $HOME.  That's a worse default
than "~/Downloads/", no?

But I don't know enough about the XDG standard to propose a solution.
Nor do I know if this is because my setup is particularly unusual.

Lars, what do you think?

Best regards,
Stefan Kangas





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#41030: [PATCH] Make EWW respect XDG download directory by default
  2020-05-03 22:52 ` Stefan Kangas
@ 2020-05-03 23:28   ` Basil L. Contovounesios
  2020-05-05  8:02     ` Lars Ingebrigtsen
  2020-05-05 21:32     ` Stefan Kangas
  0 siblings, 2 replies; 10+ messages in thread
From: Basil L. Contovounesios @ 2020-05-03 23:28 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: Lars Ingebrigtsen, Philip K, 41030

severity 41030 wishlist
quit

Stefan Kangas <stefan@marxist.se> writes:

> Philip K <philip@warpmail.net> writes:
>
>> -(defcustom eww-download-directory "~/Downloads/"
>> +(defcustom eww-download-directory (or (xdg-user-dir "DOWNLOAD")
>> +                                      "~/Downloads/")
>
> This makes sense conceptually.  However, on my machine, evaluating
> (xdg-user-dir "DOWNLOAD") just returns $HOME.  That's a worse default
> than "~/Downloads/", no?
>
> But I don't know enough about the XDG standard to propose a solution.
> Nor do I know if this is because my setup is particularly unusual.

It sounds like it could be specific to your environment; have a look at
'man 1 xdg-user-dirs-update'.

> Lars, what do you think?

I'm not Lars, but there's some precedent for this feature.  In the
following thread that prompted the creation of xdg.el, Lars talked about
a general facility for determining the default download directory:

https://lists.gnu.org/archive/html/emacs-devel/2017-01/msg00607.html

In the following thread(s), using the external executable xdg-user-dirs
for eww-download-directory was discussed:

https://lists.gnu.org/archive/html/emacs-devel/2018-10/msg00599.html
https://lists.gnu.org/archive/html/emacs-devel/2018-11/msg00014.html

Some executive questions:

- Does it make sense and is it safe to eagerly load xdg.el on all
  platforms and call xdg-user-dir while eww.el is being loaded?  One
  alternative being to define a symbolic constant such as 'xdg for
  eww-download-directory that is translated to a call to xdg-user-dir on
  demand rather than up front.  This idea can be expanded to cover
  non-XDG systems.

- Should we wait until there's a general utility for this?

- What do we do when xdg-user-dir returns ~/ but ~/Downloads/ also
  exists, as in Stefan's case?  Consider it a user misconfiguration?

Thanks,

-- 
Basil





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#41030: [PATCH] Make EWW respect XDG download directory by default
  2020-05-03 23:28   ` Basil L. Contovounesios
@ 2020-05-05  8:02     ` Lars Ingebrigtsen
  2020-05-05  8:20       ` Philip K.
  2020-05-05 21:32     ` Stefan Kangas
  1 sibling, 1 reply; 10+ messages in thread
From: Lars Ingebrigtsen @ 2020-05-05  8:02 UTC (permalink / raw)
  To: Basil L. Contovounesios; +Cc: Philip K, Stefan Kangas, 41030

"Basil L. Contovounesios" <contovob@tcd.ie> writes:

> - What do we do when xdg-user-dir returns ~/ but ~/Downloads/ also
>   exists, as in Stefan's case?  Consider it a user misconfiguration?

I think that is ~/Downloads/ exists, it's a good hint that the user
wants to use ~/Downloads/, no matter what xdg-user-dir says.

Probably?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#41030: [PATCH] Make EWW respect XDG download directory by default
  2020-05-05  8:02     ` Lars Ingebrigtsen
@ 2020-05-05  8:20       ` Philip K.
  2020-07-17 13:09         ` Lars Ingebrigtsen
  0 siblings, 1 reply; 10+ messages in thread
From: Philip K. @ 2020-05-05  8:20 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: contovob, stefan, 41030

Lars Ingebrigtsen <larsi@gnus.org> writes:

> "Basil L. Contovounesios" <contovob@tcd.ie> writes:
>
>> - What do we do when xdg-user-dir returns ~/ but ~/Downloads/ also
>>   exists, as in Stefan's case?  Consider it a user misconfiguration?
>
> I think that is ~/Downloads/ exists, it's a good hint that the user
> wants to use ~/Downloads/, no matter what xdg-user-dir says.

So should it check for "~/Downloads/" first (and maybe perhaps a few
other popular directory names in other languages), and unless that
hasn't been found load xdg.el and call xdg-user-dir? In the worst case,
the user doesn't have a download directory and $HOME is actually where
they want their files to land.

-- 
	Philip K.





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#41030: [PATCH] Make EWW respect XDG download directory by default
  2020-05-03 23:28   ` Basil L. Contovounesios
  2020-05-05  8:02     ` Lars Ingebrigtsen
@ 2020-05-05 21:32     ` Stefan Kangas
  2020-05-06  0:04       ` Noam Postavsky
  1 sibling, 1 reply; 10+ messages in thread
From: Stefan Kangas @ 2020-05-05 21:32 UTC (permalink / raw)
  To: Basil L. Contovounesios; +Cc: Lars Ingebrigtsen, Philip K, 41030

"Basil L. Contovounesios" <contovob@tcd.ie> writes:

>>> -(defcustom eww-download-directory "~/Downloads/"
>>> +(defcustom eww-download-directory (or (xdg-user-dir "DOWNLOAD")
>>> +                                      "~/Downloads/")
>>
>> This makes sense conceptually.  However, on my machine, evaluating
>> (xdg-user-dir "DOWNLOAD") just returns $HOME.  That's a worse default
>> than "~/Downloads/", no?
>>
>> But I don't know enough about the XDG standard to propose a solution.
>> Nor do I know if this is because my setup is particularly unusual.
>
> It sounds like it could be specific to your environment; have a look at
> 'man 1 xdg-user-dirs-update'.

In my use-case, I don't think I have ever touched any of this stuff.
Not AFAIR, anyways.

So I wonder if the suggested code would mean to never use
"~/Downloads", since xdg-user-dir will always return something else?

Best regards,
Stefan Kangas





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#41030: [PATCH] Make EWW respect XDG download directory by default
  2020-05-05 21:32     ` Stefan Kangas
@ 2020-05-06  0:04       ` Noam Postavsky
  2020-05-06  0:17         ` Stefan Kangas
  0 siblings, 1 reply; 10+ messages in thread
From: Noam Postavsky @ 2020-05-06  0:04 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: Basil L. Contovounesios, Lars Ingebrigtsen, Philip K, 41030

Stefan Kangas <stefan@marxist.se> writes:

>> It sounds like it could be specific to your environment; have a look at
>> 'man 1 xdg-user-dirs-update'.
>
> In my use-case, I don't think I have ever touched any of this stuff.
> Not AFAIR, anyways.
>
> So I wonder if the suggested code would mean to never use
> "~/Downloads", since xdg-user-dir will always return something else?

I get nil from (xdg-user-dir "DOWNLOAD").  Looking at the code, I guess
you have something in ~/.config/user-dirs.dirs which causes this.





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#41030: [PATCH] Make EWW respect XDG download directory by default
  2020-05-06  0:04       ` Noam Postavsky
@ 2020-05-06  0:17         ` Stefan Kangas
  0 siblings, 0 replies; 10+ messages in thread
From: Stefan Kangas @ 2020-05-06  0:17 UTC (permalink / raw)
  To: Noam Postavsky
  Cc: Basil L. Contovounesios, Lars Ingebrigtsen, Philip K, 41030

Noam Postavsky <npostavs@gmail.com> writes:

> I get nil from (xdg-user-dir "DOWNLOAD").  Looking at the code, I guess
> you have something in ~/.config/user-dirs.dirs which causes this.

Yup, that seems to be it.

I deleted the file, and now (xdg-user-dir "DOWNLOAD") returns nil as
it should.

Sorry about the noise.

Best regards,
Stefan Kangas





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#41030: [PATCH] Make EWW respect XDG download directory by default
  2020-05-05  8:20       ` Philip K.
@ 2020-07-17 13:09         ` Lars Ingebrigtsen
  2020-07-29  5:14           ` Lars Ingebrigtsen
  0 siblings, 1 reply; 10+ messages in thread
From: Lars Ingebrigtsen @ 2020-07-17 13:09 UTC (permalink / raw)
  To: Philip K.; +Cc: contovob, stefan, 41030

philip@warpmail.net (Philip K.) writes:

>> I think that is ~/Downloads/ exists, it's a good hint that the user
>> wants to use ~/Downloads/, no matter what xdg-user-dir says.
>
> So should it check for "~/Downloads/" first (and maybe perhaps a few
> other popular directory names in other languages), and unless that
> hasn't been found load xdg.el and call xdg-user-dir?

Yes, perhaps something like that.

But we don't want to do that checking at load time, I think?  And the
same goes for the call to xdg-user-dir -- that doesn't be done at load
time, either.

(And the patch isn't correct as is, either, because xdg-user-dir returns
the directory without a trailing slash.)

So perhaps eww-download-directory should default to a function that does
all this checking and calling?

Any opinions?

And... as far as I can see, xdg-user-dir isn't used anywhere else in
Emacs?  What's up with that?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#41030: [PATCH] Make EWW respect XDG download directory by default
  2020-07-17 13:09         ` Lars Ingebrigtsen
@ 2020-07-29  5:14           ` Lars Ingebrigtsen
  0 siblings, 0 replies; 10+ messages in thread
From: Lars Ingebrigtsen @ 2020-07-29  5:14 UTC (permalink / raw)
  To: Philip K.; +Cc: contovob, stefan, 41030

Lars Ingebrigtsen <larsi@gnus.org> writes:

> So perhaps eww-download-directory should default to a function that does
> all this checking and calling?

I've now done this in Emacs 28.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2020-07-29  5:14 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-05-02 16:58 bug#41030: [PATCH] Make EWW respect XDG download directory by default Philip K
2020-05-03 22:52 ` Stefan Kangas
2020-05-03 23:28   ` Basil L. Contovounesios
2020-05-05  8:02     ` Lars Ingebrigtsen
2020-05-05  8:20       ` Philip K.
2020-07-17 13:09         ` Lars Ingebrigtsen
2020-07-29  5:14           ` Lars Ingebrigtsen
2020-05-05 21:32     ` Stefan Kangas
2020-05-06  0:04       ` Noam Postavsky
2020-05-06  0:17         ` Stefan Kangas

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.