From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/60153 Path: news.gmane.org!not-for-mail From: Mark Plaksin Newsgroups: gmane.emacs.gnus.general Subject: CODE: Hide groups with few unread articles Date: Wed, 13 Apr 2005 21:20:29 -0400 Message-ID: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: sea.gmane.org 1113441822 19930 80.91.229.2 (14 Apr 2005 01:23:42 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 14 Apr 2005 01:23:42 +0000 (UTC) Original-X-From: ding-owner+M8680@lists.math.uh.edu Thu Apr 14 03:23:40 2005 Return-path: Original-Received: from malifon.math.uh.edu ([129.7.128.13]) by ciao.gmane.org with esmtp (Exim 4.43) id 1DLt4w-0001wx-8u for ding-account@gmane.org; Thu, 14 Apr 2005 03:23:34 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.math.uh.edu ident=lists) by malifon.math.uh.edu with smtp (Exim 3.20 #1) id 1DLt2n-0005kQ-00; Wed, 13 Apr 2005 20:21:21 -0500 Original-Received: from util2.math.uh.edu ([129.7.128.23]) by malifon.math.uh.edu with esmtp (Exim 3.20 #1) id 1DLt2e-0005kI-00 for ding@lists.math.uh.edu; Wed, 13 Apr 2005 20:21:12 -0500 Original-Received: from quimby.gnus.org ([80.91.224.244]) by util2.math.uh.edu with esmtp (Exim 4.30) id 1DLt2c-000732-Ua for ding@lists.math.uh.edu; Wed, 13 Apr 2005 20:21:11 -0500 Original-Received: from main.gmane.org ([80.91.229.2] helo=ciao.gmane.org) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1DLt2b-0003Pn-00 for ; Thu, 14 Apr 2005 03:21:09 +0200 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1DLsz8-0001QH-B0 for ding@gnus.org; Thu, 14 Apr 2005 03:17:34 +0200 Original-Received: from water.tss.usg.edu ([168.24.82.53]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 14 Apr 2005 03:17:34 +0200 Original-Received: from happy by water.tss.usg.edu with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 14 Apr 2005 03:17:34 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-To: ding@gnus.org Original-Lines: 130 Original-X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: water.tss.usg.edu User-Agent: Gnus/5.110003 (No Gnus v0.3) Emacs/22.0.50 (gnu/linux) Cancel-Lock: sha1:nhCZlUvNF8UYqgkz3px6By8MvYw= X-Spam-Score: -4.9 (----) Precedence: bulk Original-Sender: ding-owner@lists.math.uh.edu Xref: news.gmane.org gmane.emacs.gnus.general:60153 X-Report-Spam: http://spam.gmane.org/gmane.emacs.gnus.general:60153 --=-=-= Here's some code that lets you hide groups when they have just a few unread articles. You can set the threshold on a per-topic and/or per-group basis. I use levels to separate my groups by priority but I am subscribed to a lot of groups so each level contains a lot of groups. I'm easily distracted so I wanted a way to hide groups without many unread articles. That way when I check for new messages I don't end up reading two or three articles in each of 25 groups. Instead I generally end up reading one or two groups with 25 articles each. It requires a small patch to gnus-group.el which allows you to specify the predicate to use in the funcall to gnus-group-prepare-function. That's the first attachment. The second attachment does the rest of the work. You get a new group parameter called gnus-distraction-threshold. If a group has fewer than gnus-distraction-threshold unread articles, it won't be displayed. gnus-distraction-threshold defaults to 1 so nothing should change unless you set the threshold somewhere. As with any group parameter you can set it for a topic and have it apply to all groups in the topic. By default groups with ticked articles are always displayed. Two key bindings are turned on in the Group buffer: - C-cd toggles distraction prevention on and off - C-ct toggles the display of groups with ticked articles I've only been playing with this for a few days so comments and suggestions are very welcome! --=-=-= Content-Disposition: attachment; filename=patch Content-Description: gnus-group.el patch --- gnus-group.el.orig 2005-04-13 20:43:59.300374438 -0400 +++ gnus-group.el 2005-04-13 20:54:52.185167853 -0400 @@ -255,6 +255,10 @@ :group 'gnus-group-listing :type 'function) +(defvar gnus-group-prepare-function-predicate '(lambda (info) (gnus-distraction-prevention-check info)) + "Predicate to use in call to gnus-group-prepare-function. +Defaults to '(lambda (info) (gnus-distraction-prevention-check info))") + (defcustom gnus-group-prepare-hook nil "Hook called after the group buffer has been generated. If you want to modify the group buffer, you can use this hook." @@ -1156,9 +1160,12 @@ (props (text-properties-at (point-at-bol))) (empty (= (point-min) (point-max))) (group (gnus-group-group-name)) + (unread-or-predicate (if (functionp gnus-group-prepare-function-predicate) + gnus-group-prepare-function-predicate + unread)) number) (set-buffer gnus-group-buffer) - (setq number (funcall gnus-group-prepare-function level unread lowest)) + (setq number (funcall gnus-group-prepare-function level unread-or-predicate lowest)) (when (or (and (numberp number) (zerop number)) (zerop (buffer-size))) --=-=-= Content-Disposition: attachment; filename=gnus-distraction-prevention.el Content-Description: distraction-prevention.el (defvar gnus-prevent-distraction-prevention nil "If t, do not prevent distraction.") (defvar gnus-distraction-prevention-include-ticked t "If t, groups with ticked articles will always be displayed.") (setq gnus-distraction-threshold 1) (defun gnus-distraction-prevention-check (info) "Return t if group has more than gnus-distraction-threshold unread articles. If gnus-distraction-prevention-include-ticked is t, groups with ticked articles will always be displayed." ;(debug) (let* ((group (car info)) (threshold (or (if gnus-prevent-distraction-prevention 1 nil) (gnus-group-find-parameter group 'gnus-distraction-threshold) gnus-distraction-threshold)) (unread (or (gnus-group-unread group) 0)) (ticked (assoc 'tick (gnus-info-marks info)))) ;; if unread is t, the group is not opened (if (eq unread t) (setq unread 0)) ;;(message (concat "threshold for " group " is " ;; (number-to-string threshold))) (or (and gnus-distraction-prevention-include-ticked ticked) (>= unread threshold)))) (defun gnus-distraction-prevention-toggle () "Toggle between distraction prevention and no distraction prevention." (interactive) (let ((message)) (if gnus-prevent-distraction-prevention (progn (setq gnus-prevent-distraction-prevention nil message "on")) (setq gnus-prevent-distraction-prevention t message "off")) (gnus-group-list-groups) (message (concat "Distraction prevention is " message ".")))) (defun gnus-distraction-tick-toggle () "Toggle between displaying groups with ticked articles or not." (interactive) (let ((message)) (if gnus-distraction-prevention-include-ticked (progn (setq gnus-distraction-prevention-include-ticked nil message "on")) (setq gnus-distraction-prevention-include-ticked t message "off")) (gnus-group-list-groups) (message (concat "Ticked distraction prevention is " message ".")))) (define-key gnus-group-mode-map (kbd "C-c d") 'gnus-distraction-prevention-toggle) (define-key gnus-group-mode-map (kbd "C-c t") 'gnus-distraction-tick-toggle) --=-=-=--