summaryrefslogtreecommitdiff
path: root/contrib/lisp/org-mime.el
diff options
context:
space:
mode:
authorS├ębastien Delafond <sdelafond@gmail.com>2014-07-13 13:35:27 +0200
committerS├ębastien Delafond <sdelafond@gmail.com>2014-07-13 13:35:27 +0200
commite32a45ed36d6000db4b39171149072d11b77af72 (patch)
treeb5f4a7d43022c08c3298e82b3e9fc50f68be660f /contrib/lisp/org-mime.el
parent7697fa4daf3ec84f85711a84035d8f0224afd4e3 (diff)
Imported Upstream version 8.0.7
Diffstat (limited to 'contrib/lisp/org-mime.el')
-rw-r--r--contrib/lisp/org-mime.el42
1 files changed, 24 insertions, 18 deletions
diff --git a/contrib/lisp/org-mime.el b/contrib/lisp/org-mime.el
index fc333be..855dc2d 100644
--- a/contrib/lisp/org-mime.el
+++ b/contrib/lisp/org-mime.el
@@ -1,6 +1,6 @@
;;; org-mime.el --- org html export for text/html MIME emails
-;; Copyright (C) 2010-2012 Eric Schulte
+;; Copyright (C) 2010-2013 Eric Schulte
;; Author: Eric Schulte
;; Keywords: mime, mail, email, html
@@ -22,9 +22,7 @@
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING. If not, write to the
-;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
+;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
@@ -57,6 +55,9 @@
;;; Code:
(require 'cl)
+(declare-function org-export-string-as "ox"
+ (string backend &optional body-only ext-plist))
+
(defcustom org-mime-use-property-inheritance nil
"Non-nil means al MAIL_ properties apply also for sublevels."
:group 'org-mime
@@ -195,6 +196,8 @@ and images in a multipart/related part."
html using `org-mode'. If called with an active region only
export that region, otherwise export the entire body."
(interactive "P")
+ (require 'ox-org)
+ (require 'ox-html)
(let* ((region-p (org-region-active-p))
(html-start (or (and region-p (region-beginning))
(save-excursion
@@ -204,10 +207,11 @@ export that region, otherwise export the entire body."
(html-end (or (and region-p (region-end))
;; TODO: should catch signature...
(point-max)))
- (raw-body (buffer-substring html-start html-end))
+ (raw-body (concat org-mime-default-header
+ (buffer-substring html-start html-end)))
(tmp-file (make-temp-name (expand-file-name
"mail" temporary-file-directory)))
- (body (org-export-string raw-body 'org (file-name-directory tmp-file)))
+ (body (org-export-string-as raw-body 'org t))
;; because we probably don't want to skip part of our mail
(org-export-skip-text-before-1st-heading nil)
;; because we probably don't want to export a huge style file
@@ -219,8 +223,7 @@ export that region, otherwise export the entire body."
;; to hold attachments for inline html images
(html-and-images
(org-mime-replace-images
- (org-export-string raw-body 'html (file-name-directory tmp-file))
- tmp-file))
+ (org-export-string-as raw-body 'html t) tmp-file))
(html-images (unless arg (cdr html-and-images)))
(html (org-mime-apply-html-hook
(if arg
@@ -295,26 +298,29 @@ export that region, otherwise export the entire body."
(let ((fmt (if (symbolp fmt) fmt (intern fmt))))
(cond
((eq fmt 'org)
- (insert (org-export-string (org-babel-trim (bhook body 'org)) 'org)))
+ (require 'ox-org)
+ (insert (org-export-string-as
+ (org-babel-trim (bhook body 'org)) 'org t)))
((eq fmt 'ascii)
- (insert (org-export-string
- (concat "#+Title:\n" (bhook body 'ascii)) 'ascii)))
+ (require 'ox-ascii)
+ (insert (org-export-string-as
+ (concat "#+Title:\n" (bhook body 'ascii)) 'ascii t)))
((or (eq fmt 'html) (eq fmt 'html-ascii))
+ (require 'ox-ascii)
+ (require 'ox-org)
(let* ((org-link-file-path-type 'absolute)
;; 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-export-string
- (bhook body 'html)
- 'html (file-name-nondirectory file))
- file))
+ (html-and-images
+ (org-mime-replace-images
+ (org-export-string-as (bhook body 'html) 'html t) file))
(images (cdr html-and-images))
(html (org-mime-apply-html-hook (car html-and-images))))
(insert (org-mime-multipart
- (org-export-string
+ (org-export-string-as
(org-babel-trim
(bhook body (if (eq fmt 'html) 'org 'ascii)))
- (if (eq fmt 'html) 'org 'ascii))
+ (if (eq fmt 'html) 'org 'ascii) t)
html)
(mapconcat 'identity images "\n"))))))))