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

[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



reply via email to

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