[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/gnorb d79617f 019/449: gnorb-org.el: Email current subt
From: |
Stefan Monnier |
Subject: |
[elpa] externals/gnorb d79617f 019/449: gnorb-org.el: Email current subtree as exported text or file |
Date: |
Fri, 27 Nov 2020 23:15:00 -0500 (EST) |
branch: externals/gnorb
commit d79617fb0e808710dd4c60b4220e822968630dce
Author: Eric Abrahamsen <eric@ericabrahamsen.net>
Commit: Eric Abrahamsen <eric@ericabrahamsen.net>
gnorb-org.el: Email current subtree as exported text or file
Basic works-for-me functionality, bugs to be discovered later. About
four minutes after I wrote this I discovered there's some overlap with
org-mime, but it's different enough to keep.
---
lisp/gnorb-org.el | 98 +++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 96 insertions(+), 2 deletions(-)
diff --git a/lisp/gnorb-org.el b/lisp/gnorb-org.el
index 27cec3f..8636b42 100644
--- a/lisp/gnorb-org.el
+++ b/lisp/gnorb-org.el
@@ -53,7 +53,8 @@ point."
(set-window-configuration gnorb-org-window-conf))
; Should check here that we actually made it back to the right org
; heading. Could save an ID prop on the heading and check for that.
- (call-interactively 'org-agenda-todo))
+ (when (eql major-mode org-agenda-mode)
+ (call-interactively 'org-agenda-todo)))
(defun gnorb-org-handle-mail (&optional from-agenda)
"Handle mail-related links for current headline."
@@ -113,10 +114,103 @@ point."
(goto-char pos)
(gnorb-org-handle-mail t))))
+;;; Email subtree
+
+(defcustom gnorb-org-email-subtree-parameters nil
+ "A plist of export parameters corresponding to the EXT-PLIST
+ argument to the export functions."
+ :group 'gnorb-org)
+
+(defcustom gnorb-org-email-subtree-text-options '(nil t nil t)
+ "A list of ts and nils corresponding to Org's export options,
+to be used when exporting to text. The options, in order, are
+async, subtreep, visible-only, and body-only."
+ :group 'gnorb-org)
+
+(defcustom gnorb-org-email-subtree-file-options '(nil t nil nil)
+ "A list of ts and nils corresponding to Org's export options,
+to be used when exporting to a file. The options, in order, are
+async, subtreep, visible-only, and body-only."
+ :group 'gnorb-org)
+
+(defcustom gnorb-org-export-extensions
+ '((latex ".tex")
+ (ascii ".txt")
+ (html ".html")
+ (org ".org")
+ (icalendar ".ics")
+ (man ".man")
+ (md ".md")
+ (odt ".odt") ; not really, though
+ (texinfo ".texi")
+ (beamer ".tex"))
+ "Correspondence between export backends and their
+respective (usual) file extensions. Ugly way to do it, but what
+the hey..."
+ :group 'gnorb-org)
+
+(defun gnorb-org-email-subtree ()
+ "Call on a subtree to export it either to a text string or a file,
+then compose a mail message either with the exported text
+inserted into the message body, or the exported file attached to
+the message.
+
+Export options default to the following: When exporting to a
+buffer: async = nil, subtreep = t, visible-only = nil, body-only
+= t. Options are the same for files, except body-only is set to
+nil. Customize `gnorb-org-email-subtree-text-options' and
+`gnorb-org-email-subtree-file-options', respectively.
+
+Customize `gnorb-org-email-subtree-parameters' to your preferred
+default set of parameters."
+ ;; I sure would have liked to use the built-in dispatch ui, but it's
+ ;; got too much hard-coded stuff.
+ (interactive)
+ (let* ((backend-string
+ (org-completing-read
+ "Export backend: "
+ (mapcar (lambda (b)
+ (symbol-name (org-export-backend-name b)))
+ org-export--registered-backends) nil t))
+ (backend-symbol (intern backend-string))
+ (f-or-b (org-completing-read "Export as file or text? "
+ '("file" "text") nil t))
+ (org-export-show-temporary-export-buffer nil)
+ (opts (if (equal f-or-b "text")
+ gnorb-org-email-subtree-text-options
+ gnorb-org-email-subtree-file-options))
+ (result
+ (if (equal f-or-b "text")
+ (apply 'org-export-to-buffer
+ `(,backend-symbol
+ "*Gnorb Export*"
+ ,@opts
+ ,gnorb-org-email-subtree-parameters))
+ (apply 'org-export-to-file
+ `(,backend-symbol
+ ,(org-export-output-file-name
+ (second (assoc backend-symbol
gnorb-org-export-extensions))
+ t gnorb-tmp-dir)
+ ,@opts
+ ,gnorb-org-email-subtree-parameters)))))
+ (setq gnorb-org-window-conf (current-window-configuration))
+ (compose-mail nil nil nil nil nil nil nil
+ 'org-gnorb-restore-after-send)
+ (message-goto-body)
+ (insert "\n")
+ (if (equal f-or-b "text")
+ (insert-buffer result)
+ (mml-attach-file
+ result
+ (mm-default-file-encoding result)
+ nil "attachment"))
+ (message-goto-to)))
+
;; (eval-after-load "gnorb-org"
;; '(progn
;; (global-set-key (kbd "C-c C") 'gnorb-bbdb-cite-contact)
-;; (global-set-key (kbd "C-c H") 'gnorb-org-handle-mail)))
+;; (org-defkey org-mode-map (kbd "C-c H") 'gnorb-org-handle-mail)
+;; (org-defkey org-mode-map (kbd "C-c E") 'gnorb-org-email-subtree))
;; (eval-after-load 'org-agenda
;; '(org-defkey org-agenda-mode-map (kbd "H") 'gnorb-org-handle-mail-agenda))
- [elpa] externals/gnorb 88f6bda 002/449: README.md: Basic project description, (continued)
- [elpa] externals/gnorb 88f6bda 002/449: README.md: Basic project description, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb afd587b 003/449: Basic project structure., Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 82c06bc 001/449: Initial commit, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb ba4ec1b 004/449: Add customization skeleton., Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 1b037b7 006/449: gnorb-utils.el: Common utility file., Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb d090df9 007/449: gnorb-bbdb.el: New function gnorb-bbdb-mail-search, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb cc208a0 010/449: gnorb-bbdb.el: (gnorb-bbdb-mail-search), Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 869940a 015/449: README.org: Change file format to Org mode, expand docs, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 3429f3b 009/449: gnorb-org.el: (gnorb-org-contact-link), Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb b7dce0b 016/449: gnorb-utils.el: Require the cl library., Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb d79617f 019/449: gnorb-org.el: Email current subtree as exported text or file,
Stefan Monnier <=
- [elpa] externals/gnorb 27d08ef 022/449: README.org: Reorganize README, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 3edf1c9 025/449: gnorb-utils.el: gnorb-prompt-for-bbdb-record, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 32ecc09 026/449: gnorb-org.el: gnorb-org-handle-mail, gnorb-org-email-subtree, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 123b521 031/449: gnorb-org.el: bugfix gnorb-org-restore-after-send, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb a9c7410 032/449: gnorb-gnus.el: bugfix gnorb-gnus-attach-part, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 5adcc84 008/449: gnorb-utils: (gnorb-prompt-for-bbdb-record), Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb bedce9d 012/449: gnorb-gnus.el: (gnorb-gnus(article|mime)-org-attach), Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb d28a099 005/449: gnorb-bbdb.el: New function gnorb-bbdb-tag-agenda, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 63ac8f6 011/449: gnorb-org.el: (gnorb-org-handle-mail, gnorb-org-handle-mail-agenda), Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb c2b1a3a 013/449: Docstring for gnorb-org-contact-link, Stefan Monnier, 2020/11/27