emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/gnorb ee8b595 036/449: Merge gnorb-org-handle-mail func


From: Stefan Monnier
Subject: [elpa] externals/gnorb ee8b595 036/449: Merge gnorb-org-handle-mail functions
Date: Fri, 27 Nov 2020 23:15:03 -0500 (EST)

branch: externals/gnorb
commit ee8b59594995ea45ba9903d826e8dd7d4d5d54b2
Author: Eric Abrahamsen <eric@ericabrahamsen.net>
Commit: Eric Abrahamsen <eric@ericabrahamsen.net>

    Merge gnorb-org-handle-mail functions
    
    gnorb.org.el: There used to be two separate functions for agenda and
    non-agenda use. No reason for that...
---
 README.org        | 50 ++++++++++++++++++++++++++++----------------------
 lisp/gnorb-org.el | 29 +++++++++++++----------------
 2 files changed, 41 insertions(+), 38 deletions(-)

diff --git a/README.org b/README.org
index 5b9a46e..f248abf 100644
--- a/README.org
+++ b/README.org
@@ -50,37 +50,43 @@ Prompt for a BBDB record and insert a string of the type 
"Bob Smith
 **** gnorb-org-contact-link
 Prompt for a BBDB record and insert a link to that record at
 point.
-**** gnorb-org-handle-mail(-agenda)
-Call these functions on a headline containing links to Gnus messages,
-or mailto links, or BBDB links. Either start a reply to the linked
-message, or a new message, with the linked addresses in the "To"
-field. When the message is sent, return to the original Org buffer. If
-the TODO keyword is a member of `gnorb-org-mail-todos' (by default,
-"MAIL" and "REPLY"), then call `org-agenda-todo' and prompt to mark
-the TODO as done.
+**** gnorb-org-handle-mail
+This function does its best to interpret the heading under point as an
+email action.
 
-This works best with a matching capture template: if the template
-stores a link to the message under point within the headline text,
-this command will reply to that message in a DWIM style.
+If the heading text contains a link to a Gnus message then start a
+reply to that message, otherwise start composing a new message. If the
+heading contains mailto links or BBDB links, put those addresses in
+the "To" field of the new message (or reply). If the heading has
+org-attach'ed attachments, prompt to attach them to the outgoing
+message.
+
+When the message is sent, return to the original Org buffer. If the
+heading's TODO keyword is a member of `gnorb-org-mail-todos' (by
+default, "MAIL" and "REPLY"), then call `org-agenda-todo' and prompt
+to mark the TODO as done. Set that option to nil to prompt for all
+TODO keywords.
+
+This works best with a matching capture template: the template stores
+a link to the message under point within the headline text, and this
+command replies to that message in a DWIM style.
 
-If the heading has org-attach'ed attachments, prompt to attach them to
-the outgoing message.
 **** gnorb-org-email-subtree
 Call on a Org subtree to export the subtree as either text or a file.
 Then compose a message with the text in the message body, or the file
 attached to the message.
 
 There's a little overlap with org-mime, but this function allows for
-attaching files, and does not compose an HTML message. I may look into
-integrating it a bit with org-mime later.
+exporting the subtree as a file, and does not compose a MIME-multipart
+HTML message. I may look into integrating it a bit with org-mime
+later.
 
-This function is also a bit similar to
-`gnorb-org-handle-mail(-agenda)': it will also collect email address
-links from the heading and put them in the "To" field of the message,
-and also prompt to send org-attach'ed attachments along with the
-email.
+This function is also overlaps with `gnorb-org-handle-mail':
+it will also collect email address links from the heading and put them
+in the "To" field of the message, and also prompts to send
+org-attach'ed attachments along with the email.
 
-What's the difference, then? Use `gnorb-org-handle-mail(-agenda)' when
+What's the difference, then? Use `gnorb-org-handle-mail' when
 the primary purpose of the heading is as a TODO reminding you to send
 or reply to an email. Any text under the heading will be disregarded.
 
@@ -98,7 +104,7 @@ more distinct.
        (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))))
+         '(org-defkey org-agenda-mode-map (kbd "H") 'gnorb-org-handle-mail))))
 #+END_SRC
 ** Gnorb-Gnus
 *** Functions
diff --git a/lisp/gnorb-org.el b/lisp/gnorb-org.el
index 373f6e7..df9825c 100644
--- a/lisp/gnorb-org.el
+++ b/lisp/gnorb-org.el
@@ -106,14 +106,22 @@ point."
                    (org-attach-file-list attach-dir))))
       files)))
 
-(defun gnorb-org-handle-mail (&optional from-agenda)
+(defun gnorb-org-handle-mail ()
   "Handle mail-related links for current headline."
   (interactive)
+  (setq gnorb-org-window-conf (current-window-configuration))
+  (when (eq major-mode 'org-agenda-mode)
+    (org-agenda-check-type t 'agenda 'timeline 'todo 'tags)
+    (org-agenda-check-no-diary)
+    (let* ((marker (or (org-get-at-bol 'org-hd-marker)
+                      (org-agenda-error)))
+          (buffer (marker-buffer marker))
+          (pos (marker-position marker)))
+      (switch-to-buffer buffer)
+      (widen)
+      (goto-char pos)))
   (unless (org-back-to-heading t)
     (error "Not in an org item"))
-  (unless from-agenda
-    ;; window conf should return to the agenda.
-    (setq gnorb-org-window-conf (current-window-configuration)))
   (let ((mail-stuff (gnorb-org-extract-mail-stuff))
        (attachments (gnorb-org-attachment-list)))
     (gnorb-org-setup-message (first mail-stuff) (second mail-stuff))
@@ -131,18 +139,7 @@ point."
 
 (defun gnorb-org-handle-mail-agenda ()
   "Examine item at point for mail-related links, and handle them."
-  (interactive)
-  (org-agenda-check-type t 'agenda 'timeline 'todo 'tags)
-  (org-agenda-check-no-diary)
-  (let* ((marker (or (org-get-at-bol 'org-hd-marker)
-                    (org-agenda-error)))
-        (buffer (marker-buffer marker))
-        (pos (marker-position marker)))
-    (setq gnorb-org-window-conf (current-window-configuration))
-    (with-current-buffer buffer
-      (widen)
-      (goto-char pos)
-      (gnorb-org-handle-mail t))))
+  (interactive))
 
 ;;; Email subtree
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]