diff --git a/emacs/init.org b/emacs/init.org index 34861aa..288b9cd 100755 --- a/emacs/init.org +++ b/emacs/init.org @@ -3914,16 +3914,38 @@ Then configure it: (cdar (mu4e-message-field msg :from))))))))) #+end_src +Support sending attachments from Dired: +#+BEGIN_SRC emacs-lisp + (with-eval-after-load 'dired + (require 'gnus-dired) + ;; make the `gnus-dired-mail-buffers' function also work on + ;; message-mode derived modes, such as mu4e-compose-mode + (defun gnus-dired-mail-buffers () + "Return a list of active message buffers." + (let (buffers) + (save-current-buffer + (dolist (buffer (buffer-list t)) + (set-buffer buffer) + (when (and (derived-mode-p 'message-mode) + (null message-sent-message-via)) + (push (buffer-name buffer) buffers)))) + (nreverse buffers))) + + (setq gnus-dired-mail-mode 'mu4e-user-agent) + (add-hook 'dired-mode-hook 'turn-on-gnus-dired-mode)) +#+END_SRC + + Support sending rich-text emails via Markdown: #+BEGIN_SRC emacs-lisp (defun multipart-html-message (plain html) "Creates a multipart HTML email with a text part and an html part." (concat "<#multipart type=alternative>\n" - "<#part type=text/plain>" - plain - "<#part type=text/html>\n" - html - "<#/multipart>\n")) + "<#part type=text/plain>" + plain + "<#part type=text/html>\n" + html + "<#/multipart>\n")) (defun convert-message-to-markdown () "Convert the message in the current buffer to a multipart HTML email. @@ -3933,29 +3955,29 @@ Support sending rich-text emails via Markdown: (unless (executable-find "pandoc") (error "Pandoc not found, unable to convert message")) (let* ((begin - (save-excursion - (goto-char (point-min)) - (search-forward mail-header-separator))) - (end (point-max)) - (html-buf (generate-new-buffer "*mail-md-output*")) - (exit-code - (call-process-region begin end "pandoc" nil html-buf nil - "--quiet" "-f" "gfm" "-t" "html")) - (html (format "\n\n\n%s\n\n" - (with-current-buffer html-buf - (buffer-substring (point-min) (point-max))))) - (raw-body (buffer-substring begin end))) + (save-excursion + (goto-char (point-min)) + (search-forward mail-header-separator))) + (end (point-max)) + (html-buf (generate-new-buffer "*mail-md-output*")) + (exit-code + (call-process-region begin end "pandoc" nil html-buf nil + "--quiet" "-f" "gfm" "-t" "html")) + (html (format "\n\n\n%s\n\n" + (with-current-buffer html-buf + (buffer-substring (point-min) (point-max))))) + (raw-body (buffer-substring begin end))) (when (not (= exit-code 0)) - (error "Markdown conversion failed, see %s" (buffer-name html-buf))) + (error "Markdown conversion failed, see %s" (buffer-name html-buf))) (with-current-buffer html-buf - (set-buffer-modified-p nil) - (kill-buffer)) + (set-buffer-modified-p nil) + (kill-buffer)) (undo-boundary) (delete-region begin end) (save-excursion - (goto-char begin) - (newline) - (insert (multipart-html-message raw-body html))))) + (goto-char begin) + (newline) + (insert (multipart-html-message raw-body html))))) (defun message-md-send (&optional arg) "Convert the current buffer and send it.