unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Gnus: read x earliest unread articles
@ 2014-12-20 12:36 Emanuel Berg
  0 siblings, 0 replies; only message in thread
From: Emanuel Berg @ 2014-12-20 12:36 UTC (permalink / raw)
  To: help-gnu-emacs

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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2014-12-20 12:36 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-20 12:36 Gnus: read x earliest unread articles Emanuel Berg

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 read-only IMAP folder(s) and NNTP newsgroup(s).