Gnus development mailing list
 help / color / mirror / Atom feed
From: Antoine Levitt <antoine.levitt@gmail.com>
To: ding@gnus.org
Subject: gnus-group-list-ticked
Date: Thu, 17 Mar 2011 18:42:05 +0100	[thread overview]
Message-ID: <87aagtr6du.fsf@gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1059 bytes --]

Hi,

gnus-group has functions to list groups with dormant or cached articles,
but not ticked. That might be useful for some setups (for instance, I
have gnus-list-groups-with-ticked-articles set to nil and periodically
check my ticked messages with this), or just to look at groups with
ticked articles, and not unread ones. The following patch does just
that, and provides a binding for it. It's a trivial copy/paste from
gnus-group-list-dormant and -cached. There didn't seem to be much point
in abstracting the code out of these functions, since there are simple
wrappers around gnus-group-prepare-function.

Speaking of which, the interface in gnus-group-prepare-function is
slightly different than the one in gnus-group-prepare-flat, and code
calls gnus-group-prepare-function assuming the extended interface from
gnus-group-prepare-flat. Seems to me either gnus-group-prepare-function
should document the extended interface, or it should just be dispensed
with and gnus-group-prepare-flat called directly. Any reason to leave
the indirection?

Antoine


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: gnus-group-list-ticked.diff --]
[-- Type: text/x-diff, Size: 2424 bytes --]

diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog
index 90f3625..8d6c461 100644
--- a/lisp/gnus/ChangeLog
+++ b/lisp/gnus/ChangeLog
@@ -1,3 +1,9 @@
+2011-03-17  Antoine Levitt  <antoine.levitt@gmail.com>
+
+	* gnus-group.el (gnus-group-list-ticked): New function.
+	(gnus-group-make-menu-bar): Provide a menu entry for it.
+	(gnus-group-list-map): Provide a binding for it.
+
 2011-03-16  Julien Danjou  <julien@danjou.info>
 
 	* mm-uu.el (mm-uu-dissect-text-parts): Only dissect handle that are
diff --git a/lisp/gnus/gnus-group.el b/lisp/gnus/gnus-group.el
index e928811..c265538 100644
--- a/lisp/gnus/gnus-group.el
+++ b/lisp/gnus/gnus-group.el
@@ -697,7 +697,8 @@ simple manner.")
   "M" gnus-group-list-all-matching
   "l" gnus-group-list-level
   "c" gnus-group-list-cached
-  "?" gnus-group-list-dormant)
+  "?" gnus-group-list-dormant
+  "!" gnus-group-list-ticked)
 
 (gnus-define-keys (gnus-group-list-limit-map "/" gnus-group-list-map)
   "k"  gnus-group-list-limit
@@ -849,7 +850,8 @@ simple manner.")
 	["List all groups matching..." gnus-group-list-all-matching t]
 	["List active file" gnus-group-list-active t]
 	["List groups with cached" gnus-group-list-cached t]
-	["List groups with dormant" gnus-group-list-dormant t])
+	["List groups with dormant" gnus-group-list-dormant t]
+	["List groups with ticked" gnus-group-list-ticked t])
        ("Sort"
 	["Default sort" gnus-group-sort-groups t]
 	["Sort by method" gnus-group-sort-groups-by-method t]
@@ -4536,6 +4538,28 @@ This command may read the active file."
   (goto-char (point-min))
   (gnus-group-position-point))
 
+(defun gnus-group-list-ticked (level &optional lowest)
+  "List all groups with ticked articles.
+If the prefix LEVEL is non-nil, it should be a number that says which
+level to cut off listing groups.
+If LOWEST, don't list groups with level lower than LOWEST.
+
+This command may read the active file."
+  (interactive "P")
+  (when level
+    (setq level (prefix-numeric-value level)))
+  (when (or (not level) (>= level gnus-level-zombie))
+    (gnus-cache-open))
+  (funcall gnus-group-prepare-function
+	   (or level gnus-level-subscribed)
+	   #'(lambda (info)
+	       (let ((marks (gnus-info-marks info)))
+		 (assq 'tick marks)))
+	   lowest
+	   'ignore)
+  (goto-char (point-min))
+  (gnus-group-position-point))
+
 (defun gnus-group-listed-groups ()
   "Return a list of listed groups."
   (let (point groups)

             reply	other threads:[~2011-03-17 17:42 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-17 17:42 Antoine Levitt [this message]
2011-03-17 17:57 ` gnus-group-list-ticked Lars Magne Ingebrigtsen
2011-03-19  0:45   ` gnus-group-list-ticked Antoine Levitt
2011-03-29 18:37     ` gnus-group-list-ticked 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=87aagtr6du.fsf@gmail.com \
    --to=antoine.levitt@gmail.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).