From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/80256 Path: news.gmane.org!not-for-mail From: Dave Abrahams Newsgroups: gmane.emacs.gnus.general Subject: [PATCH 3/6] Add `gnus-select-group-with-message-id' Date: Sun, 9 Oct 2011 00:11:24 -0400 Message-ID: <1318133487-45386-4-git-send-email-dave@boostpro.com> References: <1318133487-45386-1-git-send-email-dave@boostpro.com> NNTP-Posting-Host: lo.gmane.org X-Trace: dough.gmane.org 1318133550 5808 80.91.229.12 (9 Oct 2011 04:12:30 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 9 Oct 2011 04:12:30 +0000 (UTC) Cc: Dave Abrahams To: ding@gnus.org Original-X-From: ding-owner+M28541@lists.math.uh.edu Sun Oct 09 06:12:20 2011 Return-path: Envelope-to: ding-account@gmane.org Original-Received: from util0.math.uh.edu ([129.7.128.18]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1RCkkN-00068j-Oy for ding-account@gmane.org; Sun, 09 Oct 2011 06:12:20 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.math.uh.edu) by util0.math.uh.edu with smtp (Exim 4.63) (envelope-from ) id 1RCkjy-0003tc-07; Sat, 08 Oct 2011 23:11:54 -0500 Original-Received: from mx1.math.uh.edu ([129.7.128.32]) by util0.math.uh.edu with esmtps (TLSv1:AES256-SHA:256) (Exim 4.63) (envelope-from ) id 1RCkju-0003sw-IS for ding@lists.math.uh.edu; Sat, 08 Oct 2011 23:11:50 -0500 Original-Received: from quimby.gnus.org ([80.91.231.51]) by mx1.math.uh.edu with esmtps (TLSv1:AES256-SHA:256) (Exim 4.76) (envelope-from ) id 1RCkjj-0003x1-RU for ding@lists.math.uh.edu; Sat, 08 Oct 2011 23:11:49 -0500 Original-Received: from mail-vx0-f172.google.com ([209.85.220.172]) by quimby.gnus.org with esmtp (Exim 4.72) (envelope-from ) id 1RCkji-0005pX-BT for ding@gnus.org; Sun, 09 Oct 2011 06:11:38 +0200 Original-Received: by vcbfo11 with SMTP id fo11so6298251vcb.17 for ; Sat, 08 Oct 2011 21:11:32 -0700 (PDT) Original-Received: by 10.52.34.196 with SMTP id b4mr8520742vdj.131.1318133492507; Sat, 08 Oct 2011 21:11:32 -0700 (PDT) Original-Received: from pluto.luannocracy.com (207-172-223-249.c3-0.smr-ubr3.sbo-smr.ma.static.cable.rcn.com. [207.172.223.249]) by mx.google.com with ESMTPS id v8sm14099061vdg.22.2011.10.08.21.11.30 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 08 Oct 2011 21:11:30 -0700 (PDT) Original-Received: by pluto.luannocracy.com (Postfix, from userid 501) id F404A10AD629; Sun, 9 Oct 2011 00:11:29 -0400 (EDT) X-Mailer: git-send-email 1.7.6.1 In-Reply-To: <1318133487-45386-1-git-send-email-dave@boostpro.com> X-Spam-Score: -2.9 (--) List-ID: Precedence: bulk Xref: news.gmane.org gmane.emacs.gnus.general:80256 Archived-At: --- 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 2e10263..048f442 100644 --- a/lisp/gnus-int.el +++ b/lisp/gnus-int.el @@ -531,6 +531,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.6.1