[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/gnorb a370e64 372/449: Rename msg-id-to-group to msg-id
From: |
Stefan Monnier |
Subject: |
[elpa] externals/gnorb a370e64 372/449: Rename msg-id-to-group to msg-id-request-head, refactor |
Date: |
Fri, 27 Nov 2020 23:16:14 -0500 (EST) |
branch: externals/gnorb
commit a370e64d2813d0273e9784cdb79879bab28d9170
Author: Eric Abrahamsen <eric@ericabrahamsen.net>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>
Rename msg-id-to-group to msg-id-request-head, refactor
* packages/gnorb/gnorb-utils.el (gnorb-msg-id-request-head): Renaming
because it now always calls gnus-request-head, and always returns
the full return value of that call (as well as setting the registry
group key). Callers that don't want to use Gnus to verify
group/article can just access the group key. Also now calls
gnus-activate-group in an attempt to get it to quit querying about
number of articles to get from group.
(gnorb-msg-id-to-link): Change call. This is one of the functions
that might just use the group key instead of doing the full lookup.
* packages/gnorb/nngnorb.el (nnir-run-gnorb): Refactor and simplify.
Now we aren't calling gnus-request-head twice for each message.
---
gnorb-registry.el | 2 +-
gnorb-utils.el | 39 +++++++++++++++++++--------------------
nngnorb.el | 33 +++++++++++----------------------
3 files changed, 31 insertions(+), 43 deletions(-)
diff --git a/gnorb-registry.el b/gnorb-registry.el
index 2b3912c..05f91f5 100644
--- a/gnorb-registry.el
+++ b/gnorb-registry.el
@@ -297,7 +297,7 @@ your Org files."
;; 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))
+ (gnorb-msg-id-request-head p))
(cl-incf count)))))
gnorb-org-find-candidates-match
'agenda 'archive 'comment)
diff --git a/gnorb-utils.el b/gnorb-utils.el
index f4a0aff..ae51a59 100644
--- a/gnorb-utils.el
+++ b/gnorb-utils.el
@@ -488,14 +488,14 @@ and 'gnus."
(defun gnorb-msg-id-to-link (msg-id)
"Given a message id, try to create a full org link to the
message."
- (let ((server-group (gnorb-msg-id-to-group msg-id)))
+ (let ((server-group (car (gnorb-msg-id-request-head msg-id))))
(when server-group
(org-link-escape
(concat server-group "#"
(gnorb-unbracket-message-id msg-id))))))
-(defun gnorb-msg-id-to-group (msg-id)
- "Given a message id, try to find the group it's in.
+(defun gnorb-msg-id-request-head (msg-id)
+ "Given a message id, try to find its group and article number.
So far we're checking the registry, then the groups in
`gnorb-gnus-sent-groups'. Use search engines? Other clever
@@ -504,23 +504,22 @@ methods?"
(setq msg-id (gnorb-bracket-message-id msg-id))
(catch 'found
(when gnorb-tracking-enabled
- (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)
- (string-match-p "+" server-group)
- (not
- (string-match-p
- "\\(nnir\\|nnvirtual\\|UNKNOWN\\)"
- server-group))
- (setq check
- (ignore-errors
- (gnus-request-head msg-id server-group))))
-
- (gnus-registry-set-id-key msg-id 'group (list server-group))
- (throw 'found (car check))))))
+ (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)
+ (string-match-p "+" server-group)
+ (not
+ (string-match-p
+ "\\(nnir\\|nnvirtual\\|UNKNOWN\\)"
+ server-group))
+ (gnus-activate-group server-group)
+ (setq check
+ (ignore-errors
+ (gnus-request-head msg-id server-group))))
+
+ (gnus-registry-set-id-key msg-id 'group (list server-group))
+ (throw 'found (cons server-group (cdr check))))))
nil)))
(defun gnorb-collect-ids (&optional id)
diff --git a/nngnorb.el b/nngnorb.el
index 172dbab..a0e8f8c 100644
--- a/nngnorb.el
+++ b/nngnorb.el
@@ -78,7 +78,7 @@ be scanned for gnus messages, and those messages displayed."
(save-window-excursion
(let ((q (cdr (assq 'query query)))
(buf (get-buffer-create nnir-tmp-buffer))
- msg-ids org-ids links messages vectors)
+ msg-ids org-ids links vectors)
(with-current-buffer buf
(erase-buffer)
(setq nngnorb-attachment-file-list nil))
@@ -139,34 +139,23 @@ be scanned for gnus messages, and those messages
displayed."
(nth 1 (split-string link "#"))))
messages))
+ (unless (gnus-alive-p)
+ (gnus))
+
;; Then use the registry to turn list of org-ids into list of
;; msg-ids.
(dolist (i (delq nil (delete-dups org-ids)))
(when-let ((rel-msg-id (gnorb-registry-org-id-search i)))
(setq msg-ids (append (delq nil rel-msg-id) msg-ids))))
- ;; Then find the group for each msg-id, and add the results to
- ;; messages.
+ ;; Then find the group and article number for each msg-id, and
+ ;; push that onto our return value "vectors".
(when msg-ids
- (dolist (id (delete-dups msg-ids))
- (when-let ((group (gnorb-msg-id-to-group id)))
- (push (list group id) messages))))
-
- (setq messages (sort messages (lambda (l r)
- (string< (car l) (car r)))))
-
- (unless (gnus-alive-p)
- (gnus))
-
- (dolist (m messages (when vectors
- (reverse vectors)))
- (let ((artno
- (cdr-safe (ignore-errors
- (gnus-request-head
- (nth 1 m) (car m))))))
-
- (when (and artno (integerp artno) (> artno 0))
- (push (vector (car m) artno 100) vectors)))))))
+ (dolist (id (delete-dups msg-ids) (when vectors
+ (nreverse vectors)))
+ (pcase-let ((`(,group . ,artno) (gnorb-msg-id-request-head id)))
+ (when (and artno (integerp artno) (> artno 0))
+ (push (vector 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 7ea06f9 339/449: Delete gnorb-prompt-for-bbdb-record, (continued)
- [elpa] externals/gnorb 7ea06f9 339/449: Delete gnorb-prompt-for-bbdb-record, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb e2afc4b 355/449: Switch on lexical binding across the board, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 7d14112 358/449: Trying to fix issue #30., Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb c1014ac 359/449: Merge pull request #31 from berhoel/master, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 64e72d6 360/449: Use :package-version, not :version, on defcustom, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 3090162 361/449: Bump version to 1.1.4, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb c0b3090 362/449: Fix email subtree command, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 6cdf064 365/449: Remove useless use of progn, update usage status function, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 6a3ea57 368/449: Update documentation, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb d61d9b8 370/449: Remove unnecessary with-no-warnings, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb a370e64 372/449: Rename msg-id-to-group to msg-id-request-head, refactor,
Stefan Monnier <=
- [elpa] externals/gnorb 943606f 373/449: Bump Gnorb version to 1.2, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb e7fa2d2 378/449: New copy-message-text behavior, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 8509773 376/449: Don't let the Gnus summary format group create registry entries, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 4b215ae 379/449: gnorb-utils needs macros from nnheader, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 4a732d9 384/449: Tweak text search in gnorb-org-view, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb d304558 383/449: Fix replying to most recent tracked message; bump to 1.3.2, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb b630235 390/449: Gnorb: Tweaks to gnorb-org-extract-mail-tracking, Stefan Monnier, 2020/11/27
- [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