Gnus development mailing list
 help / color / mirror / Atom feed
From: Dave Abrahams <dave@boostpro.com>
To: ding@gnus.org
Cc: Dave Abrahams <dave@boostpro.com>
Subject: [PATCH 4/6] Add `gnus-try-warping-via-registry()'
Date: Sun,  9 Oct 2011 00:11:25 -0400	[thread overview]
Message-ID: <1318133487-45386-5-git-send-email-dave@boostpro.com> (raw)
In-Reply-To: <1318133487-45386-1-git-send-email-dave@boostpro.com>

The new function attempts to warp to the article based on group
information stored for the article in the registry.
---
 lisp/gnus-int.el |   50 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 50 insertions(+), 0 deletions(-)

diff --git a/lisp/gnus-int.el b/lisp/gnus-int.el
index 048f442..e241689 100644
--- a/lisp/gnus-int.el
+++ b/lisp/gnus-int.el
@@ -574,6 +574,56 @@ the group's summary.
       (error (when group-is-new (gnus-summary-exit))
              (apply 'signal err)))))
 
+(defun gnus-simplify-group-name (group)
+  "Return the simplest representation of the name of GROUP.
+This is the string that Gnus uses to identify the group."
+  (gnus-group-prefixed-name
+   (gnus-group-real-name group)
+   (gnus-group-method group)))
+
+;; largely based on nnir-warp-to-article
+(defun gnus-try-warping-via-registry ()
+  "Attempt to warp to the current article's source group based on
+data stored in the registry."
+  (interactive)
+  (when (gnus-summary-article-header)
+    (let* ((message-id (mail-header-id (gnus-summary-article-header)))
+           ;; Retrieve the message's group(s) from the registry
+           (groups (gnus-registry-get-id-key message-id 'group))
+           ;; If starting from an ephemeral group, this describes
+           ;; how to restore the window configuration
+           (quit-config
+            (gnus-ephemeral-group-p gnus-newsgroup-name))
+           (seen-groups (list (gnus-group-group-name))))
+
+      (catch 'found
+        (dolist (group (mapcar 'gnus-simplify-group-name groups))
+
+          ;; skip over any groups we really don't want to warp to.
+          (unless (or (member group seen-groups)
+                      (gnus-ephemeral-group-p group)          ;; any ephemeral group
+                      (memq (car (gnus-find-method-for-group group))
+                            '(nnir))) ;; Specific methods; this list may need to expand.
+
+            ;; remember that we've seen this group already
+            (push group seen-groups)
+
+            ;; first exit from any ephemeral summary buffer.
+            (when quit-config
+              (gnus-summary-exit)
+              ;; and if the ephemeral summary buffer in turn came from another
+              ;; summary buffer we have to clean that summary up too.
+              (when (eq (cdr quit-config) 'summary)
+                (gnus-summary-exit))
+              ;; remember that we've already done this part
+              (setq quit-config nil))
+
+            ;; Try to activate the group.  If that fails, just move
+            ;; along.  We may have more groups to work with
+            (ignore-errors
+                (gnus-select-group-with-message-id group message-id))
+            (throw 'found t)))))))
+
 (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




  parent reply	other threads:[~2011-10-09  4:11 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-09  4:11 Patch Series: Warping via the registry Dave Abrahams
2011-10-09  4:11 ` [PATCH 1/6] Allow gnus-summary-insert-subject to work in empty groups Dave Abrahams
2011-10-09  4:11 ` [PATCH 2/6] Record information in the registry about each article retrieved Dave Abrahams
2011-10-09  4:11 ` [PATCH 3/6] Add `gnus-select-group-with-message-id' Dave Abrahams
2011-10-09  4:11 ` Dave Abrahams [this message]
2011-10-09  4:11 ` [PATCH 5/6] Enable registry-warping as a fallback if warping via the current backend fails Dave Abrahams
2011-10-09  4:11 ` [PATCH 6/6] Use `gnus-registry-enabled' instead of `gnus-registry-install' Dave Abrahams
2011-10-10 23:09 ` Patch Series: Warping via the registry Andy Moreton
2011-10-11  1:44   ` Dave Abrahams
2011-10-12 14:48     ` *bump* (was: Patch Series: Warping via the registry) Dave Abrahams
2011-10-12 23:38       ` *bump* Ted Zlatanov
2011-10-16 12:02       ` *bump* again Dave Abrahams
2011-11-03 22:56         ` Lars Magne Ingebrigtsen
2011-11-04  0:23           ` Dave Abrahams
2011-11-04  8:36             ` Steinar Bang
2011-11-04 11:26               ` Steinar Bang
2011-11-04 12:35               ` Gnus Git branching strategy for Emacs sync (was: *bump* again) Ted Zlatanov
2011-11-04 15:30               ` *bump* again Dave Abrahams
2011-11-04 16:07                 ` Steinar Bang
2011-11-05  5:13                   ` Dave Abrahams
2011-11-05 10:09                     ` John Wiegley
2011-11-04 12:26             ` Ted Zlatanov
2011-10-12 15:04     ` Patch Series: Warping via the registry Andy Moreton

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=1318133487-45386-5-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).