help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Gnus: read x earliest unread articles


From: Emanuel Berg
Subject: Gnus: read x earliest unread articles
Date: Sat, 20 Dec 2014 13:36:30 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)

Yet another path for Gnus. Gnus - probably the best
Gnus in the world. (But we'll have to look into that.)

This is also a simple idea - will it already be there,
as well?

There is also some interesting Elisp - Emacs doesn't
seem to come with a function to take n elements from a
list (?). Check out the two solutions - I don't know
how `reverse' is implemented, but both solutions are
slow, is my gut feeling, but not slow enough to break
the purpose of the function.

The purpose: often you have a group like this:

    the.gosh.wow.group 115 [unread]

However, you don't want to read 115 posts, because
then you'll just read and write and get into arguments
all day (and night) long, and there won't be any time
to carve mythical-religious talismans out of pieces of
wood...

Say, you just want 10 messages. OK, stupid, `C-u 10
RET', right? Wrong, that gets you the newest 10, which
you can't follow because you didn't read the earlier
stages of the discussion. OK, `C-u -10 RET' then? No,
that works for archived stuff, like your nnml inbox,
but not groups: it apparently refers to all articles,
not just the unread ones.

But <drumroll> with this, you can get the 10 earliest,
out of those that are unread! Still, the coolest thing
about this function is that it is actually useful.

(emacs-lisp-mode) ; evaluate me to read easier

(defun n-first-r (n l)
  "Get the first N elements of L, recursively."
  (if (and (> n 0) l) (cons (car l) (n-first-r (1- n) (cdr l)))) )
(defun n-first (n l)
  "Get the first N elements of L, with `reverse' and `last'."
  (reverse (last (reverse l) n)))

(defun gnus-summary-read-unread (&optional articles group)
  "Show ARTICLES number of the earliest, unread messages of GROUP.
If ARTICLES is nil, show all unread.
If GROUP is nil, use the current `gnus-group-group-name' group.
Use \\[universal-argument] to set ARTICLES."
  (interactive "p")
  (unless group (setq group (gnus-group-group-name)))
  (let ((article-list (gnus-list-of-unread-articles group)))
    (gnus-summary-read-group group
                             nil nil nil nil nil
                             (if articles (n-first articles article-list) nil) 
)))

--
underground experts united


reply via email to

[Prev in Thread] Current Thread [Next in Thread]