[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/org-mime d540da37df 026/118: make it emacs 24.3 compatible
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/org-mime d540da37df 026/118: make it emacs 24.3 compatible |
Date: |
Wed, 5 Jan 2022 07:58:44 -0500 (EST) |
branch: elpa/org-mime
commit d540da37df26c673b83cc9aab36f2ca6cfed3481
Author: Chen Bin <chenbin.sh@gmail.com>
Commit: Chen Bin <chenbin.sh@gmail.com>
make it emacs 24.3 compatible
---
README.org | 2 +-
org-mime.el | 39 +++++++++++++++++++++++++++------------
2 files changed, 28 insertions(+), 13 deletions(-)
diff --git a/README.org b/README.org
index 1315ce07b4..2912cd7765 100644
--- a/README.org
+++ b/README.org
@@ -3,7 +3,7 @@ org-mime can be used to send HTML email using Org-mode HTML
export.
This approximates a WYSiWYG HTML mail editor from within Emacs, and can be
useful for sending tables, fontified source code, and inline images in email.
-Tested on Emacs 23.4, 24.3, 24.4, 24.5, 25.1.
+Tested on Emacs 24.3, 24.4, 24.5, 25.1.
* Setup
#+begin_src elisp
(require 'org-mime)
diff --git a/org-mime.el b/org-mime.el
index ea5e0ed3dc..4a3a3e2d69 100644
--- a/org-mime.el
+++ b/org-mime.el
@@ -6,8 +6,8 @@
;; Maintainer: Chen Bin (redguardtoo)
;; Keywords: mime, mail, email, html
;; Homepage: http://github.com/org-mime/org-mime
-;; Version: 0.0.5
-;; Package-Requires: ((cl-lib "0.5"))
+;; Version: 0.0.6
+;; Package-Requires: ((emacs "24") (cl-lib "0.5"))
;; This file is not part of GNU Emacs.
@@ -60,6 +60,9 @@
;; Or just setup your export options in org buffer/subtree which is overrided
;; by `org-mime-export-options' when it's NOT nil.
;;
+;; You can change `org-mime-up-subtree-heading' before exporting subtree.
+;; heck its documentation.
+;;
;; Quick start:
;; Write mail in message-mode, make sure the mail body follows org format.
;; Before sending mail, `M-x org-mime-htmlize'
@@ -81,7 +84,6 @@
;;; Code:
(require 'cl-lib)
(require 'org)
-(require 'ox) ; org export lib
(defcustom org-mime-use-property-inheritance nil
"Non-nil means al MAIL_ properties apply also for sublevels."
@@ -131,16 +133,28 @@ buffer holding\nthe text to be exported.")
(defvar org-mime-debug nil
"Enable debug logger.")
-(defun org-mime--export-string (s &optional opts)
+(defvar org-mime-up-subtree-heading 'org-up-heading-safe
+ "Funtion to call before exporting subtree.
+You could use either `org-up-heading-safe' or `org-back-to-heading'.")
+
+
+(defun org-mime--chomp (str)
+ "Chomp leading and tailing whitespace from STR."
+ (while (string-match "\\`[\n\r]+\\|^\\s-+\\|\\s-+$\\|[\n\r]+\\'"
+ str)
+ (setq str (replace-match "" t t str)))
+ str)
+
+(defun org-mime--export-string (s fmt &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 (if org-mime-export-options
org-mime-export-options opts))
- ;; emacs 23
- (org-export-string s "html")))
+ ;; emacs24.4+
+ (org-export-string-as s fmt t (if org-mime-export-options
org-mime-export-options opts))
+ ;; emacs 24.3
+ (org-export-string s (symbol-name fmt))))
;; example hook, for setting a dark background in <pre
style="background-color: #EEE;"> elements
(defun org-mime-change-element-style (element style)
@@ -255,6 +269,7 @@ If ARG is not NIL, use `org-mime-fixedwith-wrap' to wrap
the exported text."
(html-and-images
(org-mime-replace-images
(org-mime--export-string body
+ 'html
(if (fboundp
'org-export--get-inbuffer-options)
(org-export--get-inbuffer-options)))
tmp-file))
@@ -306,12 +321,12 @@ If ARG is not NIL, use `org-mime-fixedwith-wrap' to wrap
the exported text."
(buffer-string))
body))))
(let* ((org-link-file-path-type 'absolute)
- (plain (org-export-string-as (org-babel-trim body) 'ascii t nil))
+ (plain (org-mime--export-string (org-mime--chomp body) 'ascii))
;; we probably don't want to export a huge style file
(org-export-htmlize-output-type 'inline-css)
(html-and-images
(org-mime-replace-images
- (org-mime--export-string (bhook body 'html) opts)
+ (org-mime--export-string (bhook body 'html) 'html opts)
file))
(images (cdr html-and-images))
(html (org-mime-apply-html-hook (car html-and-images))))
@@ -349,8 +364,8 @@ current org-mode file exported to html and encoded in both
html
and in org formats as mime alternatives."
(interactive)
(save-excursion
- (org-up-heading-safe)
- (cl-flet ((mp (p) (org-entry-get nil p org-mime-use-property-inheritance)))
+ (funcall org-mime-up-subtree-heading)
+ (flet ((mp (p) (org-entry-get nil p org-mime-use-property-inheritance)))
(let* ((file (buffer-file-name (current-buffer)))
(subject (or (mp "MAIL_SUBJECT") (nth 4
(org-heading-components))))
(to (mp "MAIL_TO"))
- [nongnu] elpa/org-mime 30bb3e663d 117/118: Merge pull request #66 from skangas/gplv3, (continued)
- [nongnu] elpa/org-mime 30bb3e663d 117/118: Merge pull request #66 from skangas/gplv3, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime 4105d1bb9c 004/118: support Emacs 23.4, 24.3 24.4, 24.5, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime e9b0be2860 005/118: mails need NO TOC, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime 3a16180195 006/118: clean code according to org-mode review, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime 351b233a7e 018/118: Don't use obsoleted function, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime 44e7a78ffd 019/118: Fix for cl-lib, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime dfe41e05e2 012/118: Merge pull request #1 from acowley/subject, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime d3ae6df753 013/118: Merge pull request #2 from acowley/subtree, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime 957bb3b43a 014/118: Merge pull request #3 from acowley/plain-part, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime b00d23aa1d 022/118: explicitly require org export libs, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime d540da37df 026/118: make it emacs 24.3 compatible,
ELPA Syncer <=
- [nongnu] elpa/org-mime c0e99cfdfa 028/118: README, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime f1175e3fab 035/118: can htmlize new mail, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime 895a7c31bb 052/118: Merge pull request #23 from liujoey/master, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime 11965c407f 055/118: rewrite beautify function, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime cf7dbea171 054/118: rename cleanup function to match beautify user option, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime 53e0c8141b 058/118: one-line fix for klipse errors in org-mime, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime baa6cde22f 057/118: Merge pull request #25 from tmurph/blockquote-parser, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime 1b516d604a 056/118: remove unnecessary dependency, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime 817744f3b1 062/118: remove plain text body, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime 4bd5d55ba9 071/118: fixed logic, ELPA Syncer, 2022/01/05