[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/gnorb 6653b6c 187/449: Fix gnorb-tracking-initialize
From: |
Stefan Monnier |
Subject: |
[elpa] externals/gnorb 6653b6c 187/449: Fix gnorb-tracking-initialize |
Date: |
Fri, 27 Nov 2020 23:15:36 -0500 (EST) |
branch: externals/gnorb
commit 6653b6cf1dbf4f383e9b8c396671c52bf6d15327
Author: Eric Abrahamsen <eric@ericabrahamsen.net>
Commit: Eric Abrahamsen <eric@ericabrahamsen.net>
Fix gnorb-tracking-initialize
* lisp/gnorb-utils.el (gnorb-tracking-initialize): Needs to be put into
the gnus-started-hook in order to work properly.
---
lisp/gnorb-registry.el | 18 +++++++++++++++++-
lisp/gnorb-utils.el | 15 ++++++++++-----
2 files changed, 27 insertions(+), 6 deletions(-)
diff --git a/lisp/gnorb-registry.el b/lisp/gnorb-registry.el
index 95f24c5..3c4da22 100644
--- a/lisp/gnorb-registry.el
+++ b/lisp/gnorb-registry.el
@@ -88,15 +88,31 @@ to the message's registry entry, under the 'gnorb-ids key."
(memq major-mode '(gnus-summary-mode gnus-article-mode)))
(not org-note-abort))
(let* ((msg-id
- (concat "<" (plist-get org-store-link-plist :message-id) ">"))
+ (format "<%s>" (plist-get org-store-link-plist :message-id)))
(entry (gnus-registry-get-or-make-entry msg-id))
(org-ids
(gnus-registry-get-id-key msg-id 'gnorb-ids))
(new-org-id (org-id-get-create)))
+ (plist-put org-capture-plist :gnorb-id new-org-id)
(setq org-ids (cons new-org-id org-ids))
(setq org-ids (delete-dups org-ids))
(gnus-registry-set-id-key msg-id 'gnorb-ids org-ids))))
+
+(defun gnorb-registry-capture-abort-cleanup ()
+ (when (and (org-capture-get :gnorb-id)
+ org-note-abort)
+ (condition-case error
+ (let* ((msg-id (format "<%s>" (plist-get org-store-link-plist
:message-id)))
+ (existing-org-ids (gnus-registry-get-id-key msg-id 'gnorb-ids))
+ (org-id (org-capture-get :gnorb-id)))
+ (when (member org-id existing-org-ids)
+ (gnus-registry-set-id-key msg-id 'gnorb-ids
+ (remove org-id existing-org-ids)))
+ (setq abort-note 'clean))
+ (error
+ (setq abort-note 'dirty)))))
+
(defun gnorb-find-visit-candidates (ids)
"For all message-ids in IDS (which should be a list of
Message-ID strings, with angle brackets), produce a list of Org
diff --git a/lisp/gnorb-utils.el b/lisp/gnorb-utils.el
index 7d598a8..669763f 100644
--- a/lisp/gnorb-utils.el
+++ b/lisp/gnorb-utils.el
@@ -262,11 +262,16 @@ Gnus messages and Org headings. This requires that the
Gnus
registry be in use, and should be called after the call to
`gnus-registry-initialize'."
(require 'gnorb-registry)
- (unless (gnus-registry-install-p)
- (user-error "Gnorb tracking requires that the Gnus registry be
installed."))
- (add-to-list 'gnus-registry-extra-entries-precious 'gnorb-ids)
- (add-hook 'org-capture-prepare-finalize-hook 'gnorb-registry-capture)
- (setq gnorb-tracking-enabled t))
+ (add-hook
+ 'gnus-started-hook
+ (lambda ()
+ (unless (gnus-registry-install-p)
+ (user-error "Gnorb tracking requires that the Gnus registry be
installed."))
+ (add-to-list 'gnus-registry-extra-entries-precious 'gnorb-ids)
+ (add-to-list 'gnus-registry-track-extra 'gnorb-ids)
+ (add-hook 'org-capture-mode-hook 'gnorb-registry-capture)
+ (add-hook 'org-capture-prepare-finalize-hook
'gnorb-registry-capture-abort-cleanup)
+ (setq gnorb-tracking-enabled t))))
(provide 'gnorb-utils)
;;; gnorb-utils.el ends here
- [elpa] externals/gnorb 8958546 155/449: Backquote escape fail, (continued)
- [elpa] externals/gnorb 8958546 155/449: Backquote escape fail, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 38df7d0 166/449: Ignore a notes.org file, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 44f8d23 165/449: Begin shift to using the registry, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb c280ea4 160/449: Only add relevant sent messages in the registry, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 4fc1075 172/449: Rename gnorb-org-window-conf to gnorb-window-conf, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb bb44a8c 174/449: Don't force id creation!, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb b596ee7 157/449: Check for success when following gnus links, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 43fbd55 176/449: New function for restoring window layout, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb fe7d814 179/449: Provide initialization of gnorb email tracking, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb b95f371 186/449: That's not how you use condition-case, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 6653b6c 187/449: Fix gnorb-tracking-initialize,
Stefan Monnier <=
- [elpa] externals/gnorb f0cfa7b 191/449: Improvements to gnorb-registry-make-entry, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb bdbc96f 195/449: Rename gnorb-gnus-sending-message-info, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb ca85930 197/449: First draft of trigger action reworking, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 9e880eb 200/449: Improve Gnus summary hinting, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 8a0d275 202/449: Docstring for gnorb-registry-org-id-search, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 6293b22 208/449: Squash with the trigger action stuff, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 326fcb0 210/449: Document new tracking system, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 096e39a 209/449: Remove the capture-to-child/sibling actions for now, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 04d2951 211/449: Shadow message forwarding in nngnorb summary buffers, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb b6ab1c5 214/449: Only use the summary reply hook once., Stefan Monnier, 2020/11/27