diff --git a/emacs/init.org b/emacs/init.org index 66a713e..e3dc4a1 100755 --- a/emacs/init.org +++ b/emacs/init.org @@ -4250,6 +4250,27 @@ Support sending rich-text emails via Markdown: (point) (insert description "\n"))) (mail-encode-encoded-word-region description (point)))))) + + (defun message-md-insert-inline-image (image type description) + (interactive + (let* ((file (mml-minibuffer-read-file "Insert image: ")) + (type (if current-prefix-arg + (or (mm-default-file-encoding file) + "application/octet-stream") + (mml-minibuffer-read-type file))) + (description (if current-prefix-arg + nil + (mml-minibuffer-read-description)))) + (list file type description))) + (let ((id (format "%s%s" (s-snake-case description) (random)))) + (insert (format "![%s](cid:%s)" description id)) + (save-excursion + (goto-char (point-max)) + (newline) + (insert + (format (concat "<#part id=\"<%s>\" x-attachment-id=%S " + "type=%S filename=%S disposition=inline description=%s>") + id id type image description))))) #+END_SRC