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

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

[elpa] externals/gnorb ec44a6d 182/449: Continue shifting candidate find


From: Stefan Monnier
Subject: [elpa] externals/gnorb ec44a6d 182/449: Continue shifting candidate finding to the registry
Date: Fri, 27 Nov 2020 23:15:35 -0500 (EST)

branch: externals/gnorb
commit ec44a6dd43744bd73eb0511d1d58cc9fbb387b53
Author: Eric Abrahamsen <eric@ericabrahamsen.net>
Commit: Eric Abrahamsen <eric@ericabrahamsen.net>

    Continue shifting candidate finding to the registry
    
    * lisp/gnorb-org.el (gnorb-org-add-id-hash-entry): Move function to
      gnorb-registry.el
      (gnorb-org-populate-id-hash): Move function to gnorb-registry.el
    
    * lisp/gnorb-utils.el (gnorb-msg-id-to-heading-table): Move defvar to
      gnorb-registry.el
    
    * lisp/gnorb-registry.el: Accept all the above
---
 lisp/gnorb-org.el      | 47 --------------------------------------------
 lisp/gnorb-registry.el | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++
 lisp/gnorb-utils.el    |  6 ------
 3 files changed, 53 insertions(+), 53 deletions(-)

diff --git a/lisp/gnorb-org.el b/lisp/gnorb-org.el
index fa08264..36822a5 100644
--- a/lisp/gnorb-org.el
+++ b/lisp/gnorb-org.el
@@ -559,53 +559,6 @@ current heading."
           from cc bcc
           attachments text org-id))))))
 
-(defun gnorb-org-add-id-hash-entry (msg-id &optional marker)
-  (org-with-point-at (or marker (point))
-    (let ((old-val (gethash msg-id gnorb-msg-id-to-heading-table))
-         (new-val (list
-                   (org-id-get-create)
-                   (append
-                    (list
-                     (file-name-nondirectory
-                      (buffer-file-name
-                       (org-base-buffer (current-buffer)))))
-                    (org-get-outline-path)
-                    (list
-                     (org-no-properties
-                      (replace-regexp-in-string
-                       org-bracket-link-regexp
-                       "\\3"
-                       (nth 4 (org-heading-components)))))))))
-      (unless (member (car new-val) old-val)
-       (puthash msg-id
-                (if old-val
-                    (append (list new-val) old-val)
-                  (list new-val))
-                gnorb-msg-id-to-heading-table)))))
-
-(defun gnorb-org-populate-id-hash ()
-  "Scan all agenda files for headings with the
-  `gnorb-org-msg-id-key' property, and construct a hash table of
-  message-ids as keys, and org headings as values -- actually
-  two-element lists representing the heading's id and outline
-  path."
-  ;; where are all the places where we might conceivably want to
-  ;; refresh this?
-  (interactive)
-  (setq gnorb-msg-id-to-heading-table
-       (make-hash-table
-        :test 'equal :size 100))
-  (let (props)
-    (org-map-entries
-     (lambda ()
-       (setq props
-            (org-entry-get-multivalued-property
-             (point) gnorb-org-msg-id-key))
-       (dolist (p props)
-        (gnorb-org-add-id-hash-entry p)))
-     gnorb-org-find-candidates-match
-     'agenda 'archive 'comment)))
-
 ;;; Email subtree
 
 (defcustom gnorb-org-email-subtree-text-parameters nil
diff --git a/lisp/gnorb-registry.el b/lisp/gnorb-registry.el
index ff5e47e..7304a8f 100644
--- a/lisp/gnorb-registry.el
+++ b/lisp/gnorb-registry.el
@@ -55,6 +55,12 @@
   :tag "Gnorb Registry"
   :group 'gnorb)
 
+(defvar gnorb-msg-id-to-heading-table nil
+  "Hash table where keys are message-ids, and values are lists of
+  org headings which have that message-id in their GNORB_MSG_ID
+  property. Values are actually two-element lists: the heading's
+  id, and its outline path.")
+
 (defun gnorb-registry-make-entry (msg-id sender subject org-id group)
   "Create a Gnus registry entry for a message, either received or
 sent. Save the relevant Org ids in the 'gnorb-ids key."
@@ -99,4 +105,51 @@ values in their `gnorb-org-org-msg-id-key' property."
        (setq ret-val (append sub-val ret-val))))
     ret-val))
 
+(defun gnorb-org-add-id-hash-entry (msg-id &optional marker)
+  (org-with-point-at (or marker (point))
+    (let ((old-val (gethash msg-id gnorb-msg-id-to-heading-table))
+         (new-val (list
+                   (org-id-get-create)
+                   (append
+                    (list
+                     (file-name-nondirectory
+                      (buffer-file-name
+                       (org-base-buffer (current-buffer)))))
+                    (org-get-outline-path)
+                    (list
+                     (org-no-properties
+                      (replace-regexp-in-string
+                       org-bracket-link-regexp
+                       "\\3"
+                       (nth 4 (org-heading-components)))))))))
+      (unless (member (car new-val) old-val)
+       (puthash msg-id
+                (if old-val
+                    (append (list new-val) old-val)
+                  (list new-val))
+                gnorb-msg-id-to-heading-table)))))
+
+(defun gnorb-org-populate-id-hash ()
+  "Scan all agenda files for headings with the
+  `gnorb-org-msg-id-key' property, and construct a hash table of
+  message-ids as keys, and org headings as values -- actually
+  two-element lists representing the heading's id and outline
+  path."
+  ;; where are all the places where we might conceivably want to
+  ;; refresh this?
+  (interactive)
+  (setq gnorb-msg-id-to-heading-table
+       (make-hash-table
+        :test 'equal :size 100))
+  (let (props)
+    (org-map-entries
+     (lambda ()
+       (setq props
+            (org-entry-get-multivalued-property
+             (point) gnorb-org-msg-id-key))
+       (dolist (p props)
+        (gnorb-org-add-id-hash-entry p)))
+     gnorb-org-find-candidates-match
+     'agenda 'archive 'comment)))
+
 (provide 'gnorb-registry)
diff --git a/lisp/gnorb-utils.el b/lisp/gnorb-utils.el
index 63d4953..7d598a8 100644
--- a/lisp/gnorb-utils.el
+++ b/lisp/gnorb-utils.el
@@ -66,12 +66,6 @@
 (defvar gnorb-tmp-dir (make-temp-file "emacs-gnorb" t)
   "Temporary directory where attachments etc are saved.")
 
-(defvar gnorb-msg-id-to-heading-table nil
-  "Hash table where keys are message-ids, and values are lists of
-  org headings which have that message-id in their GNORB_MSG_ID
-  property. Values are actually two-element lists: the heading's
-  id, and its outline path.")
-
 (defvar gnorb-message-org-ids nil
   "List of Org heading IDs from the outgoing Gnus message, used
   to mark mail TODOs as done once the message is sent."



reply via email to

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