Announcements and discussions for Gnus, the GNU Emacs Usenet newsreader
 help / color / mirror / Atom feed
From: Emanuele Santoro <manu@santoro.tk>
To: info-gnus-english@gnu.org
Subject: [GNUS] Displaying available news-groups, sorted by name
Date: Fri, 12 Feb 2016 20:49:08 +0100	[thread overview]
Message-ID: <87y4apk8hs.fsf@santoro.tk> (raw)


Hi all!

I recently configured Gnus on GNU Emacs 24.4.1 as newsreader. In order
to subscribe to newsgroups, I type M-d, bound to the
gnus-group-describe-all-groups.

The problem is that newsgroups shown are not sorted by name, making
quite anooying to browse.

I tried to edit the gnus-group-describe-all-groups function as follows:


(defun gnus-group-describe-all-groups (&optional force)
  "Pop up a buffer with descriptions of all newsgroups."
  (interactive "P")
  (when force
    (setq gnus-description-hashtb nil))
  (when (not (or gnus-description-hashtb
		 (gnus-read-all-descriptions-files)))
    (error "Couldn't request descriptions file"))

  ;; MODIFCATIONS START HERE
  ;; remove newsgroups with strange names that make sorting fail
  (setq gnus-description-hashtb (remove-if 'numberp gnus-description-hashtb))
  ;; sort the gnus-description-hashtb
  (setq gnus-description-hashtb
	(cl-sort gnus-description-hashtb (lambda (x y)
					   (string< (symbol-name y) (symbol-name x)))))
  ;; MODIFICATIONS END HERE


  (let ((buffer-read-only nil)
	b)
    (erase-buffer)
    (mapatoms
     (lambda (group)
       (setq b (point))
       (let ((charset (gnus-group-name-charset nil (symbol-name group))))
	 (insert (format "      *: %-20s %s\n"
			 (gnus-group-name-decode
			  (symbol-name group) charset)
			 (gnus-group-name-decode
			  (symbol-value group) charset))))
       (gnus-add-text-properties
	b (1+ b) (list 'gnus-group group
		       'gnus-unread t 'gnus-marked nil
		       'gnus-level (1+ gnus-level-subscribed))))
     gnus-description-hashtb)
    (goto-char (point-min))
    (gnus-group-position-point)))

Basically, since gnus-description-hashtb is a vector (not an hash-table
as the name would suggest) of symbol whose name is the name of the
newsgroup, my approach is to sort such vector and then let the mapatoms
function work.

I placed this function in my *scratch* buffer and evaluated it after
loading Gnus, but reloading the newsgroup list shows no effect: the
newsgroup list is still unsorted.

Please note that I am not an expert Lisp programmer nor an expert GNU
Emacs user.

How could I solve this problem?

Thanks in advance,
--
Emanuele Santoro

             reply	other threads:[~2016-02-12 19:49 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-12 19:49 Emanuele Santoro [this message]
2016-02-12 22:31 ` Adam Sjøgren
2016-02-13  1:55   ` Emanuel Berg
2016-02-13 12:33     ` Adam Sjøgren
2016-02-13 17:59       ` Emanuel Berg
2016-02-13  1:50 ` Emanuel Berg
2016-02-13  7:45 ` Lars 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=87y4apk8hs.fsf@santoro.tk \
    --to=manu@santoro.tk \
    --cc=info-gnus-english@gnu.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).