Created
October 21, 2023 19:21
-
-
Save genegoykhman/482a6d0b05ee5abe7327dc7d4042133d to your computer and use it in GitHub Desktop.
mu4e: custom compose-resend that includes in-line attachments
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun my/mu4e-compose-resend () | |
(interactive) | |
(advice-add 'mu4e~compose-handler :after #'my/mu4e-compose-resend-processing) | |
(mu4e-compose 'resend)) | |
(defun my/mu4e-compose-resend-processing (&rest args) | |
;; Make sure we are in a compose buffer | |
(unless (derived-mode-p 'mu4e-compose-mode) | |
(error "Must be in a mu4e-compose buffer.")) | |
;; remove all headers preceding the "From:" line | |
(goto-char (point-min)) | |
(re-search-forward "^From:") | |
(delete-region (point-min) (line-beginning-position)) | |
;; Is this a multipart message? | |
(let ((case-fold-search t)) | |
(when (re-search-forward "^content-type: multipart" nil :noerror) | |
(mime-to-mml) | |
;; remove the first line of the message (mime multipart separator) | |
(let ((end-pos (point)) | |
(start-pos (message-goto-body))) | |
(delete-region start-pos end-pos)))) | |
;; Remove unneeded headers | |
(message-remove-header "Date") | |
(message-remove-header "Message-ID") | |
(message-remove-header "X-TUID") | |
(message-goto-body) | |
(advice-remove 'mu4e~compose-handler #'my/mu4e-compose-resend-processing)) | |
(define-key mu4e-headers-mode-map (kbd "S") #'my/mu4e-compose-resend) | |
(define-key mu4e-view-mode-map (kbd "S") #'my/mu4e-compose-resend) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment