[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/gnorb c2f837c 341/449: Improve efficiency of retrieving
From: |
Stefan Monnier |
Subject: |
[elpa] externals/gnorb c2f837c 341/449: Improve efficiency of retrieving tracked messages |
Date: |
Fri, 27 Nov 2020 23:16:07 -0500 (EST) |
branch: externals/gnorb
commit c2f837c3a99f7d75fa59dc9424d98195597dbb21
Author: Eric Abrahamsen <eric@ericabrahamsen.net>
Commit: Eric Abrahamsen <eric@ericabrahamsen.net>
Improve efficiency of retrieving tracked messages
* gnorb-utils.el (gnorb-tracking-initialize): Add a 'artno (article
number) key to information tracked in the registry.
(gnorb-msg-id-to-group): When determining a message's group, save the
verified group and article number information in the registry.
This caches the data for future use. (This whole process was
previously causing a grand total of three server hits per message,
every time, sheesh.)
(gnorb-open-gnus-link): Do the same get-or-get-and-set routine for
article numbers here.
* nngnorb.el (nnir-run-gnorb): Ditto here.
I'm embarrassed to say this only became a priority after I switched to a
remote imap server, and network lags started killing me.
---
gnorb-utils.el | 43 +++++++++++++++++++++++++------------------
nngnorb.el | 31 +++++++++++++++++++------------
2 files changed, 44 insertions(+), 30 deletions(-)
diff --git a/gnorb-utils.el b/gnorb-utils.el
index 723f27b..ec2642e 100644
--- a/gnorb-utils.el
+++ b/gnorb-utils.el
@@ -189,13 +189,16 @@ window."
;; We've probably already bracketed the id, but just in case this is
;; called from elsewhere...
(let* ((id (gnorb-bracket-message-id id))
- (art-no (cdr (gnus-request-head id group)))
(arts (gnus-group-unread group))
- success)
+ artno success)
+ (or (setq artno (car (gnus-registry-get-id-key id 'artno)))
+ (progn
+ (setq artno (cdr (gnus-request-head id group)))
+ (gnus-registry-set-id-key id 'artno (list artno))))
(gnus-activate-group group)
(setq success (gnus-group-read-group arts t group))
(if success
- (gnus-summary-goto-article (or art-no id) nil t)
+ (gnus-summary-goto-article arto nil t)
(signal 'error "Group could not be opened."))))
(defun gnorb-trigger-todo-action (arg &optional id)
@@ -386,24 +389,27 @@ message."
So far we're checking the registry, then the groups in
`gnorb-gnus-sent-groups'. Use search engines? Other clever
methods?"
- (let (candidates server-group)
+ (let (candidates server-group check)
(setq msg-id (gnorb-bracket-message-id msg-id))
(catch 'found
(when gnorb-tracking-enabled
- ;; Make a big list of all the groups where this message might
- ;; conceivably be.
- (setq candidates
- (append (gnus-registry-get-id-key msg-id 'group)
- gnorb-gnus-sent-groups))
- (while (setq server-group (pop candidates))
- (when (and (stringp server-group)
- (not
- (string-match-p
- "\\(nnir\\|nnvirtual\\|UNKNOWN\\)"
- server-group))
- (ignore-errors
- (gnus-request-head msg-id server-group)))
- (throw 'found server-group))))
+ (setq candidates (gnus-registry-get-id-key msg-id 'group))
+ (if (= 1 (length candidates))
+ (throw 'found (car candidates))
+ (setq candidates (append candidates gnorb-gnus-sent-groups))
+ (while (setq server-group (pop candidates))
+ (when (and (stringp server-group)
+ (not
+ (string-match-p
+ "\\(nnir\\|nnvirtual\\|UNKNOWN\\)"
+ server-group)))
+ (setq check
+ (ignore-errors
+ (gnus-request-head msg-id server-group)))
+ (when check
+ (gnus-registry-set-id-key msg-id 'group (list (car check)))
+ (gnus-registry-set-id-key msg-id 'artno (list (cdr check)))
+ (throw 'found (car check)))))))
nil)))
(defun gnorb-collect-ids (&optional id)
@@ -484,6 +490,7 @@ registry be in use, and should be called after the call to
(require 'gnorb-registry)
(with-eval-after-load 'gnus-registry
(add-to-list 'gnus-registry-extra-entries-precious 'gnorb-ids)
+ (add-to-list 'gnus-registry-extra-entries-precious 'artno)
(add-to-list 'gnus-registry-track-extra 'gnorb-ids))
(add-hook
'gnus-started-hook
diff --git a/nngnorb.el b/nngnorb.el
index bb0ddfd..0c1ca35 100644
--- a/nngnorb.el
+++ b/nngnorb.el
@@ -144,26 +144,33 @@ be scanned for gnus messages, and those messages
displayed."
(when rel-msg-id
(setq msg-ids (append (delq nil 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))
+ (dolist (id msg-ids)
+ (let ((link (gnorb-msg-id-to-link id)))
+ (when link
+ (push link links)))))
+ (setq links (sort (delete-dups links) 'string<))
(unless (gnus-alive-p)
(gnus))
(dolist (m links (when vectors
- (nreverse vectors)))
- (let (server-group msg-id result artno)
+ (reverse vectors)))
+ (let (server-group msg-id artno check)
(setq m (org-link-unescape m))
(when (string-match "\\`\\([^#]+\\)\\(#\\(.*\\)\\)?" m)
(setq server-group (match-string 1 m)
msg-id (gnorb-bracket-message-id
(match-string 3 m))
- result (ignore-errors (gnus-request-head msg-id
server-group)))
- (when result
- (setq artno (cdr result))
- (when (and (integerp artno) (> artno 0))
- (push (vector server-group artno 100) vectors)))))))))
+ artno (or (car (gnus-registry-get-id-key msg-id 'artno))
+ (when (setq check
+ (cdr (ignore-errors
+ (gnus-request-head
+ msg-id server-group))))
+ (gnus-registry-set-id-key
+ msg-id 'artno
+ (list check))
+ check)))
+ (when artno
+ (when (and (integerp artno) (> artno 0))
+ (push (vector server-group artno 100) vectors)))))))))
(defvar gnorb-summary-minor-mode-map (make-sparse-keymap)
"Keymap for use in Gnorb's *Summary* minor mode.")
- [elpa] externals/gnorb 9e95e90 387/449: Gnorb: New option gnorb-gnus-tick-all-tracked-messages, (continued)
- [elpa] externals/gnorb 9e95e90 387/449: Gnorb: New option gnorb-gnus-tick-all-tracked-messages, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 09d5487 386/449: New option gnorb-org-log-add-link, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb ed11f5d 399/449: Gnorb: Fix and bump to 1.4.2, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb a3f4fbd 400/449: Gnorb: The proper link type is "mailto", not "mail", Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb ba976d5 401/449: Prefer defalias to fset, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb e8d0043 405/449: Missing a require for seq package, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb cb25e86 406/449: New function gnorb-gnus-search-registry, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 5f885be 398/449: Gnorb: New command for inserting tracked messages; bump to 1.4.1, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 8922fd0 409/449: [gnorb] Fix immediate and inexplicable typos, bump to 1.5.1, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 0c20b7d 397/449: Provide Org tagging for Gnus messages, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb c2f837c 341/449: Improve efficiency of retrieving tracked messages,
Stefan Monnier <=
- [elpa] externals/gnorb 6917948 343/449: Bah, typo, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 47195a6 349/449: Require gnorb-gnus in the gnus-started-hook, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb b892337 356/449: Bump version to 1.1.3, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 5c270cd 357/449: Update NEWS file, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 269a8a8 363/449: New function gnorb-install-defaults, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 27b58a9 364/449: Fix autoloads for BBDB functions, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb d1299d2 388/449: Gnorb: Consolidate all after-capture functions into one, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 6722839 327/449: Formatting improvements, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 8c2fb15 329/449: nngnorb.el: Handle non-existent nnir-tmp-buffer, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 9da022f 366/449: Fix creation of nngnorb/nnir groups, Stefan Monnier, 2020/11/27