[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/gnorb cf975f5 048/449: Refactor gnorb-org mail-related
From: |
Stefan Monnier |
Subject: |
[elpa] externals/gnorb cf975f5 048/449: Refactor gnorb-org mail-related stuff. |
Date: |
Fri, 27 Nov 2020 23:15:06 -0500 (EST) |
branch: externals/gnorb
commit cf975f583fdd4d787de777e1b8c790605c78a98e
Author: Eric Abrahamsen <eric@ericabrahamsen.net>
Commit: Eric Abrahamsen <eric@ericabrahamsen.net>
Refactor gnorb-org mail-related stuff.
gnorb-org.el: `gnorb-org-email-subtree' and `gnorb-org-handle-mail' make
more extensive use of the underlying `gnorb-org-setup-message'.
---
lisp/gnorb-org.el | 90 +++++++++++++++++++++++++++----------------------------
1 file changed, 44 insertions(+), 46 deletions(-)
diff --git a/lisp/gnorb-org.el b/lisp/gnorb-org.el
index 248f339..51ec73d 100644
--- a/lisp/gnorb-org.el
+++ b/lisp/gnorb-org.el
@@ -97,21 +97,45 @@ point."
(push mail mails))))))))
(list message mails)))
-(defun gnorb-org-setup-message (message mails)
- (if (not message)
+(defun gnorb-org-setup-message (&optional messages mails attachments text)
+ "Common message setup routine for other gnorb-org commands."
+ (if (not messages)
+ ; either compose new message...
(compose-mail (mapconcat 'identity mails ", ")
nil nil nil nil nil nil
'(gnorb-org-restore-after-send))
- (org-gnus-open (org-link-unescape (car message)))
+ ; ...or follow link and start reply
+ (org-gnus-open (org-link-unescape (car messages)))
(call-interactively
'gnus-summary-wide-reply-with-original)
+ ; add MAILS to message To header
(when mails
(message-goto-to)
(insert ", ")
(insert (mapconcat 'identity mails ", ")))
(add-to-list 'message-exit-actions
- 'gnorb-org-restore-after-send t)
- (message-goto-body)))
+ 'gnorb-org-restore-after-send t))
+ ; attach ATTACHMENTS
+ (map-y-or-n-p
+ (lambda (a) (format "Attach %s to outgoing message? "
+ (file-name-nondirectory a)))
+ (lambda (a)
+ (mml-attach-file
+ a (mm-default-file-encoding a)
+ nil "attachment"))
+ attachments
+ '("file" "files" "attach"))
+ ; insert text, if any
+ (when text
+ (message-goto-body)
+ (insert"\n")
+ (if (bufferp text)
+ (insert-buffer text)
+ (insert text)))
+ ; put point somewhere reasonable
+ (if mails
+ (message-goto-body)
+ (message-goto-to)))
(defun gnorb-org-attachment-list ()
"Get a list of files (absolute filenames) attached to the
@@ -125,7 +149,7 @@ current heading."
files)))
(defun gnorb-org-handle-mail ()
- "Handle mail-related links for current headline."
+ "Handle current headline as a mail TODO."
(interactive)
(setq gnorb-org-window-conf (current-window-configuration))
(when (eq major-mode 'org-agenda-mode)
@@ -142,21 +166,9 @@ current heading."
(error "Not in an org item"))
(let ((mail-stuff (gnorb-org-extract-mail-stuff))
(attachments (gnorb-org-attachment-list)))
- (gnorb-org-setup-message (first mail-stuff) (second mail-stuff))
- (message-goto-body)
- (map-y-or-n-p
- (lambda (a)
- (format "Attach %s to outgoing message? "
- (file-name-nondirectory a)))
- (lambda (a)
- (mml-attach-file
- a (mm-default-file-encoding a)
- nil "attachment"))
- attachments
- '("file" "files" "attach"))
- (if (second mail-stuff)
- (message-goto-body)
- (message-goto-to))))
+ (gnorb-org-setup-message
+ (first mail-stuff) (second mail-stuff)
+ attachments)))
;;; Email subtree
@@ -218,14 +230,14 @@ default set of parameters."
(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? "
+ (f-or-t (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")
+ (opts (if (equal f-or-t "text")
gnorb-org-email-subtree-text-options
gnorb-org-email-subtree-file-options))
(result
- (if (equal f-or-b "text")
+ (if (equal f-or-t "text")
(apply 'org-export-to-buffer
`(,backend-symbol
"*Gnorb Export*"
@@ -239,29 +251,15 @@ default set of parameters."
,@opts
,gnorb-org-email-subtree-parameters))))
(mail-stuff (gnorb-org-extract-mail-stuff))
- (attachments (gnorb-org-attachment-list)))
+ (attachments (gnorb-org-attachment-list))
+ text)
(setq gnorb-org-window-conf (current-window-configuration))
- (gnorb-org-setup-message (first mail-stuff) (second mail-stuff))
- (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"))
- (map-y-or-n-p
- (lambda (a) (format "Attach %s to outgoing message? "
- (file-name-nondirectory a)))
- (lambda (a)
- (mml-attach-file
- a (mm-default-file-encoding a)
- nil "attachment"))
- attachments
- '("file" "files" "attach"))
- (if (second mail-stuff)
- (message-goto-body)
- (message-goto-to))))
+ (if (bufferp result)
+ (setq text result)
+ (push result attachments))
+ (gnorb-org-setup-message
+ (first mail-stuff) (second mail-stuff)
+ attachments text)))
(defcustom gnorb-org-capture-collect-link-p t
"Should the capture process store a link to the gnus message or
- [elpa] externals/gnorb c9e4dfb 056/449: Limit to TODOs only in BBDB tag searches, (continued)
- [elpa] externals/gnorb c9e4dfb 056/449: Limit to TODOs only in BBDB tag searches, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 210851e 065/449: That's not broken anymore., Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 72a98bd 020/449: README.org: Document new capture attachment thingy., Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb e2617e0 030/449: gnorb-org.el: That's not how return-actions look, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb c5e3459 033/449: README.org: Fixed keybinding for mime map, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 0e75c71 035/449: Note future mail-search-from-agenda function, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 1024a81 037/449: New gnorb-org-capture-collect-link-p option, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb ee8b595 036/449: Merge gnorb-org-handle-mail functions, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 5b9e163 047/449: Allow attaching in all captures., Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 3a95a07 049/449: First go at `gnorb-org-agenda-popup-bbdb', Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb cf975f5 048/449: Refactor gnorb-org mail-related stuff.,
Stefan Monnier <=
- [elpa] externals/gnorb ac3a4d2 050/449: Change README.org wording, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 78f625b 052/449: Documentation and whitespace changes, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb ac392c0 053/449: Leave point in body of message replies, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb e05fafe 054/449: `gnorb-org-popup-agenda-popup-bbdb' keybinding, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 32a88b8 061/449: Wishlist item for outgoing messages, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 5ba5ce4 062/449: Rework gnorb-org-restore-after-send, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 8246cd4 064/449: Restore from mails more reliably, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 89b57f0 066/449: Whoops., Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 9f13881 067/449: First whack at gnorb-gnus-message-trigger-todo, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb e472348 073/449: New hook gnorb-org-after-message-setup-hook, Stefan Monnier, 2020/11/27