[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/gnorb fe7d814 179/449: Provide initialization of gnorb
From: |
Stefan Monnier |
Subject: |
[elpa] externals/gnorb fe7d814 179/449: Provide initialization of gnorb email tracking |
Date: |
Fri, 27 Nov 2020 23:15:34 -0500 (EST) |
branch: externals/gnorb
commit fe7d814ed1c8e2ae554c7ef5f06548cc7e4d1279
Author: Eric Abrahamsen <eric@ericabrahamsen.net>
Commit: Eric Abrahamsen <eric@ericabrahamsen.net>
Provide initialization of gnorb email tracking
Registry based email tracking now must be explicitly started by calling
`gnorb-tracking-initialize'. That sets the `gnorb-tracking-enabled'
variable to t, and hooks into various actions.
* lisp/gnorb-utils.el (gnorb-tracking-enabled): New internal variable.
(gnorb-tracking-initialize): New function
* lisp/gnorb-registry.el (gnorb-registry-make-entry): Check
`gnorb-tracking-enabled' instead of `gnus-registry-enabled'
(gnorb-registry-capture): New function, replacement for
`gnorb-gnus-capture-registry'.
* lisp/gnorb-gnus.el (gnorb-gnus-capture-registry): Delete function.
Remove addition of 'gnorb-ids to
`gnus-registry-extra-entries-precious', do this in the initialize
function instead.
---
lisp/gnorb-gnus.el | 28 ----------------------------
lisp/gnorb-registry.el | 18 +++++++++++++++++-
lisp/gnorb-utils.el | 20 +++++++++++++++++++-
3 files changed, 36 insertions(+), 30 deletions(-)
diff --git a/lisp/gnorb-gnus.el b/lisp/gnorb-gnus.el
index f6e3630..4e604cb 100644
--- a/lisp/gnorb-gnus.el
+++ b/lisp/gnorb-gnus.el
@@ -31,13 +31,6 @@
(declare-function org-gnus-follow-link "org-gnus"
(group article))
-;; This prevents gnorb-related registry entries from being pruned.
-;; Probably we should provide for some backup pruning routine, so we
-;; don't stuff up the whole registry.
-(eval-after-load "gnus-registry"
- '(when gnus-registry-enabled
- (add-to-list 'gnus-registry-extra-entries-precious 'gnorb-ids)))
-
(defgroup gnorb-gnus nil
"The Gnus bits of Gnorb."
:tag "Gnorb Gnus"
@@ -240,27 +233,6 @@ save them into `gnorb-tmp-dir'."
;;; Storing, removing, and acting on Org headers in messages.
-(defun gnorb-gnus-capture-registry ()
- "When capturing from a gnus message, add our new org heading id
-to the message's registry entry, under the 'gnorb-ids key."
- (when (and (with-current-buffer
- (org-capture-get :original-buffer)
- (memq major-mode '(gnus-summary-mode gnus-article-mode)))
- (not org-note-abort)
- gnus-registry-enabled)
- (let* ((msg-id
- (concat "<" (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)))
- (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))))
-
-(add-hook 'org-capture-prepare-finalize-hook
- 'gnorb-gnus-capture-registry)
-
(defvar gnorb-gnus-sending-message-info nil
"Place to store the To, Subject, Date, and Message-ID headers
of the currently-sending or last-sent message.")
diff --git a/lisp/gnorb-registry.el b/lisp/gnorb-registry.el
index 09998bd..8b47dcb 100644
--- a/lisp/gnorb-registry.el
+++ b/lisp/gnorb-registry.el
@@ -60,7 +60,7 @@
sent. Save the relevant Org ids in the 'gnorb-ids key."
;; This set-id-key stuff is actually horribly
;; inefficient.
- (when gnus-registry-enabled
+ (when gnorb-tracking-enabled
(gnus-registry-get-or-make-entry msg-id)
(gnus-registry-set-id-key msg-id 'sender (list sender))
(gnus-registry-set-id-key msg-id 'subject (list subject))
@@ -69,5 +69,21 @@ sent. Save the relevant Org ids in the 'gnorb-ids key."
org-id))
(gnus-registry-set-id-key msg-id 'group (list group))))
+(defun gnorb-registry-capture ()
+ "When capturing from a Gnus message, add our new Org heading id
+to the message's registry entry, under the 'gnorb-ids key."
+ (when (and (with-current-buffer
+ (org-capture-get :original-buffer)
+ (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) ">"))
+ (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)))
+ (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))))
(provide 'gnorb-registry)
diff --git a/lisp/gnorb-utils.el b/lisp/gnorb-utils.el
index ac33368..63d4953 100644
--- a/lisp/gnorb-utils.el
+++ b/lisp/gnorb-utils.el
@@ -234,7 +234,7 @@ is in use. Other search engines? Other clever methods?"
;; will notice them and add their group key.
(let (server-group)
(catch 'found
- (when gnus-registry-enabled
+ (when gnorb-tracking-enabled
;; The following is a cheap knock-off of
;; `gnus-try-warping-via-registry'. I can't use that, though,
;; because it isn't low-level enough -- it starts with a
@@ -256,5 +256,23 @@ is in use. Other search engines? Other clever methods?"
t)) ;; Is this even feasible? I suspect not.
server-group))
+;; Loading the registry
+
+(defvar gnorb-tracking-enabled nil
+ "Internal flag indicating whether Gnorb is successfully plugged
+ into the registry or not.")
+
+(defun gnorb-tracking-initialize ()
+ "Start using the Gnus registry to track correspondences between
+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))
+
(provide 'gnorb-utils)
;;; gnorb-utils.el ends here
- [elpa] externals/gnorb 5101731 150/449: Improvements to TODOs made from outgoing messages, (continued)
- [elpa] externals/gnorb 5101731 150/449: Improvements to TODOs made from outgoing messages, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb b841d17 146/449: Wishlist changes, Stefan Monnier, 2020/11/27
- [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 <=
- [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, 2020/11/27
- [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