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

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

[elpa] externals/gnorb 7ba1786 196/449: Use gnorb-gnus-message-info for


From: Stefan Monnier
Subject: [elpa] externals/gnorb 7ba1786 196/449: Use gnorb-gnus-message-info for incoming and outgoing
Date: Fri, 27 Nov 2020 23:15:37 -0500 (EST)

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

    Use gnorb-gnus-message-info for incoming and outgoing
    
    * lisp/gnorb-gnus.el (gnorb-gnus-incoming-do-todo): This function should
      not be creating registry entries. It should just load
      gnorb-gnus-message-info, same as outgoing does, and leave the rest to
      gnorb-trigger-todo-action.
    
    * lisp/gnorb-utils.el (gnorb-trigger-todo-action): Now responsible for
      creating registry entries both for incoming and outgoing. It no longer
      needs to "know" which is which.
---
 lisp/gnorb-gnus.el  | 20 +++++++++-------
 lisp/gnorb-utils.el | 67 ++++++++++++++++++++++++++---------------------------
 2 files changed, 45 insertions(+), 42 deletions(-)

diff --git a/lisp/gnorb-gnus.el b/lisp/gnorb-gnus.el
index 0c21346..bc2c3c4 100644
--- a/lisp/gnorb-gnus.el
+++ b/lisp/gnorb-gnus.el
@@ -479,17 +479,18 @@ to t (it is, by default)."
   ;; We should only store a link if it's not already at the head of
   ;; `org-stored-links'. There's some duplicate storage, at
   ;; present. Take a look at calling it non-interactively.
-  (call-interactively 'org-store-link)
   (setq gnorb-window-conf (current-window-configuration))
   (move-marker gnorb-return-marker (point))
+  (setq gnorb-gnus-message-info nil)
   (let* ((msg-id (mail-header-id headers))
-        (sender (mail-header-from headers))
+        (from (mail-header-from headers))
         (subject (mail-header-subject headers))
+        (date (mail-header-date headers))
+        (to (cdr (assoc 'To (mail-header-extra headers))))
         (group gnus-newsgroup-name)
+        (link (call-interactively 'org-store-link))
         (org-refile-targets gnorb-gnus-trigger-refile-targets)
-        ;; otherwise `gnorb-trigger-todo-action' will think we
-        ;; started from an outgoing message
-        (gnorb-gnus-message-info nil)
+        ;;
         (ref-msg-ids
          (with-current-buffer gnus-original-article-buffer
            (message-narrow-to-headers-or-head)
@@ -505,6 +506,11 @@ to t (it is, by default)."
              (message "Gnorb can't check for relevant headings unless 
`org-id-track-globally' is t")
              (sit-for 1))))
         targ)
+    (setq gnorb-gnus-message-info
+           `(:subject ,subject :msg-id ,msg-id
+                      :to ,to :from ,from
+                      :link ,link :date ,date :refs ,ref-msg-ids
+                      :group ,group))
     (gnorb-gnus-collect-all-attachments nil t)
     ;; Delete other windows, users can restore with
     ;; `gnorb-restore-layout'.
@@ -523,9 +529,7 @@ to t (it is, by default)."
     (message
      "Insert a link to the message with org-insert-link (%s)"
      (key-description
-      (where-is-internal 'org-insert-link nil t)))
-    (gnorb-registry-make-entry
-     msg-id sender subject (org-id-get-create) group)))
+      (where-is-internal 'org-insert-link nil t)))))
 
 ;;;###autoload
 (defun gnorb-gnus-search-messages (str &optional ret)
diff --git a/lisp/gnorb-utils.el b/lisp/gnorb-utils.el
index b26ef23..0456a55 100644
--- a/lisp/gnorb-utils.el
+++ b/lisp/gnorb-utils.el
@@ -139,40 +139,39 @@ the prefix arg."
                        (point-at-bol))
          ret-dest-todo (org-entry-get
                         root-marker "TODO"))
-    (let ((sent-id (plist-get gnorb-gnus-message-info :msg-id)))
-      (when sent-id
-       (gnorb-registry-make-entry
-        sent-id
-        (plist-get gnorb-gnus-message-info :from)
-        (plist-get gnorb-gnus-message-info :subject)
-        (org-id-get-create)
-        (plist-get gnorb-gnus-message-info :group)))
-      (setq action (cond ((not
-                          (or (and ret-dest-todo
-                                   (null gnorb-org-mail-todos))
-                              (member ret-dest-todo gnorb-org-mail-todos)))
-                         'note)
-                        ((eq gnorb-trigger-todo-default 'prompt)
-                         (intern (completing-read
-                                  "Take note, or trigger TODO state change? "
-                                  '("note" "todo") nil t)))
-                        ((null arg)
-                         gnorb-trigger-todo-default)
-                        (t
-                         (if (eq gnorb-trigger-todo-default 'todo)
-                             'note
-                           'todo))))
-      (map-y-or-n-p
-       (lambda (a)
-        (format "Attach %s to heading? "
-                (file-name-nondirectory a)))
-       (lambda (a) (org-attach-attach a nil 'mv))
-       gnorb-gnus-capture-attachments
-       '("file" "files" "attach"))
-      (setq gnorb-gnus-capture-attachments nil)
-      (if (eq action 'note)
-         (call-interactively note-func)
-       (call-interactively todo-func)))))
+    (gnorb-registry-make-entry
+     (plist-get gnorb-gnus-message-info :msg-id)
+     (plist-get gnorb-gnus-message-info :from)
+     (plist-get gnorb-gnus-message-info :subject)
+     (org-with-point-at root-marker
+       (org-id-get-create))
+     (plist-get gnorb-gnus-message-info :group))
+    (setq action (cond ((not
+                        (or (and ret-dest-todo
+                                 (null gnorb-org-mail-todos))
+                            (member ret-dest-todo gnorb-org-mail-todos)))
+                       'note)
+                      ((eq gnorb-trigger-todo-default 'prompt)
+                       (intern (completing-read
+                                "Take note, or trigger TODO state change? "
+                                '("note" "todo") nil t)))
+                      ((null arg)
+                       gnorb-trigger-todo-default)
+                      (t
+                       (if (eq gnorb-trigger-todo-default 'todo)
+                           'note
+                         'todo))))
+    (map-y-or-n-p
+     (lambda (a)
+       (format "Attach %s to heading? "
+              (file-name-nondirectory a)))
+     (lambda (a) (org-attach-attach a nil 'mv))
+     gnorb-gnus-capture-attachments
+     '("file" "files" "attach"))
+    (setq gnorb-gnus-capture-attachments nil)
+    (if (eq action 'note)
+       (call-interactively note-func)
+      (call-interactively todo-func))))
 
 (defun gnorb-pretty-outline (id &optional kw)
   "Return pretty outline path of the Org heading indicated by ID.



reply via email to

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