[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/org-mime 3c4f24c8d4 016/118: clean code. github organizati
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/org-mime 3c4f24c8d4 016/118: clean code. github organization created |
Date: |
Wed, 5 Jan 2022 07:58:42 -0500 (EST) |
branch: elpa/org-mime
commit 3c4f24c8d43c24332c4f2f4bf763459b11ead956
Author: Chen Bin <chenbin.sh@gmail.com>
Commit: Chen Bin <chenbin.sh@gmail.com>
clean code. github organization created
---
README.org | 8 ++++-
org-mime.el | 104 +++++++++++++++++++++++-------------------------------------
2 files changed, 47 insertions(+), 65 deletions(-)
diff --git a/README.org b/README.org
index b2f8e657a6..1677df63fe 100644
--- a/README.org
+++ b/README.org
@@ -2,6 +2,8 @@
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.
* Setup
#+begin_src elisp
(require 'org-mime)
@@ -57,7 +59,11 @@ 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.
+* 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.
* 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 stylesheets are licensed under the
[[http://www.gnu.org/licenses/gpl.html][GNU General Public License v3 or
later]].
+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 c3b2a5becf..553689a4ce 100644
--- a/org-mime.el
+++ b/org-mime.el
@@ -5,8 +5,8 @@
;; Author: Eric Schulte
;; Maintainer: Chen Bin (redguardtoo)
;; Keywords: mime, mail, email, html
-;; Homepage: http://github.com/redguardtoo/org-mime
-;; Version: 0.0.3
+;; Homepage: http://github.com/org-mime/org-mime
+;; Version: 0.0.4
;; This file is not part of GNU Emacs.
@@ -64,8 +64,8 @@
(defcustom org-mime-default-header
"#+OPTIONS: latex:t toc:nil H:3\n"
- "Default header to control html export options, and ensure
- first line isn't assumed to be a title line."
+ "Default header to control html export options.
+And ensure first line isn't assumed to be a title line."
:group 'org-mime
:type 'string)
@@ -75,8 +75,7 @@
:type '(choice 'mml 'semi 'vm))
(defcustom org-mime-preserve-breaks t
- "Used as temporary value of `org-export-preserve-breaks' during
- mime encoding."
+ "Temporary value of `org-export-preserve-breaks' during mime encoding."
:group 'org-mime
:type 'boolean)
@@ -101,22 +100,22 @@ buffer holding\nthe text to be exported.")
(defvar org-mime-debug nil
"Enable debug logger.")
-(defun org-mime--export-string (s &optional opts)
+(defun org-mime--export-string (s)
+ "Export string S into HTML format."
(if (fboundp 'org-export-string-as)
;; emacs24
- (org-export-string-as s 'html t opts)
+ (org-export-string-as s 'html t nil)
;; emacs 23
(org-export-string s "html")))
;; example hook, for setting a dark background in <pre
style="background-color: #EEE;"> elements
(defun org-mime-change-element-style (element style)
- "Set new default htlm style for <ELEMENT> elements in exported html."
+ "Set <ELEMENT> elements in exported html with new default html STYLE."
(while (re-search-forward (format "<%s" element) nil t)
(replace-match (format "<%s style=\"%s\"" element style))))
(defun org-mime-change-class-style (class style)
- "Set new default htlm style for objects with classs=CLASS in
-exported html."
+ "CLASS is used for new default html STYLE in exported html."
(while (re-search-forward (format "class=\"%s\"" class) nil t)
(replace-match (format "class=\"%s\" style=\"%s\"" class style))))
@@ -131,7 +130,7 @@ exported html."
;; "verse" "border-left: 2px solid gray; padding-left: 4px;")))
(defun org-mime-file (ext path id)
- "Markup a file for attachment."
+ "Markup a file wth EXT, PATH and ID for attachment."
(if org-mime-debug (message "org-mime-file called => %s %s %s" ext path id))
(case org-mime-library
(mml (format (concat "<#part type=\"%s\" filename=\"%s\" "
@@ -149,9 +148,8 @@ exported html."
(vm "?")))
(defun org-mime-multipart (plain html &optional images)
- "Markup a multipart/alternative with text/plain and text/html alternatives.
-If the html portion of the message includes images wrap the html
-and images in a multipart/related part."
+ "Markup a multipart/alternative PLAIN with PLAIN and HTML alternatives.
+If html portion of message includes IMAGES they are wrapped in
multipart/related part."
(case org-mime-library
(mml (concat "<#multipart type=alternative><#part type=text/plain>"
plain
@@ -172,7 +170,8 @@ and images in a multipart/related part."
(vm "?")))
(defun org-mime-replace-images (str current-file)
- "Replace images in html files with cid links."
+ "Replace images in STR with cid links.
+CURRENT-FILE is used to calculate full path of images."
(if org-mime-debug (message "org-mime-replace-images called => %s"
current-file)
) (let* (html-images)
(cons
@@ -194,9 +193,9 @@ and images in a multipart/related part."
html-images)))
(defun org-mime-htmlize (arg)
- "Export a portion of an email body composed using `mml-mode' to
-html using `org-mode'. If called with an active region only
-export that region, otherwise export the entire body."
+ "Export a portion of an email to html using `org-mode'.
+If called with an active region only export that region, otherwise entire body.
+If ARG is not NIL, use `org-mime-fixedwith-wrap' to wrap the exported text."
(if org-mime-debug (message "org-mime-htmlize called"))
(interactive "P")
(let* ((region-p (org-region-active-p))
@@ -234,6 +233,7 @@ export that region, otherwise export the entire body."
body html (mapconcat 'identity html-images "\n"))))))
(defun org-mime-apply-html-hook (html)
+ "Apply HTML hook."
(if org-mime-html-hook
(with-temp-buffer
(insert html)
@@ -242,12 +242,8 @@ export that region, otherwise export the entire body."
(buffer-string))
html))
-(defmacro org-mime-try (&rest body)
- `(condition-case nil ,@body (error nil)))
-
(defun org-mime--get-buffer-title ()
- "Returns the `TITLE' option of the current buffer, or `nil' if
-it is not set."
+ "Get buffer title."
(let* ((tmp (if (fboundp 'org-export--get-inbuffer-options)
(plist-get (org-export--get-inbuffer-options) :title))))
(when tmp
@@ -255,37 +251,13 @@ it is not set."
(set-text-properties 0 (length txt) nil txt)
txt))))
-(defun org-mime-send-buffer ()
- (run-hooks 'org-mime-send-buffer-hook)
- (let* ((region-p (org-region-active-p))
- (file (buffer-file-name (current-buffer)))
- (subject (or (org-mime--get-buffer-title)
- (if (not file) (buffer-name (buffer-base-buffer))
- (file-name-sans-extension
- (file-name-nondirectory file)))))
- (body-start (or (and region-p (region-beginning))
- (save-excursion (goto-char (point-min)))))
- (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)))
-
-(defun org-mime-send-subtree ()
- (run-hooks 'org-mime-send-buffer-hook)
- (save-excursion
- (org-up-heading-safe)
- (let* ((file (buffer-file-name (current-buffer)))
- (subject (nth 4 (org-heading-components)))
- (opts (org-export--get-subtree-options))
- (body (org-get-entry)))
- (org-mime-compose body file nil subject nil opts))))
-
-(defun org-mime-compose (body file &optional to subject headers opts)
+(defun org-mime-compose (body file &optional subject)
+ "Create mail BODY in FILE with SUBJECT."
(if org-mime-debug (message "org-mime-compose called => %s" file))
(let* ((fmt 'html))
(unless (featurep 'message)
(require 'message))
- (message-mail to subject headers nil)
+ (message-mail nil subject nil nil)
(message-goto-body)
(flet ((bhook (body fmt)
(let ((hook 'org-mime-pre-html-hook))
@@ -297,30 +269,34 @@ it is not set."
(buffer-string))
body))))
(let* ((org-link-file-path-type 'absolute)
- (plain (org-export-string-as (org-babel-trim body) 'ascii t opts))
+ (plain (org-export-string-as (org-babel-trim body) 'ascii t nil))
;; 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) file))
+ (org-mime--export-string (bhook body 'html)) file))
(images (cdr html-and-images))
(html (org-mime-apply-html-hook (car html-and-images))))
(insert (org-mime-multipart plain html)
(mapconcat 'identity images "\n"))))))
+;;;###autoload
(defun org-mime-org-buffer-htmlize ()
- "Create an email buffer containing the current org-mode file
- exported to html and encoded in both html and in org formats as
- mime alternatives."
- (interactive)
- (org-mime-send-buffer))
-
-(defun org-mime-org-subtree-htmlize ()
- "Create an email buffer containing the current subtree of the
- current org-mode file exported to html and encoded in both html
- and in org formats as mime alternatives."
+ "Create buffer where text encoded in html&org formats as mime alternatives."
(interactive)
- (org-mime-send-subtree))
+ (run-hooks 'org-mime-send-buffer-hook)
+ (let* ((region-p (org-region-active-p))
+ (file (buffer-file-name (current-buffer)))
+ (subject (or (org-mime--get-buffer-title)
+ (if (not file) (buffer-name (buffer-base-buffer))
+ (file-name-sans-extension
+ (file-name-nondirectory file)))))
+ (body-start (or (and region-p (region-beginning))
+ (save-excursion (goto-char (point-min)))))
+ (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 subject)))
(provide 'org-mime)
;;; org-mime.el ends here
- [nongnu] branch elpa/org-mime created (now 613969effc), ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime a1a7fb329f 003/118: clean doc, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime 3c4f24c8d4 016/118: clean code. github organization created,
ELPA Syncer <=
- [nongnu] elpa/org-mime 2347595278 002/118: emacs24 use org-export-string instead of org-export-string-as, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime a0b82a6c1a 024/118: better export format (not TOC, etc) and bug fix, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime 9d32b819f0 025/118: updated README, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime caa1f19d4b 009/118: Fix getting the subect, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime 0311662889 017/118: Correct 'interactive' position, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime ffbf3e3e47 010/118: Support mime encoding current subtree, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime c49eb00fc6 021/118: can create email from org subtree, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime e554d8821d 020/118: Merge pull request #1 from syohex/fix-package, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime 91d8f48775 023/118: can set org export options, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime 7c3483b2b0 030/118: sample for advanced setup, ELPA Syncer, 2022/01/05