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

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

[elpa] externals/gnorb ba99110 242/449: Check for relevant headings when


From: Stefan Monnier
Subject: [elpa] externals/gnorb ba99110 242/449: Check for relevant headings when handling attachments
Date: Fri, 27 Nov 2020 23:15:48 -0500 (EST)

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

    Check for relevant headings when handling attachments
    
    * gnorb-gnus.el (gnorb-gnus-attach-part): When the user wants to attach
      a mail attachment to a TODO heading, check if the message is
      already associated with a heading, offer that first.
---
 gnorb-gnus.el | 25 +++++++++++++++++++------
 1 file changed, 19 insertions(+), 6 deletions(-)

diff --git a/gnorb-gnus.el b/gnorb-gnus.el
index e6c6a1d..ba72107 100644
--- a/gnorb-gnus.el
+++ b/gnorb-gnus.el
@@ -156,15 +156,28 @@ each message."
 (defun gnorb-gnus-attach-part (handle &optional org-heading)
   "Attach HANDLE to an existing org heading."
   (let* ((filename (gnorb-gnus-save-part handle))
-        ;; we should probably do the automatic location routine here,
-        ;; as well.
         (org-refile-targets gnorb-gnus-trigger-refile-targets)
-        (org-heading (or org-heading
-                         (org-refile-get-location "Attach part to" nil t))))
+        (ref-msg-ids
+         (concat (gnus-fetch-original-field "references") " "
+                 (gnus-fetch-original-field "in-reply-to")))
+        (rel-heading
+         (when gnorb-tracking-enabled
+           (car (gnorb-find-visit-candidates
+                 ref-msg-ids))))
+        (org-heading
+         (if (and rel-heading
+                  (y-or-n-p (message
+                             "Attach part to %s"
+                             (gnorb-pretty-outline rel-heading))))
+             rel-heading
+           (org-refile-get-location "Attach part to" nil t))))
     (require 'org-attach)
     (save-window-excursion
-      (find-file (nth 1 org-heading))
-      (goto-char (nth 3 org-heading))
+      (if (stringp org-heading)
+         (org-id-goto org-heading)
+       (progn
+         (find-file (nth 1 org-heading))
+         (goto-char (nth 3 org-heading))))
       (org-attach-attach filename nil 'mv))))
 
 (defun gnorb-gnus-save-part (handle)



reply via email to

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