3

When selecting a newsgroup to read, gnus prompts for the number of articles to fetch. The value it shows is the number of articles in the group.

I recall that there was a way to specify a default value, such that gnus would prompt to load only the most recent, say, 500 articles.

How do I achieve this?

3

Set the group parameter large-newsgroup-initial to 500 for "All" (default is nil), and you should get what you want - a prompt if there are more than gnus-large-newsgroup unread articles, where the prompt defaults to 500 (instead of the number of unread articles).

1

Set gnus-large-newsgroup to 500.

https://www.gnu.org/software/emacs/manual/html_node/gnus/Selecting-a-Group.html

The gnus-large-newsgroup variable says what Gnus should consider to be a big group. If it is nil, no groups are considered big. The default value is 200. If the group has more (unread and/or ticked) articles than this, Gnus will query the user before entering the group. The user can then specify how many articles should be fetched from the server. If the user specifies a negative number (-n), the n oldest articles will be fetched. If it is positive, the n articles that have arrived most recently will be fetched

  • 1
    I looked at that variable already. It's value is 200. When I enter a group, the default value shown is the number of messages, not 200, so this will not solve it. I would like to set the default number of messages to fetch so that I can just press Enter when going into a group, rather than having to type "500" each time. – SabreWolfy Apr 25 '16 at 16:50
  • Could you add version info regarding your emacs, gnus and OS/distribution? The variable works as documented for nntp select method in Debian/Testing emacs24. – AnFi Apr 25 '16 at 18:58
  • 1
    gnus 5.13 in Emacs 24.5.1. That variable defaults to 200 for me. If I set it to 500, no change in behaviour is seen. When I select a group, I am prompted as to how many articles I would like to download, with the default value being the total number of articles in the group. – SabreWolfy Apr 25 '16 at 20:11
  • That variable seems to control the maximum number of articles, which will trigger the prompt to ask how many articles to download. I'm talking about changing the default value, which appears in the prompt. – SabreWolfy Apr 25 '16 at 20:12
1

This seems like a sorely missing feature. Having to stop and choose a number and type it in every time you open a group with a large backlog is tiresome.

As a workaround, you could bind RET in the *Group* buffer to a function that runs:

(gnus-group-select-group number)

...where number is what you would normally type at the prompt.

However, note from the docstring:

If ALL is non-nil, already read articles become readable.

This means that using this workaround will always load already-read articles--which, for me, defeats the whole purpose.

I suppose another possible workaround would be to write a function which compares the number of unread articles in the group to the gnus-large-newsgroup variable, and if larger, calls gnus-group-select-group, inputs the number directly into the minibuffer, and presses RET. Kind of an ugly hack, but I guess it would work.

The way gnus is installed on my system, the uncompiled elisp code isn't available, so modifying it will take a lot more effort. However, once you have the gnus code handy, it would probably not be too difficult to add a new setting to gnus for a default number of articles to load...

1

I hit exactly the same problem while using Gnus for the first time. After browsing the source code for a while, I found the following line from gnus-sum.el.gz is the cause.

(defun gnus-articles-to-read (group &optional read-all)
  "Find out what articles the user wants to read."
  (let* ((only-read-p t)
     (articles
      (gnus-list-range-difference
      ;; Select all articles if `read-all' is non-nil, or if there
      ;; are no unread articles.
           (if (or read-all ...)
               (or ...)
        ;; Select only the "normal" subset of articles.
        (setq only-read-p nil)
            ...))))
    ...
              (let* ((cursor-in-echo-area nil)
             (initial (gnus-parameter-large-newsgroup-initial
                   gnus-newsgroup-name))
             (default (if only-read-p
                      (or initial gnus-large-newsgroup)
                    number))
             (input
              (read-string
               (if only-read-p
                   (format
                "How many articles from %s (available %d, default %d): "
                (gnus-group-real-name
                 (gnus-group-decoded-name gnus-newsgroup-name))
                number default)
                 (format
                  "How many articles from %s (%d default): "
                  (gnus-group-real-name
                   (gnus-group-decoded-name gnus-newsgroup-name))
                  default))
                       ...

I comment out the following line.

        ;; (setq only-read-p nil)

And now it got the default 200 as in the following snapshot.

snapshot showing up default 200

I am on Emacs 25.3 with Gnus 5.13 under Ubuntu 16.04.3 LTS.


Follow-up

I tracked the source code repo and found the following.

commit 4c7468f6446a25c4abbbacf495d45e30103f26b7
Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
Date:   Tue Mar 15 22:57:48 2011 +0000

    gnus-sum.el (gnus-articles-to-read): Revert back to old behaviour if we're selecting a group with unread articles.

diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog
index 1b4cd18695..27fdc563db 100644
--- a/lisp/gnus/ChangeLog
+++ b/lisp/gnus/ChangeLog
@@ -1,5 +1,8 @@
 2011-03-15  Lars Magne Ingebrigtsen  <larsi@gnus.org>

+   * gnus-sum.el (gnus-articles-to-read): Revert back to old behaviour if
+   we're selecting a group with unread articles.
+
    * nnimap.el (nnimap-open-connection-1): Allow `network-only', too.

    * gssapi.el: New file separated out from imap.el to provide a general
diff --git a/lisp/gnus/gnus-sum.el b/lisp/gnus/gnus-sum.el
index 0fa1d5979c..385460378b 100644
--- a/lisp/gnus/gnus-sum.el
+++ b/lisp/gnus/gnus-sum.el
@@ -5798,7 +5798,8 @@ gnus-article-marked-p

 (defun gnus-articles-to-read (group &optional read-all)
   "Find out what articles the user wants to read."
-  (let* ((articles
+  (let* ((only-read-p t)
+    (articles
      ;; Select all articles if `read-all' is non-nil, or if there
      ;; are no unread articles.
      (if (or read-all
@@ -5822,6 +5823,7 @@ gnus-articles-to-read
         (gnus-uncompress-range (gnus-active group)))
           (gnus-cache-articles-in-group group))
        ;; Select only the "normal" subset of articles.
+       (setq only-read-p nil)
        (gnus-sorted-nunion
         (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
         gnus-newsgroup-unreads)))
@@ -5845,18 +5847,25 @@ gnus-articles-to-read
          (let* ((cursor-in-echo-area nil)
             (initial (gnus-parameter-large-newsgroup-initial
                   gnus-newsgroup-name))
+            (default (if only-read-p
+                     (or initial gnus-large-newsgroup)
+                   number))
             (input
              (read-string
-              (format
-               "How many articles from %s (available %d, default %d): "
-               (gnus-group-decoded-name
-                (gnus-group-real-name gnus-newsgroup-name))
-               number
-               (or initial gnus-large-newsgroup))
+              (if only-read-p
+                  (format
+                 "How many articles from %s (available %d, default %d): "
+                 (gnus-group-decoded-name
+                  (gnus-group-real-name gnus-newsgroup-name))
+                 number default)
+                (format
+               "How many articles from %s (%d available): "
+               (gnus-group-decoded-name
+                (gnus-group-real-name gnus-newsgroup-name))
+               default))
               nil
               nil
-              (number-to-string
-               (or initial gnus-large-newsgroup)))))
+              (number-to-string default))))
            (if (string-match "^[ \t]*$" input) number input)))
         ((and (> scored marked) (< scored number)
               (> (- scored number) 20))

So designed behavior is that if all messages under the group are read, then it will prompt with a default number, otherwise none is provided.

I believe the more proper way to solve the problem is not to modify the source code, but rather mark all messages in the group as read by hitting c on the group buffer.

I reverted my change on gnus-sum.el.gz and the following also works now.

read group without new message

But the other group still doesn't prompt a default.

read group with new messages

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.