Add some improvements in attachment actions.
* mu4e/mu4e-view.el (mu4e-view-attachment-action): Handle multi save in mu4e-view-attachment-action. * mu4e/mu4e-view.el (mu4e-view-attachment-actions): Make mu4e-view-attachment-actions a defcustom and add some options. New user variable mu4e-view-attachment-assoc. * mu4e/mu4e-view.el (mu4e-view-attachment-assoc): New. (mu4e-view-open-attachment-with): Use it.
This commit is contained in:
@ -111,8 +111,17 @@ where:
|
|||||||
|
|
||||||
The first letter of NAME is used as a shortcut character.")
|
The first letter of NAME is used as a shortcut character.")
|
||||||
|
|
||||||
(defvar mu4e-view-attachment-actions
|
(defcustom mu4e-view-attachment-assoc nil
|
||||||
'( ("wopen-with" . mu4e-view-open-attachment-with)
|
"Alist of (EXTENSION . PROGRAM).
|
||||||
|
Specify which PROGRAM to use to open attachment with EXTENSION.
|
||||||
|
Args EXTENSION and PROGRAM should be specified as strings."
|
||||||
|
:group 'mu4e-view
|
||||||
|
:type '(alist :key-type string :value-type string))
|
||||||
|
|
||||||
|
(defcustom mu4e-view-attachment-actions
|
||||||
|
'( ("ssave" . mu4e-view-save-attachment-single)
|
||||||
|
("Ssave multi" . mu4e-view-save-attachment-multi)
|
||||||
|
("wopen-with" . mu4e-view-open-attachment-with)
|
||||||
("ein-emacs" . mu4e-view-open-attachment-emacs)
|
("ein-emacs" . mu4e-view-open-attachment-emacs)
|
||||||
("dimport-in-diary" . mu4e-view-import-attachment-diary)
|
("dimport-in-diary" . mu4e-view-import-attachment-diary)
|
||||||
("|pipe" . mu4e-view-pipe-attachment))
|
("|pipe" . mu4e-view-pipe-attachment))
|
||||||
@ -123,7 +132,9 @@ where:
|
|||||||
* NAME is the name of the action (e.g. \"Count lines\")
|
* NAME is the name of the action (e.g. \"Count lines\")
|
||||||
* FUNC is a function which receives two arguments: the message
|
* FUNC is a function which receives two arguments: the message
|
||||||
plist and the attachment number.
|
plist and the attachment number.
|
||||||
The first letter of NAME is used as a shortcut character.")
|
The first letter of NAME is used as a shortcut character."
|
||||||
|
:group 'mu4e-view
|
||||||
|
:type '(alist :key-type string :value-type function))
|
||||||
|
|
||||||
(defvar mu4e-view-fill-headers t
|
(defvar mu4e-view-fill-headers t
|
||||||
"If non-nil, automatically fill the headers when viewing them.")
|
"If non-nil, automatically fill the headers when viewing them.")
|
||||||
@ -1243,11 +1254,13 @@ ATTNUM is nil ask for the attachment number."
|
|||||||
"Open MSG's attachment ATTACHNUM with CMD.
|
"Open MSG's attachment ATTACHNUM with CMD.
|
||||||
If CMD is nil, ask user for it."
|
If CMD is nil, ask user for it."
|
||||||
(let* ((att (mu4e~view-get-attach msg attachnum))
|
(let* ((att (mu4e~view-get-attach msg attachnum))
|
||||||
(cmd (or cmd
|
(ext (file-name-extension (plist-get att :name)))
|
||||||
(read-string
|
(cmd (or cmd
|
||||||
|
(read-string
|
||||||
(mu4e-format "Shell command to open it with: ")
|
(mu4e-format "Shell command to open it with: ")
|
||||||
nil 'mu4e~view-open-with-hist)))
|
(assoc-default ext mu4e-view-attachment-assoc)
|
||||||
(index (plist-get att :index)))
|
'mu4e~view-open-with-hist)))
|
||||||
|
(index (plist-get att :index)))
|
||||||
(mu4e~view-temp-action
|
(mu4e~view-temp-action
|
||||||
(mu4e-message-field msg :docid) index "open-with" cmd)))
|
(mu4e-message-field msg :docid) index "open-with" cmd)))
|
||||||
|
|
||||||
@ -1287,12 +1300,16 @@ If MSG is nil use the message returned by `message-at-point'.
|
|||||||
The actions are specified in `mu4e-view-attachment-actions'."
|
The actions are specified in `mu4e-view-attachment-actions'."
|
||||||
(interactive)
|
(interactive)
|
||||||
(let* ((msg (or msg (mu4e-message-at-point)))
|
(let* ((msg (or msg (mu4e-message-at-point)))
|
||||||
(actionfunc (mu4e-read-option
|
(actionfunc (mu4e-read-option
|
||||||
"Action on attachment: "
|
"Action on attachment: "
|
||||||
mu4e-view-attachment-actions))
|
mu4e-view-attachment-actions))
|
||||||
(attnum (mu4e~view-get-attach-num "Which attachment" msg)))
|
(multi (eq actionfunc 'mu4e-view-save-attachment-multi))
|
||||||
(when (and actionfunc attnum)
|
(attnum (unless multi
|
||||||
(funcall actionfunc msg attnum))))
|
(mu4e~view-get-attach-num "Which attachment" msg multi))))
|
||||||
|
(cond ((and actionfunc attnum)
|
||||||
|
(funcall actionfunc msg attnum))
|
||||||
|
((and actionfunc multi)
|
||||||
|
(funcall actionfunc msg)))))
|
||||||
|
|
||||||
;; handler-function to handle the response we get from the server when we
|
;; handler-function to handle the response we get from the server when we
|
||||||
;; want to do something with one of the attachments.
|
;; want to do something with one of the attachments.
|
||||||
|
|||||||
Reference in New Issue
Block a user