[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 72bc6cd 4/5: Rename msg-id-to-group to msg-id-request-head
From: |
Eric Abrahamsen |
Subject: |
[elpa] master 72bc6cd 4/5: Rename msg-id-to-group to msg-id-request-head, refactor |
Date: |
Tue, 21 Mar 2017 15:59:24 -0400 (EDT) |
branch: master
commit 72bc6cd06d6285a231b003edc8f78d5036aae5a2
Author: Eric Abrahamsen <address@hidden>
Commit: Eric Abrahamsen <address@hidden>
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.
---
packages/gnorb/gnorb-registry.el | 2 +-
packages/gnorb/gnorb-utils.el | 39 +++++++++++++++++++--------------------
packages/gnorb/nngnorb.el | 33 +++++++++++----------------------
3 files changed, 31 insertions(+), 43 deletions(-)
diff --git a/packages/gnorb/gnorb-registry.el b/packages/gnorb/gnorb-registry.el
index 7c9f687..5acb793 100644
--- a/packages/gnorb/gnorb-registry.el
+++ b/packages/gnorb/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/packages/gnorb/gnorb-utils.el b/packages/gnorb/gnorb-utils.el
index 9352d34..9d10ad4 100644
--- a/packages/gnorb/gnorb-utils.el
+++ b/packages/gnorb/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/packages/gnorb/nngnorb.el b/packages/gnorb/nngnorb.el
index 172dbab..a0e8f8c 100644
--- a/packages/gnorb/nngnorb.el
+++ b/packages/gnorb/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] master updated (32329b4 -> e0f0dac), Eric Abrahamsen, 2017/03/21
- [elpa] master cbbee0b 1/5: Fix nnir search routine, Eric Abrahamsen, 2017/03/21
- [elpa] master cb87b09 2/5: Remove unnecessary with-no-warnings, Eric Abrahamsen, 2017/03/21
- [elpa] master 014466a 3/5: Update Gnus summary article line after trigger process, Eric Abrahamsen, 2017/03/21
- [elpa] master e0f0dac 5/5: Bump Gnorb version to 1.2, Eric Abrahamsen, 2017/03/21
- [elpa] master 72bc6cd 4/5: Rename msg-id-to-group to msg-id-request-head, refactor,
Eric Abrahamsen <=