From: Dave Abrahams <dave@boostpro.com>
To: ding@gnus.org
Cc: Dave Abrahams <dave@boostpro.com>
Subject: [PATCH 3/5] Add `gnus-select-group-with-message-id'
Date: Thu, 15 Mar 2012 14:23:11 -0400 [thread overview]
Message-ID: <1331835793-70228-4-git-send-email-dave@boostpro.com> (raw)
In-Reply-To: <1331835793-70228-1-git-send-email-dave@boostpro.com>
---
lisp/gnus-int.el | 43 +++++++++++++++++++++++++++++++++++++++++++
1 files changed, 43 insertions(+), 0 deletions(-)
diff --git a/lisp/gnus-int.el b/lisp/gnus-int.el
index 1190d79..8a00c4a 100644
--- a/lisp/gnus-int.el
+++ b/lisp/gnus-int.el
@@ -533,6 +533,49 @@ If BUFFER, insert the article in that group."
header
(gnus-group-real-name group))))
+(defun gnus-select-group-with-message-id (group message-id)
+ "Activate and select GROUP with the given MESSAGE-ID selected.
+Returns the article number of the message.
+
+If GROUP is not already selected, the message will be the only one in
+the group's summary.
+"
+ ;; TODO: is there a way to know at this point whether the group will
+ ;; be newly-selected? If so we could clean up the logic at the end
+ ;;
+ ;; save the new group's display parameter, if any, so we
+ ;; can replace it temporarily with zero.
+ (let ((saved-display
+ (gnus-group-get-parameter group 'display :allow-list)))
+
+ ;; Tell gnus we really don't want any articles
+ (gnus-group-set-parameter group 'display 0)
+
+ (unwind-protect
+ (gnus-summary-read-group-1
+ group (not :show-all) :no-article (not :kill-buffer)
+ ;; The combination of no-display and this dummy list of
+ ;; articles to select somehow makes it possible to open a
+ ;; group with no articles in it. Black magic.
+ :no-display '(-1); select-articles
+ )
+ ;; Restore the new group's display parameter
+ (gnus-group-set-parameter group 'display saved-display)))
+
+ ;; The summary buffer was suppressed by :no-display above.
+ ;; Create it now and insert the message
+ (let ((group-is-new (gnus-summary-setup-buffer group)))
+ (condition-case err
+ (let ((article-number
+ (gnus-summary-insert-subject message-id)))
+ (unless article-number
+ (signal 'error "message-id not in group"))
+ (gnus-summary-select-article nil nil nil article-number)
+ article-number)
+ ;; Clean up the new summary and propagate the error
+ (error (when group-is-new (gnus-summary-exit))
+ (apply 'signal err)))))
+
(defun gnus-warp-to-article ()
"Warps from an article in a virtual group to the article in its
real group. Does nothing on a real group."
--
1.7.5.4
next prev parent reply other threads:[~2012-03-15 18:23 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-15 18:23 [PATCH 0/5] *** Resubmit: Warping via the registry *** Dave Abrahams
2012-03-15 18:23 ` [PATCH 1/5] Allow gnus-summary-insert-subject to work in empty groups Dave Abrahams
2012-03-15 18:23 ` [PATCH 2/5] Record information in the registry about each article retrieved Dave Abrahams
2012-03-15 18:23 ` Dave Abrahams [this message]
2012-03-15 18:23 ` [PATCH 4/5] Add `gnus-try-warping-via-registry()' Dave Abrahams
2012-03-15 18:23 ` [PATCH 5/5] Enable registry-warping as a fallback if warping via the current backend fails Dave Abrahams
2012-03-19 17:05 ` [PATCH 0/5] *** Resubmit: Warping via the registry *** Ted Zlatanov
2012-03-22 20:59 ` Lars Magne Ingebrigtsen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1331835793-70228-4-git-send-email-dave@boostpro.com \
--to=dave@boostpro.com \
--cc=ding@gnus.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).