[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/gnorb 7b70966 190/449: Look up tracked messages via the
From: |
Stefan Monnier |
Subject: |
[elpa] externals/gnorb 7b70966 190/449: Look up tracked messages via the registry |
Date: |
Fri, 27 Nov 2020 23:15:36 -0500 (EST) |
branch: externals/gnorb
commit 7b70966a61c9bb906af9bc3e8b757f8ade6a6555
Author: Eric Abrahamsen <eric@ericabrahamsen.net>
Commit: Eric Abrahamsen <eric@ericabrahamsen.net>
Look up tracked messages via the registry
* lisp/gnorb-registry.el (gnorb-registry-org-id-search): Wrapper for
`registry-lookup-secondary-value`: We feed it an org id, and it gives
us relevant message ids.
* lisp/nngnorb.el (nnir-run-gnorb): Use this ability when creating nnir
summary buffers from org searches. For now we're both scanning the
registry, and searching for links and GNORB_MSG_ID props. We'll
probably always search for links, but the props search will get
dropped eventually.
---
lisp/gnorb-registry.el | 3 +++
lisp/nngnorb.el | 55 +++++++++++++++++++++++++++++++++-----------------
2 files changed, 40 insertions(+), 18 deletions(-)
diff --git a/lisp/gnorb-registry.el b/lisp/gnorb-registry.el
index 3c4da22..a6c7e05 100644
--- a/lisp/gnorb-registry.el
+++ b/lisp/gnorb-registry.el
@@ -163,6 +163,9 @@ values in their `gnorb-org-org-msg-id-key' property."
(make-hash-table
:test 'equal :size 100))
(let (props)
+(defun gnorb-registry-org-id-search (id)
+ (registry-search gnus-registry-db :member `((gnorb-ids ,id))))
+
(org-map-entries
(lambda ()
(setq props
diff --git a/lisp/nngnorb.el b/lisp/nngnorb.el
index 70b3a88..d680278 100644
--- a/lisp/nngnorb.el
+++ b/lisp/nngnorb.el
@@ -61,16 +61,21 @@ different things. First is the ID string of an Org heading,
prefixed with \"id+\". This was probably a bad choice as it could
conceivably look like an org tags search string. Fix that later.
If it's an ID, then the entire subtree text of that heading is
-scanned for gnus links, and all the linked messages are displayed
-in an ephemeral group.
+scanned for gnus links, and the messages relevant to the subtree
+are collected from the registry, and all the resulting messages
+are displayed in an ephemeral group.
Otherwise, the query string can be a tags match string, a la the
Org agenda tags search. All headings matched by this string will
be scanned for gnus messages, and those messages displayed."
+ ;; During the transition period between using message-ids stored in
+ ;; a property, and the new registry-based system, we're going to use
+ ;; both methods to collect relevant messages. This could be a little
+ ;; slower, but for the time being it will be safer.
(save-excursion
(let ((q (cdr (assq 'query query)))
(buf (get-buffer-create nnir-tmp-buffer))
- links vectors)
+ msg-ids org-ids links vectors)
(with-current-buffer buf
(erase-buffer))
(when (equal "5.13" gnus-version-number)
@@ -82,7 +87,15 @@ be scanned for gnus messages, and those messages displayed."
buf
(point)
(org-element-property
- :end (org-element-at-point)))))
+ :end (org-element-at-point)))
+ (save-restriction
+ (org-narrow-to-subtree)
+ (setq org-ids
+ (append
+ (org-element-map (org-element-parse-buffer)
+ 'headline
+ (lambda (hl) (org-element-property :ID hl)))
+ org-ids)))))
((listp q)
;; be a little careful: this could be a list of links, or
;; it could be the full plist
@@ -91,6 +104,7 @@ be scanned for gnus messages, and those messages displayed."
q)))
(t (org-map-entries
(lambda ()
+ (push (org-id-get-create) org-ids)
(append-to-buffer
buf
(point)
@@ -100,20 +114,25 @@ be scanned for gnus messages, and those messages
displayed."
q
'agenda)))
(with-current-buffer buf
- (let (ids)
- (goto-char (point-min))
- (setq links (plist-get (gnorb-scan-links (point-max) 'gnus)
- :gnus))
- (goto-char (point-min))
- (while (re-search-forward
- (concat ":" gnorb-org-msg-id-key ": \\([^\n]+\\)")
- (point-max) t)
- (setq ids (append (split-string (match-string 1)) ids)))
- (when ids
- (dolist (id ids)
- (let ((link (gnorb-msg-id-to-link id)))
- (when link
- (push link links)))))))
+ (goto-char (point-min))
+ (setq links (plist-get (gnorb-scan-links (point-max) 'gnus)
+ :gnus))
+ (goto-char (point-min))
+ (while (re-search-forward
+ (concat ":" gnorb-org-msg-id-key ": \\([^\n]+\\)")
+ (point-max) t)
+ (setq msg-ids (append (split-string (match-string 1)) msg-ids))))
+ ;; Here's where we maybe do some duplicate work using the
+ ;; registry. Take our org ids and find all relevant message ids.
+ (dolist (i (delq nil org-ids))
+ (let ((rel-msg-id (gnorb-registry-org-id-search i)))
+ (when rel-msg-id
+ (setq msg-ids (append rel-msg-id msg-ids)))))
+ (when msg-ids
+ (dolist (id msg-ids)
+ (let ((link (gnorb-msg-id-to-link id)))
+ (when link
+ (push link links)))))
(setq links (delete-dups links))
(unless (gnus-alive-p)
(gnus))
- [elpa] externals/gnorb ade7ee8 163/449: Make hash entries for new sent-message TODOs, (continued)
- [elpa] externals/gnorb ade7ee8 163/449: Make hash entries for new sent-message TODOs, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 4d584f1 171/449: Require gnorb-bbdb when popping up bbdb buffer, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 260161b 159/449: Check registry-enabled only after registry is loaded, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb f1545cd 162/449: Don't add a 'group key to registry if no group, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb d04bf53 178/449: Rename/move the registry-entry function, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 452a3f0 177/449: Basic skeleton of registry usage, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb eaa4bf4 181/449: Begin shifting candidate finding to the registry, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 7f4dbed 180/449: Don't check for relevant headings if not tracking, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 093c4ed 185/449: Spurious 'g', Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 8121bf5 188/449: Stop creating hash table entries and GNORB_MSG_IDS, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 7b70966 190/449: Look up tracked messages via the registry,
Stefan Monnier <=
- [elpa] externals/gnorb 5ba511e 198/449: Dispense with the "insert a link" message, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 05e6a02 204/449: Docstring for gnorb-msg-id-to-link, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 4f302fa 205/449: New gnorb-collect-ids utility function, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 01e7b1e 206/449: New minor mode for nnir summary buffers, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 69ddfd3 212/449: Delete duplicate org-ids for outgoing messages, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 36303d9 213/449: Do a better job of dealing with reference headers, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 01645a4 215/449: Allowing fetching attachments from specific IDs, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 305a704 216/449: Don't append the message-exit-action, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb d0d196f 222/449: Check prefix arg correctly, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 9a76fad 226/449: Use org-element-interpret-data to get paragraph text, Stefan Monnier, 2020/11/27