Merge pull request #574 from jeansch/master

mu4e: Added action to import attachment in diary. Better handle encoding while sending html to html2text.
This commit is contained in:
Dirk-Jan C. Binnema
2015-02-04 21:22:51 +02:00
2 changed files with 13 additions and 2 deletions

View File

@ -178,8 +178,10 @@ be changed by setting `mu4e-view-prefer-html'."
(insert html)
(cond
((stringp mu4e-html2text-command)
(shell-command-on-region (point-min) (point-max)
mu4e-html2text-command nil t))
(let* ((tmp-file (make-temp-file "mu4e-html")))
(write-region (point-min) (point-max) tmp-file)
(mu4e-process-file-through-pipe tmp-file mu4e-html2text-command)
(delete-file tmp-file)))
((functionp mu4e-html2text-command)
(funcall mu4e-html2text-command))
(t (mu4e-error "Invalid `mu4e-html2text-command'")))

View File

@ -105,6 +105,7 @@ The first letter of NAME is used as a shortcut character.")
(defvar mu4e-view-attachment-actions
'( ("wopen-with" . mu4e-view-open-attachment-with)
("ein-emacs" . mu4e-view-open-attachment-emacs)
("dimport-in-diary" . mu4e-view-import-attachment-diary)
("|pipe" . mu4e-view-pipe-attachment))
"List of actions to perform on message attachments.
The actions are cons-cells of the form:
@ -1136,6 +1137,12 @@ If PIPECMD is nil, ask user for it."
(index (plist-get att :index)))
(mu4e~view-temp-action (mu4e-message-field msg :docid) index "emacs")))
(defun mu4e-view-import-attachment-diary (msg attachnum)
"Open MSG's attachment ATTACHNUM in the current emacs instance."
(interactive)
(let* ((att (mu4e~view-get-attach msg attachnum))
(index (plist-get att :index)))
(mu4e~view-temp-action (mu4e-message-field msg :docid) index "diary")))
(defun mu4e-view-attachment-action (&optional msg)
"Ask user what to do with attachments in MSG
@ -1174,6 +1181,8 @@ attachments) in response to a (mu4e~proc-extract 'temp ... )."
;; make the buffer read-only since it usually does not make
;; sense to edit the temp buffer; use C-x C-q if you insist...
(setq buffer-read-only t))
((string= what "diary")
(icalendar-import-file path diary-file))
(t (mu4e-error "Unsupported action %S" what))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;