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

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

[elpa] master a60a0a2 2/5: Gnorb: Consolidate all after-capture function


From: Eric Abrahamsen
Subject: [elpa] master a60a0a2 2/5: Gnorb: Consolidate all after-capture functions into one
Date: Mon, 4 Dec 2017 14:08:41 -0500 (EST)

branch: master
commit a60a0a2249fcfe7544f373c23cd3bd981799a0f9
Author: Eric Abrahamsen <address@hidden>
Commit: Eric Abrahamsen <address@hidden>

    Gnorb: Consolidate all after-capture functions into one
    
    * packages/gnorb/gnorb-gnus.el (gnorb-gnus-after-capture-function):
      This new function replaces gnorb-gnus-capture-attach, and
      gnorb-gnus-capture-save-text. New: it also ticks the message as
      needed, and updates the summary line.
---
 packages/gnorb/gnorb-gnus.el | 89 +++++++++++++++++++++++++-------------------
 1 file changed, 50 insertions(+), 39 deletions(-)

diff --git a/packages/gnorb/gnorb-gnus.el b/packages/gnorb/gnorb-gnus.el
index abf0739..0750261 100644
--- a/packages/gnorb/gnorb-gnus.el
+++ b/packages/gnorb/gnorb-gnus.el
@@ -244,47 +244,58 @@ save them into `gnorb-tmp-dir'."
            (when (or capture-p store)
              (push filename gnorb-gnus-capture-attachments))))))))
 
-;;; Make the above work in the capture process
-
-(defun gnorb-gnus-capture-attach ()
-  (when (and (or gnorb-gnus-capture-always-attach
-                (org-capture-get :gnus-attachments))
-            (with-current-buffer
-                (org-capture-get :original-buffer)
-              (memq major-mode '(gnus-summary-mode gnus-article-mode))))
-    (require 'org-attach)
-    (setq gnorb-gnus-capture-attachments nil)
-    (gnorb-gnus-collect-all-attachments t)
-    (map-y-or-n-p
-     (lambda (a)
-       (format "Attach %s to capture 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)))
-
-(defun gnorb-gnus-capture-save-text ()
-  (when (and gnorb-gnus-copy-message-text
-            (with-current-buffer
-                (org-capture-get :original-buffer)
-              (memq major-mode '(gnus-summary-mode gnus-article-mode))))
+(defun gnorb-gnus-after-capture-function ()
+  "Do various things after starting the capture process.
+Currently includes:
+
+1. Offering to move all the attachments from the message we
+captured from onto the Org heading being captured.
+
+2. Possibly saving the text of the message we captured from (see
+`gnorb-gnus-copy-message-text').
+
+3. Possibly ticking the message we captured from (see
+`gnorb-gnus-tick-all-tracked-messages')."
+  (when (with-current-buffer
+           (org-capture-get :original-buffer)
+         (memq major-mode '(gnus-summary-mode gnus-article-mode)))
     (save-window-excursion
       (set-buffer (org-capture-get :original-buffer))
-      (gnus-with-article-buffer
-       (article-goto-body)
-       (if (numberp gnorb-gnus-copy-message-text)
-           (progn
-             (copy-to-register
-              gnorb-gnus-copy-message-text
-              (point) (point-max))
-             (message "Message text copied to register %c"
-                      gnorb-gnus-copy-message-text))
-         (kill-new (buffer-substring (point) (point-max)))
-         (message "Message text copied to kill ring"))))))
-
-(add-hook 'org-capture-mode-hook 'gnorb-gnus-capture-attach)
-(add-hook 'org-capture-mode-hook 'gnorb-gnus-capture-save-text)
+      (let ((art-no (gnus-summary-article-number)))
+
+       (when gnorb-gnus-copy-message-text
+         (gnus-with-article-buffer
+           (article-goto-body)
+           (if (numberp gnorb-gnus-copy-message-text)
+               (progn
+                 (copy-to-register
+                  gnorb-gnus-copy-message-text
+                  (point) (point-max))
+                 (message "Message text copied to register %c"
+                          gnorb-gnus-copy-message-text))
+             (kill-new (buffer-substring (point) (point-max)))
+             (message "Message text copied to kill ring"))))
+
+       (when (or gnorb-gnus-capture-always-attach
+                 (org-capture-get :gnus-attachments))
+         (require 'org-attach)
+         (setq gnorb-gnus-capture-attachments nil)
+         (gnorb-gnus-collect-all-attachments t)
+         (map-y-or-n-p
+          (lambda (a)
+            (format "Attach %s to capture 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))
+
+       (when gnorb-gnus-tick-all-tracked-messages
+         (gnus-summary-mark-article art-no gnus-ticked-mark))
+
+       (gnus-summary-update-article art-no)))))
+
+(add-hook 'org-capture-mode-hook 'gnorb-gnus-after-capture-function)
 
 (defvar org-note-abort)
 



reply via email to

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