From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/81610 Path: news.gmane.org!not-for-mail From: Dave Abrahams Newsgroups: gmane.emacs.gnus.general Subject: [PATCH 3/5] Add `gnus-select-group-with-message-id' Date: Thu, 15 Mar 2012 14:23:11 -0400 Message-ID: <1331835793-70228-4-git-send-email-dave@boostpro.com> References: <1331835793-70228-1-git-send-email-dave@boostpro.com> NNTP-Posting-Host: plane.gmane.org X-Trace: dough.gmane.org 1331835934 18866 80.91.229.3 (15 Mar 2012 18:25:34 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 15 Mar 2012 18:25:34 +0000 (UTC) Cc: Dave Abrahams To: ding@gnus.org Original-X-From: ding-owner+M29890@lists.math.uh.edu Thu Mar 15 19:25:29 2012 Return-path: Envelope-to: ding-account@gmane.org Original-Received: from util0.math.uh.edu ([129.7.128.18]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1S8FMX-0008U0-T2 for ding-account@gmane.org; Thu, 15 Mar 2012 19:25:22 +0100 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 1S8FLe-0003gT-Ch; Thu, 15 Mar 2012 13:24:26 -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 1S8FLc-0003g7-9o for ding@lists.math.uh.edu; Thu, 15 Mar 2012 13:24:24 -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 1S8FLO-0006nE-0z for ding@lists.math.uh.edu; Thu, 15 Mar 2012 13:24:24 -0500 Original-Received: from mail-qc0-f172.google.com ([209.85.216.172]) by quimby.gnus.org with esmtp (Exim 4.72) (envelope-from ) id 1S8FLM-0000gg-Fe for ding@gnus.org; Thu, 15 Mar 2012 19:24:08 +0100 Original-Received: by qcsq13 with SMTP id q13so93600qcs.17 for ; Thu, 15 Mar 2012 11:24:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=xlFWFsA0Bg8NN2OeJIFfP2YdVmnQs7X3NnTITqi3r5k=; b=cbQNpfkLjSDIRlcMPT4+OydV/gxufGYfAW4Fqd+wCCag19PV25RAPTFR1Hsqw7f/Sw +XhKYHvSM42t72B10amEOwhYyp9RDJD38AGzxBNf9jXBfaGncp8TZUShytSs57yorZP7 Q/5+xgyAMVg6HChDdIcHM6wPxFNYHSowKAc/qe/cVhM60qy19n9Kuk69hEQp8RJr1slV rl4fgog/ee+h8e0PCUa5nlkWcDTZS6FWmFhMx8V2p/KAbPZiU3tn8PwqNpt01qLtGRKH 5Jg2m2ytMxjDYxZlS54zf960meHWD8/kDY/VBItjLzOWWJYUaV4xKkj93ZOoZLBKCCTA YEdw== Original-Received: by 10.229.78.215 with SMTP id m23mr2656545qck.93.1331835842580; Thu, 15 Mar 2012 11:24:02 -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 z6sm5378736qap.17.2012.03.15.11.24.01 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 15 Mar 2012 11:24:01 -0700 (PDT) X-Mailer: git-send-email 1.7.9.2 In-Reply-To: <1331835793-70228-1-git-send-email-dave@boostpro.com> X-Gm-Message-State: ALoCoQnm/cAQE3RMyaD9oLgj1JO8HBUW72iFFTUty5AYgXPbkzGqsX4X8I/EhWcsdZYr3Bt2Y3ib X-Spam-Score: -2.9 (--) List-ID: Precedence: bulk Xref: news.gmane.org gmane.emacs.gnus.general:81610 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 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