branch: elpa/org-mime
commit d827dbfb970b5ce9939761c2eaed52b3bd211006
Author: konezny <[email protected]>
Commit: konezny <[email protected]>
Add option to export ASCII for text/plain section
Add an option to export plain text, latin1, or utf-8 ASCII for the
text/plain section in the outgoing email message. The default is to use
the original org-mode file.
---
README.org | 19 +++++++++++++++++++
org-mime.el | 18 ++++++++++++++++--
2 files changed, 35 insertions(+), 2 deletions(-)
diff --git a/README.org b/README.org
index bd6f1a2454..88859fb951 100644
--- a/README.org
+++ b/README.org
@@ -127,6 +127,25 @@ Thibault Marin provided
[[https://lists.gnu.org/archive/html/emacs-orgmode/2019-
(search-forward "<#secure method=pgpmime mode=sign>")
(+ (point) 1))))
#+end_src
+** ASCII export options for text/plain
+Use =org-mime-export-ascii= to export the org-mode file as ASCII for the
+=text/plain= section of the email message. The default is to export the
+original unmodified org-mode file.
+
+ASCII export options:
+- plain text
+ #+begin_src elisp
+(setq org-mime-export-ascii 'ascii)
+ #+end_src
+- latin1
+ #+begin_src elisp
+(setq org-mime-export-ascii 'latin1)
+ #+end_src
+- utf-8
+ #+begin_src elisp
+(setq org-mime-export-ascii 'utf-8)
+ #+end_src
+
* Development
- Patches are always welcomed
- You can =(setq org-mime-debug t)= to enable the log
diff --git a/org-mime.el b/org-mime.el
index f2222c8e23..c6dc1de437 100644
--- a/org-mime.el
+++ b/org-mime.el
@@ -136,6 +136,12 @@ And ensure first line isn't assumed to be a title line."
:group 'org-mime
:type '(choice 'mml 'semi 'vm))
+(defcustom org-mime-export-ascii nil
+ "ASCII export options for text/plain.
+Default (nil) selects the original org-mode file."
+ :group 'org-mime
+ :type '(choice 'ascii 'latin1 'utf-8))
+
(defcustom org-mime-preserve-breaks t
"Temporary value of `org-export-preserve-breaks' during mime encoding."
:group 'org-mime
@@ -197,7 +203,15 @@ buffer holding the text to be exported.")
(defun org-mime-export-buffer-or-subtree (subtreep)
"Similar to `org-html-export-as-html' and `org-org-export-as-org'.
SUBTREEP is t if current node is subtree."
- (let* ((plain (buffer-string))
+ (let* (
+ (plain
+ (cl-case org-mime-export-ascii
+ (ascii (org-export-string-as (buffer-string) 'ascii nil
'(:ascii-charset ascii)))
+ (latin1 (org-export-string-as (buffer-string) 'ascii nil
'(:ascii-charset latin1)))
+ (utf-8 (org-export-string-as (buffer-string) 'ascii nil
'(:ascii-charset utf-8)))
+ (t (buffer-string)) ;; default is the original org file
+ )
+ )
(buf (org-export-to-buffer 'html "*Org Mime Export*"
nil subtreep nil (org-mime-get-export-options subtreep)))
(body (prog1
@@ -290,7 +304,7 @@ HTML is the body of the message."
"Markup a multipart/alternative with HTML alternatives.
If html portion of message includes IMAGES they are wrapped in
multipart/related part."
(cl-case org-mime-library
- (mml (concat "<#multipart type=alternative>\n<#part type=text/plain>"
+ (mml (concat "<#multipart type=alternative>\n<#part type=text/plain>\n"
plain
(when images "<#multipart type=related>")
"<#part type=text/html>"