[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/gnorb d1299d2 388/449: Gnorb: Consolidate all after-cap
From: |
Stefan Monnier |
Subject: |
[elpa] externals/gnorb d1299d2 388/449: Gnorb: Consolidate all after-capture functions into one |
Date: |
Fri, 27 Nov 2020 23:16:17 -0500 (EST) |
branch: externals/gnorb
commit d1299d2194c534e15f40dd055cc5ca7ff9891a06
Author: Eric Abrahamsen <eric@ericabrahamsen.net>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>
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.
---
gnorb-gnus.el | 89 +++++++++++++++++++++++++++++++++--------------------------
1 file changed, 50 insertions(+), 39 deletions(-)
diff --git a/gnorb-gnus.el b/gnorb-gnus.el
index abf0739..0750261 100644
--- a/gnorb-gnus.el
+++ b/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)
- [elpa] externals/gnorb 5f885be 398/449: Gnorb: New command for inserting tracked messages; bump to 1.4.1, (continued)
- [elpa] externals/gnorb 5f885be 398/449: Gnorb: New command for inserting tracked messages; bump to 1.4.1, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 8922fd0 409/449: [gnorb] Fix immediate and inexplicable typos, bump to 1.5.1, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 0c20b7d 397/449: Provide Org tagging for Gnus messages, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb c2f837c 341/449: Improve efficiency of retrieving tracked messages, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 6917948 343/449: Bah, typo, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 47195a6 349/449: Require gnorb-gnus in the gnus-started-hook, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb b892337 356/449: Bump version to 1.1.3, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 5c270cd 357/449: Update NEWS file, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 269a8a8 363/449: New function gnorb-install-defaults, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 27b58a9 364/449: Fix autoloads for BBDB functions, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb d1299d2 388/449: Gnorb: Consolidate all after-capture functions into one,
Stefan Monnier <=
- [elpa] externals/gnorb 6722839 327/449: Formatting improvements, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 8c2fb15 329/449: nngnorb.el: Handle non-existent nnir-tmp-buffer, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 9da022f 366/449: Fix creation of nngnorb/nnir groups, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 632b03d 367/449: Add gnorb-version command, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 7908f75 371/449: Update Gnus summary article line after trigger process, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb e865a8b 381/449: Odd bug in gnorb-org-handle-mail, bump to 1.3.1, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb af3521f 385/449: When responding, let a blank sender pass, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 5d59ba6 392/449: Gnorb: Bump version to 1.3.3, tiny manual fix, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 40fe377 391/449: Gnorb: Try harder to find the nngnorb server, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 30a6171 404/449: Factor out function for finding nngnorb server, Stefan Monnier, 2020/11/27