mirror of https://github.com/djcb/mu.git
mu4e: add mu4e-view-fetch-url for downloading URLs
Add mu4e-view-fetch-url for fetching (downloading) URIs linked to in e-mails. Add the 'f' keybinding for this, and document it. Based on code by inigoserna.
This commit is contained in:
parent
aad5708d49
commit
82e7ba051f
|
@ -118,8 +118,7 @@ better with e.g. offlineimap."
|
||||||
"Default directory for saving attachments.
|
"Default directory for saving attachments.
|
||||||
This can be either a string (a file system path), or a function
|
This can be either a string (a file system path), or a function
|
||||||
that takes a filename and the mime-type as arguments, and returns
|
that takes a filename and the mime-type as arguments, and returns
|
||||||
the attachment dir. See Info node `(mu4e) Opening and saving
|
the attachment dir. See Info node `(mu4e) Attachments' for details."
|
||||||
attachments' for details."
|
|
||||||
:type 'directory
|
:type 'directory
|
||||||
:group 'mu4e
|
:group 'mu4e
|
||||||
:safe 'stringp)
|
:safe 'stringp)
|
||||||
|
|
|
@ -687,6 +687,11 @@ FUNC should be a function taking two arguments:
|
||||||
'("Open attachment" . mu4e-view-open-attachment))
|
'("Open attachment" . mu4e-view-open-attachment))
|
||||||
(define-key menumap [extract-att]
|
(define-key menumap [extract-att]
|
||||||
'("Extract attachment" . mu4e-view-save-attachment))
|
'("Extract attachment" . mu4e-view-save-attachment))
|
||||||
|
|
||||||
|
(define-key menumap [save-url]
|
||||||
|
'("Save URL to kill-ring" . mu4e-view-save-url))
|
||||||
|
(define-key menumap [fetch-url]
|
||||||
|
'("Fetch URL" . mu4e-view-fetch-url))
|
||||||
(define-key menumap [goto-url]
|
(define-key menumap [goto-url]
|
||||||
'("Visit URL" . mu4e-view-go-to-url))
|
'("Visit URL" . mu4e-view-go-to-url))
|
||||||
|
|
||||||
|
@ -1381,6 +1386,18 @@ to save a range of URLs."
|
||||||
(kill-new url)
|
(kill-new url)
|
||||||
(mu4e-message "Saved %s to the kill-ring" url))))
|
(mu4e-message "Saved %s to the kill-ring" url))))
|
||||||
|
|
||||||
|
(defun mu4e-view-fetch-url (&optional multi)
|
||||||
|
"Offer to fetch (download) urls(s). If MULTI (prefix-argument) is nil,
|
||||||
|
download a single one, otherwise, offer to fetch a range of
|
||||||
|
URLs. The urls are fetched to `mu4e-attachment-dir'."
|
||||||
|
(interactive "P")
|
||||||
|
(mu4e~view-handle-urls "URL to fetch" multi
|
||||||
|
(lambda (url)
|
||||||
|
(let ((target (concat (mu4e~get-attachment-dir url) "/"
|
||||||
|
(file-name-nondirectory url))))
|
||||||
|
(url-copy-file url target)
|
||||||
|
(mu4e-message "Fetched %s -> %s" url target)))))
|
||||||
|
|
||||||
(defun mu4e~view-handle-urls (prompt multi urlfunc)
|
(defun mu4e~view-handle-urls (prompt multi urlfunc)
|
||||||
"If MULTI is nil, apply URLFUNC to a single uri, otherwise, apply
|
"If MULTI is nil, apply URLFUNC to a single uri, otherwise, apply
|
||||||
it to a range of uris. PROMPT is the query to present to the user."
|
it to a range of uris. PROMPT is the query to present to the user."
|
||||||
|
|
|
@ -1173,6 +1173,8 @@ actions
|
||||||
g go to (visit) numbered URL (using `browse-url')
|
g go to (visit) numbered URL (using `browse-url')
|
||||||
(or: <mouse-1> or M-RET with point on url)
|
(or: <mouse-1> or M-RET with point on url)
|
||||||
C-u g visits multiple URLs
|
C-u g visits multiple URLs
|
||||||
|
f fetch (download )the numbered URL.
|
||||||
|
C-u f fetches multiple URLs
|
||||||
k save the numbered URL in the kill-ring.
|
k save the numbered URL in the kill-ring.
|
||||||
C-u k saves multiple URLs
|
C-u k saves multiple URLs
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue