Add 'eww-default-download-directory'.

* lisp/net/eww.el (eww-default-download-directory): New defcustom.
(eww--download-directory): Use it.  (Bug#62435)
This commit is contained in:
Xi Lu 2023-03-25 21:38:48 +08:00 committed by Eli Zaretskii
parent 564c26bdbe
commit e19b7da7b0

View file

@ -64,16 +64,21 @@ The action to be taken can be further customized via
:version "28.1" :version "28.1"
:type 'regexp) :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 () (defun eww--download-directory ()
"Return the name of the download directory. "Return the name of the download directory based on the value of
If ~/Downloads/ exists, that will be used, and if not, the `eww-default-download-directory'. If the specified directory exists, it
DOWNLOAD XDG user directory will be returned. If that's will be used. Otherwise, the DOWNLOAD XDG user directory will be returned."
undefined, ~/Downloads/ is returned anyway." (or (and (file-exists-p eww-default-download-directory)
(or (and (file-exists-p "~/Downloads/") eww-default-download-directory)
"~/Downloads/")
(when-let ((dir (xdg-user-dir "DOWNLOAD"))) (when-let ((dir (xdg-user-dir "DOWNLOAD")))
(file-name-as-directory dir)) (file-name-as-directory dir))
"~/Downloads/")) eww-default-download-directory))
(defcustom eww-download-directory 'eww--download-directory (defcustom eww-download-directory 'eww--download-directory
"Directory where files will downloaded. "Directory where files will downloaded.