[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/gnorb 81fed4b 193/449: Helper function for transitionin
From: |
Stefan Monnier |
Subject: |
[elpa] externals/gnorb 81fed4b 193/449: Helper function for transitioning to the new system |
Date: |
Fri, 27 Nov 2020 23:15:37 -0500 (EST) |
branch: externals/gnorb
commit 81fed4bb29756b2a2fdafc8b1714434e886a9ffc
Author: Eric Abrahamsen <eric@ericabrahamsen.net>
Commit: Eric Abrahamsen <eric@ericabrahamsen.net>
Helper function for transitioning to the new system
* lisp/gnorb-registry.el (gnorb-registry-transition-from-props):
Single-use function for going through all org files and transitioning
from GNORB_MSG_ID-based tracking to the registry. See docstring.
---
lisp/gnorb-registry.el | 61 +++++++++++++++++++++++++++++++++++++++++++++-----
1 file changed, 55 insertions(+), 6 deletions(-)
diff --git a/lisp/gnorb-registry.el b/lisp/gnorb-registry.el
index b590b87..bf24ced 100644
--- a/lisp/gnorb-registry.el
+++ b/lisp/gnorb-registry.el
@@ -126,14 +126,63 @@ ids for headings that are relevant to that message."
(defun gnorb-registry-org-id-search (id)
(registry-search gnus-registry-db :member `((gnorb-ids ,id))))
+(defun gnorb-registry-transition-from-props (arg)
+ "Helper function for transitioning the old tracking system to the new.
+
+The old system relied on storing sent message ids on relevant Org
+headings, in the `gnorb-org-msg-id-key' property. The new system
+uses the gnus registry to track relations between messages and
+Org headings. This function will go through your agenda files,
+find headings that have the `gnorb-org-msg-id-key' property set,
+and create new registry entries that reflect that connection.
+
+Call with a prefix arg to additionally delete the
+`gnorb-org-msg-id-key' altogether from your Org headings. As this
+function will not create duplicate registry entries, it's safe to
+run it once with no prefix arg, to keep the properties in place,
+and then once you're sure everything's working okay, run it again
+with a prefix arg, to clean the Gnorb-specific properties from
+your Org files."
+ (interactive "P")
+ (let ((count 0))
+ (message "Collecting all relevant Org headings, this could take a
while...")
(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)))
+ (let ((id (org-id-get))
+ (props (org-entry-get-multivalued-property
+ (point) gnorb-org-msg-id-key))
+ links group id)
+ (when props
+ ;; If the property is set, we should probably assume that any
+ ;; Gnus links in the subtree are relevant, and should also be
+ ;; collected and associated.
+ (setq links (gnorb-scan-links
+ (org-element-property :end (org-element-at-point))
+ 'gnus))
+ (dolist (l (plist-get links :gnus))
+ (gnorb-registry-make-entry
+ (second (split-string l "#")) nil nil
+ id (first (split-string l "#"))))
+ (dolist (p props)
+ (setq id )
+ (gnorb-registry-make-entry p nil nil id nil)
+ ;; This function will try to find the group for the message
+ ;; and set that value on the registry entry if it can find
+ ;; it.
+ (unless (gnus-registry-get-id-key p 'group)
+ (gnorb-msg-id-to-group p))
+ (incf count)))))
gnorb-org-find-candidates-match
- 'agenda 'archive 'comment)))
+ 'agenda 'archive 'comment)
+ (message "Collecting all relevant Org headings, this could take a while...
done")
+ ;; Delete the properties if the user has asked us to do so.
+ (if (eq arg '(4))
+ (progn
+ (dolist (f (org-agenda-files))
+ (with-current-buffer (get-file-buffer f)
+ (org-delete-property-globally gnorb-org-msg-id-key)))
+ (message "%d entries created; all Gnorb-specific properties deleted."
+ count))
+ (message "%d entries created." count))))
(provide 'gnorb-registry)
- [elpa] externals/gnorb 0255247 133/449: Only notice records on message receipt, not sending, (continued)
- [elpa] externals/gnorb 0255247 133/449: Only notice records on message receipt, not sending, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb b70d845 168/449: Handle nil group values in registry entries, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 880afd6 158/449: Register sent messages so we can view them later, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 25aa0f1 173/449: Use a marker in conjunction with window conf, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb e1129e9 170/449: Fix problems when BBDB is not present and gnorb-bbdb is not loaded., Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 5f96b98 167/449: Stupid typo, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 9a2f747 175/449: Don't hint messages in nnir or virtual summaries, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb ec44a6d 182/449: Continue shifting candidate finding to the registry, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 927e401 184/449: New function for restoring window layout, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb a352586 189/449: Improve lookups for entries with unknown groups, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 81fed4b 193/449: Helper function for transitioning to the new system,
Stefan Monnier <=
- [elpa] externals/gnorb d7327b5 192/449: The big switch! Rely only on registry for tracking, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 7ba1786 196/449: Use gnorb-gnus-message-info for incoming and outgoing, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 0cb4d1a 201/449: Docstring for gnorb-scan-links, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 5c9ef6e 203/449: Don't create Org IDs when scanning for mails, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 9ac84b7 218/449: Return links in the order which they were found, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb a9535ae 223/449: Merge branch 'registry', Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb dd4e013 225/449: Restore action shouldn't quit summary buffer, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 08e0742 229/449: Empty News and gnorb.texi files, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb bcfd501 236/449: gitignore Elpa-generated stuff, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 55a630d 238/449: Gnus hinting needs to check in-reply-to as well, Stefan Monnier, 2020/11/27