Download of URL in EWW falls back on current URL

* lisp/net/eww.el (eww-download): If there's no URL at point,
download the current URL instead.  Previous behavior was to
signal an error if there was no URL at point.  (Bug#34291)
* doc/misc/eww.texi (Basics): Update documentation.
This commit is contained in:
Nick Drozd 2019-02-02 12:35:02 -06:00 committed by Eli Zaretskii
parent dbb1a8bc1a
commit 51e6e0694a
2 changed files with 8 additions and 5 deletions

View file

@ -125,9 +125,10 @@ HTML-specified colors or not. This sets the @code{shr-use-colors} variable.
@vindex eww-download-directory
@kindex d
@cindex Download
A URL under the point can be downloaded with @kbd{d}
(@code{eww-download}). The file will be written to the directory
specified in @code{eww-download-directory} (Default: @file{~/Downloads/}).
A URL can be downloaded with @kbd{d} (@code{eww-download}). This
will download the link under point if there is one, or else the URL of
the current page. The file will be written to the directory specified
in @code{eww-download-directory} (default: @file{~/Downloads/}).
@findex eww-back-url
@findex eww-forward-url

View file

@ -1531,10 +1531,12 @@ Differences in #targets are ignored."
(kill-new (plist-get eww-data :url)))
(defun eww-download ()
"Download URL under point to `eww-download-directory'."
"Download URL to `eww-download-directory'.
Use link under point if there is one, else the current page URL."
(interactive)
(access-file eww-download-directory "Download failed")
(let ((url (get-text-property (point) 'shr-url)))
(let ((url (or (get-text-property (point) 'shr-url)
(eww-current-url))))
(if (not url)
(message "No URL under point")
(url-retrieve url 'eww-download-callback (list url)))))