diff options
-rw-r--r-- | init.org | 41 |
1 files changed, 41 insertions, 0 deletions
@@ -1092,6 +1092,47 @@ Integrate mu4e with Org mode. erc-mode) . typo-mode)) #+end_src +Add action to delete attachments (https://emacs.stackexchange.com/a/70992) +#+begin_src elisp +(defun my-mime-part-filename (num) + "Filename of MIME part numbered num in gnus-article-mode." + ;; Check whether the specified part exists. + (when (> num (length gnus-article-mime-handle-alist)) + (error "No such part")) + ;; Move point to MIME part + (when (gnus-article-goto-part num) + ;; Get handle for MIME part at point + (let ((handle (get-text-property (point) 'gnus-data))) + (when handle + ;; Return file name of handle + (mm-handle-filename handle))))) +(defun my-delete-attachment (num) + "Remove email attachment from mu4e using altermime." + (let* ((path (mu4e-message-field (mu4e-message-at-point) :path)) + (filename (my-mime-part-filename num)) + (cmd (format "altermime --input='%s' --remove='%s'" path filename))) + (when (and filename + (yes-or-no-p + (format "Remove '%s'?" filename))) + (shell-command cmd) + (mu4e-message cmd)))) +(defun my-delete-all-attachments (msg) + "Remove all email attachments in mu4e using altermime." + (let* ((path (mu4e-message-field msg :path)) + (subject (mu4e-message-field msg :subject)) + (cmd (format "altermime --input='%s' --removeall" path))) + (when (yes-or-no-p + (format "Remove all attachments from '%s'?" subject)) + (shell-command cmd) + (mu4e-message cmd)))) +(add-to-list 'mu4e-view-mime-part-actions + '(:name "delete-attachment" + :handler my-delete-attachment + :receives index)) +(add-to-list 'mu4e-headers-actions + '("Delete-all-attachments" . my-delete-all-attachments)) +#+end_src + * TODO More stuff This is even more stuff to be done after initialising packages. I still need to process all of this and clean it up. |