emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/org-mime a0b82a6c1a 024/118: better export format (not TOC


From: ELPA Syncer
Subject: [nongnu] elpa/org-mime a0b82a6c1a 024/118: better export format (not TOC, etc) and bug fix
Date: Wed, 5 Jan 2022 07:58:44 -0500 (EST)

branch: elpa/org-mime
commit a0b82a6c1a0dbcf5b7bebfe2e5817d54a1cd3cc8
Author: Chen Bin <chenbin.sh@gmail.com>
Commit: Chen Bin <chenbin.sh@gmail.com>

    better export format (not TOC, etc) and bug fix
---
 README.org  | 28 +++++++++++++++++++---------
 org-mime.el | 41 +++++++++++++++++++++++++++++++++--------
 2 files changed, 52 insertions(+), 17 deletions(-)

diff --git a/README.org b/README.org
index 17e2ef1996..cca1fc77d9 100644
--- a/README.org
+++ b/README.org
@@ -41,16 +41,16 @@ The following key bindings are suggested, which bind the 
C-c M-o key sequence to
 =org-mime-org-subtree-htmlize= is similar to =org-mime-org-buffer-htmlize=
 but works on subtree. It can also read subtree properties MAIL_SUBJECT,
 MAIL_TO, MAIL_CC, and MAIL_BCC. Here is the sample of subtree:
-#+begin_src org
+#+begin_example
 * mail one
-  :PROPERTIES:
-  :MAIL_SUBJECT: mail title
-  :MAIL_TO: person1@gmail.com
-  :MAIL_CC: person2@gmail.com
-  :MAIL_BCC: person3@gmail.com
-  :END:
+ :PROPERTIES:
+ :MAIL_SUBJECT: mail title
+ :MAIL_TO: person1@gmail.com
+ :MAIL_CC: person2@gmail.com
+ :MAIL_BCC: person3@gmail.com
+ :END:
 content ...
-#+end_src
+#+end_example
 ** CSS style customization
 Email clients will often strip all global CSS from email messages. In the case 
of web-based email readers this is essential in order to protect the CSS of the 
containing web site. To ensure that your CSS styles are rendered correctly they 
must be included in the actual body of the elements to which they apply.
 
@@ -73,11 +73,21 @@ For those who use color themes with Dark backgrounds it is 
useful to set a dark
 #+end_src
 
 For other customization options see the org-mime customization group.
+** Export options
+To avoid exporting TOC, you can setup `org-mime-export-options',
+#+begin_src elisp
+(setq org-mime-export-options '(:section-numbers nil
+                                :with-author nil
+                                :with-toc nil))
+#+end_src
+Or just setup your export options in org buffer/subtree which is overrided by 
`org-mime-export-options' when it's NOT nil.
 * Development
 - Patches are always welcomed
 - You can =(setq org-mime-debug t)= to enable the log
 - Make sure your code has minimum dependency and works on Emacs versions we 
support
 * Credits
-org-mime was developed by Eric Schulte with much-appreciated help and 
discussion from everyone on the 
[[https://lists.gnu.org/archive/html/emacs-orgmode/2010-03/msg00500.html][using 
orgmode to send html mail]] thread especially Eric S. Fraga for adding WL 
support.
+- org-mime was developed by Eric Schulte with much-appreciated help and 
discussion from everyone on the 
[[https://lists.gnu.org/archive/html/emacs-orgmode/2010-03/msg00500.html][using 
orgmode to send html mail]] thread especially Eric S. Fraga for adding WL 
support.
+- [[https://github.com/acowley][Anthony Cowley]] fixed many bugs for exporting 
and support more export options
+- [[https://github.com/titaniumbones][Matt Price]] improved handling of mail 
headers (CC, BCC ...)
 * Licence
 Documentation from the http://orgmode.org/worg/ website (either in its HTML 
format or in its Org format) is licensed under the 
[[http://www.gnu.org/copyleft/fdl.html][GNU Free Documentation License version 
1.3]] or later. The code examples and css style sheets are licensed under the 
[[http://www.gnu.org/licenses/gpl.html][GNU General Public License v3 or 
later]].
diff --git a/org-mime.el b/org-mime.el
index 65655629f0..ea5e0ed3dc 100644
--- a/org-mime.el
+++ b/org-mime.el
@@ -6,7 +6,7 @@
 ;; Maintainer: Chen Bin (redguardtoo)
 ;; Keywords: mime, mail, email, html
 ;; Homepage: http://github.com/org-mime/org-mime
-;; Version: 0.0.4
+;; Version: 0.0.5
 ;; Package-Requires: ((cl-lib "0.5"))
 
 ;; This file is not part of GNU Emacs.
@@ -53,6 +53,13 @@
 ;;   :MAIL_BCC: person3@gmail.com
 ;;   :END:
 ;;
+;; To avoid exporting TOC, you can setup `org-mime-export-options',
+;;   (setq org-mime-export-options '(:section-numbers nil
+;;                                   :with-author nil
+;;                                   :with-toc nil))
+;; Or just setup your export options in org buffer/subtree which is overrided
+;; by `org-mime-export-options' when it's NOT nil.
+;;
 ;; Quick start:
 ;; Write mail in message-mode, make sure the mail body follows org format.
 ;; Before sending mail, `M-x org-mime-htmlize'
@@ -104,6 +111,11 @@ And ensure first line isn't assumed to be a title line."
   :group 'org-mime
   :type 'string)
 
+(defvar org-mime-export-options nil
+  "Default export options which may overrides org buffer/subtree options.
+You avoid exporting section-number/author/toc with below setup,
+`(setq org-mime-export-options '(:section-numbers nil :with-author nil 
:with-toc nil))'")
+
 (defvar org-mime-html-hook nil
   "Hook to run over the html buffer before attachment to email.
 This could be used for example to post-process html elements.")
@@ -121,9 +133,12 @@ buffer holding\nthe text to be exported.")
 
 (defun org-mime--export-string (s &optional opts)
   "Export string S into HTML format.  OPTS is export options."
+  (if org-mime-debug (message "org-mime--export-string called => %s" opts))
+  ;; we won't export title from org file anyway
+  (if opts (setq opts (plist-put opts 'title nil)))
   (if (fboundp 'org-export-string-as)
       ;; emacs24
-      (org-export-string-as s 'html t opts)
+      (org-export-string-as s 'html t (if org-mime-export-options 
org-mime-export-options opts))
     ;; emacs 23
     (org-export-string s "html")))
 
@@ -149,7 +164,7 @@ buffer holding\nthe text to be exported.")
 ;;              "verse" "border-left: 2px solid gray; padding-left: 4px;")))
 
 (defun org-mime-file (ext path id)
-  "Markup a file wth EXT, PATH and ID for attachment."
+  "Markup a file with EXT, PATH and ID for attachment."
   (if org-mime-debug (message "org-mime-file called => %s %s %s" ext path id))
   (cl-case org-mime-library
     (mml (format (concat "<#part type=\"%s\" filename=\"%s\" "
@@ -239,7 +254,10 @@ If ARG is not NIL, use `org-mime-fixedwith-wrap' to wrap 
the exported text."
          ;; to hold attachments for inline html images
          (html-and-images
           (org-mime-replace-images
-           (org-mime--export-string body) tmp-file))
+           (org-mime--export-string body
+                                    (if (fboundp 
'org-export--get-inbuffer-options)
+                                        (org-export--get-inbuffer-options)))
+           tmp-file))
          (html-images (unless arg (cdr html-and-images)))
          (html (org-mime-apply-html-hook
                 (if arg
@@ -272,7 +290,7 @@ If ARG is not NIL, use `org-mime-fixedwith-wrap' to wrap 
the exported text."
 
 (defun org-mime-compose (body file &optional to subject headers opts)
   "Create mail BODY in FILE with SUBJECT, HEADERS and OPTS."
-  (if org-mime-debug (message "org-mime-compose called => %s" file))
+  (if org-mime-debug (message "org-mime-compose called => %s %s" file opts))
   (let* ((fmt 'html))
     (unless (featurep 'message)
       (require 'message))
@@ -293,7 +311,8 @@ If ARG is not NIL, use `org-mime-fixedwith-wrap' to wrap 
the exported text."
              (org-export-htmlize-output-type 'inline-css)
              (html-and-images
               (org-mime-replace-images
-               (org-mime--export-string (bhook body 'html) opts) file))
+               (org-mime--export-string (bhook body 'html) opts)
+               file))
              (images (cdr html-and-images))
              (html (org-mime-apply-html-hook (car html-and-images))))
         (insert (org-mime-multipart plain html)
@@ -315,7 +334,13 @@ If ARG is not NIL, use `org-mime-fixedwith-wrap' to wrap 
the exported text."
          (body-end (or (and region-p (region-end)) (point-max)))
          (temp-body-file (make-temp-file "org-mime-export"))
          (body (buffer-substring body-start body-end)))
-    (org-mime-compose body file nil subject)))
+    (org-mime-compose body
+                      file
+                      nil ; TO
+                      subject
+                      nil ; HEADERS (CC, BCC ...)
+                      (if (fboundp 'org-export--get-inbuffer-options)
+                          (org-export--get-inbuffer-options)))))
 
 ;;;###autoload
 (defun org-mime-org-subtree-htmlize ()
@@ -337,7 +362,7 @@ and in org formats as mime alternatives."
                              (cc `((cc . ,cc)))
                              (bcc `((bcc . ,bcc)))
                              (t nil)))
-             (opts (org-export--get-subtree-options))
+             (opts (if (fboundp 'org-export--get-subtree-options) 
(org-export--get-subtree-options)))
              (body (org-get-entry)))
         (org-mime-compose body file to subject other-headers opts)))))
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]