* bug#62435: [PATCH] 29.0 Fix eww--download-directory on MS-Windows
@ 2023-03-25 11:56 lux
2023-03-25 13:25 ` Eli Zaretskii
0 siblings, 1 reply; 6+ messages in thread
From: lux @ 2023-03-25 11:56 UTC (permalink / raw)
To: 62435
[-- Attachment #1.1: Type: text/plain, Size: 130 bytes --]
The eww--download-directory hardcodes the download path, so it does not
work on MS-Windows, I fixed it, and tested on MS-Windows.
[-- Attachment #1.2: Type: text/html, Size: 136 bytes --]
[-- Attachment #2: 0001-Fix-eww-download-directory-on-Windows.patch --]
[-- Type: application/octet-stream, Size: 1610 bytes --]
From b4c5ed1d8fee7b69a079ee883344bf483faf7a52 Mon Sep 17 00:00:00 2001
From: Xi Lu <lx@shellcodes.org>
Date: Sat, 25 Mar 2023 14:44:35 +0800
Subject: [PATCH] Fix eww--download-directory on Windows.
* lisp/net/eww.el: Add get the download directory on MS-Windows.
---
lisp/net/eww.el | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index 859a9b44bcb..ac3af4677b5 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -66,14 +66,17 @@ eww-use-browse-url
(defun eww--download-directory ()
"Return the name of the download directory.
-If ~/Downloads/ exists, that will be used, and if not, the
-DOWNLOAD XDG user directory will be returned. If that's
+If ~/Downloads/ or %USERPROFILE% on Windows exists, that will be used,
+and if not, the DOWNLOAD XDG user directory will be returned. If that's
undefined, ~/Downloads/ is returned anyway."
- (or (and (file-exists-p "~/Downloads/")
- "~/Downloads/")
- (when-let ((dir (xdg-user-dir "DOWNLOAD")))
- (file-name-as-directory dir))
- "~/Downloads/"))
+ (let ((download-dir (if (eq system-type 'windows-nt)
+ (concat (getenv "USERPROFILE") "\\Downloads\\")
+ (concat (getenv "HOME") "/Downloads/"))))
+ (or (and (file-exists-p download-dir)
+ download-dir)
+ (when-let ((dir (xdg-user-dir "DOWNLOAD")))
+ (file-name-as-directory dir))
+ download-dir)))
(defcustom eww-download-directory 'eww--download-directory
"Directory where files will downloaded.
--
2.39.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* bug#62435: [PATCH] 29.0 Fix eww--download-directory on MS-Windows
2023-03-25 11:56 bug#62435: [PATCH] 29.0 Fix eww--download-directory on MS-Windows lux
@ 2023-03-25 13:25 ` Eli Zaretskii
2023-03-25 13:42 ` lux
0 siblings, 1 reply; 6+ messages in thread
From: Eli Zaretskii @ 2023-03-25 13:25 UTC (permalink / raw)
To: lux; +Cc: 62435
> From: "lux" <lx@shellcodes.org>
> Date: Sat, 25 Mar 2023 19:56:43 +0800
>
> The eww--download-directory hardcodes the download path, so it does not
> work on MS-Windows, I fixed it, and tested on MS-Windows.
Thanks, but this isn't the right fix. The code does want to honor the
user's "Downloads" subdirectory, even on Windows. In addition,
USERPROFILE only works on latest Windows versions.
I think the right fix here is to make this directory a defcustom, and
leave its default value at "~/Downloads" on all systems.
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#62435: [PATCH] 29.0 Fix eww--download-directory on MS-Windows
2023-03-25 13:25 ` Eli Zaretskii
@ 2023-03-25 13:42 ` lux
2023-03-25 14:05 ` Eli Zaretskii
0 siblings, 1 reply; 6+ messages in thread
From: lux @ 2023-03-25 13:42 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 62435
[-- Attachment #1: Type: text/plain, Size: 230 bytes --]
On Sat, 2023-03-25 at 16:25 +0300, Eli Zaretskii wrote:
>
>
> I think the right fix here is to make this directory a defcustom, and
> leave its default value at "~/Downloads" on all systems.
>
Thank you, I changed it.
[-- Attachment #2: 0001-Add-eww-default-download-directory.patch --]
[-- Type: text/x-patch, Size: 1427 bytes --]
From 6496142bf6b1e558ac4fbafa7b977fbfb24d2237 Mon Sep 17 00:00:00 2001
From: Xi Lu <lx@shellcodes.org>
Date: Sat, 25 Mar 2023 21:38:48 +0800
Subject: [PATCH] Add `eww-default-download-directory'.
* lisp/net/eww.el: Add variable `eww-default-download-directory'.
---
lisp/net/eww.el | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index 859a9b44bcb..8a511ecf39e 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -64,16 +64,22 @@ eww-use-browse-url
:version "28.1"
:type 'regexp)
+(defcustom eww-default-download-directory "~/Downloads/"
+ "The default directory where downloaded files will be saved."
+ :version "29.0"
+ :group 'eww
+ :type 'string)
+
(defun eww--download-directory ()
"Return the name of the download directory.
If ~/Downloads/ exists, that will be used, and if not, the
DOWNLOAD XDG user directory will be returned. If that's
undefined, ~/Downloads/ is returned anyway."
- (or (and (file-exists-p "~/Downloads/")
- "~/Downloads/")
+ (or (and (file-exists-p eww-default-download-directory)
+ eww-default-download-directory)
(when-let ((dir (xdg-user-dir "DOWNLOAD")))
(file-name-as-directory dir))
- "~/Downloads/"))
+ eww-default-download-directory))
(defcustom eww-download-directory 'eww--download-directory
"Directory where files will downloaded.
--
2.39.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* bug#62435: [PATCH] 29.0 Fix eww--download-directory on MS-Windows
2023-03-25 13:42 ` lux
@ 2023-03-25 14:05 ` Eli Zaretskii
2023-03-25 14:17 ` lux
0 siblings, 1 reply; 6+ messages in thread
From: Eli Zaretskii @ 2023-03-25 14:05 UTC (permalink / raw)
To: lux; +Cc: 62435
> From: lux <lx@shellcodes.org>
> Cc: 62435@debbugs.gnu.org
> Date: Sat, 25 Mar 2023 21:42:44 +0800
>
>
> +(defcustom eww-default-download-directory "~/Downloads/"
> + "The default directory where downloaded files will be saved."
> + :version "29.0"
^^^^^^
This should be "30.1".
> (defun eww--download-directory ()
> "Return the name of the download directory.
> If ~/Downloads/ exists, that will be used, and if not, the
> DOWNLOAD XDG user directory will be returned. If that's
> undefined, ~/Downloads/ is returned anyway."
> - (or (and (file-exists-p "~/Downloads/")
> - "~/Downloads/")
> + (or (and (file-exists-p eww-default-download-directory)
> + eww-default-download-directory)
> (when-let ((dir (xdg-user-dir "DOWNLOAD")))
> (file-name-as-directory dir))
> - "~/Downloads/"))
> + eww-default-download-directory))
Please update the doc string as well.
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#62435: [PATCH] 29.0 Fix eww--download-directory on MS-Windows
2023-03-25 14:05 ` Eli Zaretskii
@ 2023-03-25 14:17 ` lux
2023-03-26 11:59 ` Eli Zaretskii
0 siblings, 1 reply; 6+ messages in thread
From: lux @ 2023-03-25 14:17 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 62435
[-- Attachment #1: Type: text/plain, Size: 1182 bytes --]
On Sat, 2023-03-25 at 17:05 +0300, Eli Zaretskii wrote:
> > From: lux <lx@shellcodes.org>
> > Cc: 62435@debbugs.gnu.org
> > Date: Sat, 25 Mar 2023 21:42:44 +0800
> >
> >
> > +(defcustom eww-default-download-directory "~/Downloads/"
> > + "The default directory where downloaded files will be saved."
> > + :version "29.0"
> ^^^^^^
> This should be "30.1".
>
> > (defun eww--download-directory ()
> > "Return the name of the download directory.
> > If ~/Downloads/ exists, that will be used, and if not, the
> > DOWNLOAD XDG user directory will be returned. If that's
> > undefined, ~/Downloads/ is returned anyway."
> > - (or (and (file-exists-p "~/Downloads/")
> > - "~/Downloads/")
> > + (or (and (file-exists-p eww-default-download-directory)
> > + eww-default-download-directory)
> > (when-let ((dir (xdg-user-dir "DOWNLOAD")))
> > (file-name-as-directory dir))
> > - "~/Downloads/"))
> > + eww-default-download-directory))
>
> Please update the doc string as well.
>
>
Done, please review, thank you.
[-- Attachment #2: 0001-Add-eww-default-download-directory.patch --]
[-- Type: text/x-patch, Size: 1654 bytes --]
From 3eb370725605b4e66542195b5464c23a891f93c6 Mon Sep 17 00:00:00 2001
From: Xi Lu <lx@shellcodes.org>
Date: Sat, 25 Mar 2023 21:38:48 +0800
Subject: [PATCH] Add `eww-default-download-directory'.
* lisp/net/eww.el: Add variable `eww-default-download-directory'.
---
lisp/net/eww.el | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index 859a9b44bcb..9552138bb6e 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -64,16 +64,21 @@ eww-use-browse-url
:version "28.1"
:type 'regexp)
+(defcustom eww-default-download-directory "~/Downloads/"
+ "The default directory where downloaded files will be saved."
+ :version "30.1"
+ :group 'eww
+ :type 'string)
+
(defun eww--download-directory ()
- "Return the name of the download directory.
-If ~/Downloads/ exists, that will be used, and if not, the
-DOWNLOAD XDG user directory will be returned. If that's
-undefined, ~/Downloads/ is returned anyway."
- (or (and (file-exists-p "~/Downloads/")
- "~/Downloads/")
+ "Return the name of the download directory based on the value of
+`eww-default-download-directory'. If the specified directory exists, it
+ will be used. Otherwise, the DOWNLOAD XDG user directory will be returned."
+ (or (and (file-exists-p eww-default-download-directory)
+ eww-default-download-directory)
(when-let ((dir (xdg-user-dir "DOWNLOAD")))
(file-name-as-directory dir))
- "~/Downloads/"))
+ eww-default-download-directory))
(defcustom eww-download-directory 'eww--download-directory
"Directory where files will downloaded.
--
2.39.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* bug#62435: [PATCH] 29.0 Fix eww--download-directory on MS-Windows
2023-03-25 14:17 ` lux
@ 2023-03-26 11:59 ` Eli Zaretskii
0 siblings, 0 replies; 6+ messages in thread
From: Eli Zaretskii @ 2023-03-26 11:59 UTC (permalink / raw)
To: lux; +Cc: 62435-done
> From: lux <lx@shellcodes.org>
> Cc: 62435@debbugs.gnu.org
> Date: Sat, 25 Mar 2023 22:17:01 +0800
>
> > Please update the doc string as well.
> >
> >
> Done, please review, thank you.
Thanks, installed on the emacs-29 branch, and closing the bug.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-03-26 11:59 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-25 11:56 bug#62435: [PATCH] 29.0 Fix eww--download-directory on MS-Windows lux
2023-03-25 13:25 ` Eli Zaretskii
2023-03-25 13:42 ` lux
2023-03-25 14:05 ` Eli Zaretskii
2023-03-25 14:17 ` lux
2023-03-26 11:59 ` Eli Zaretskii
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.