From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/44722 Path: main.gmane.org!not-for-mail From: Matt Armstrong Newsgroups: gmane.emacs.gnus.general Subject: Hiding groups with unread messages Date: Mon, 06 May 2002 13:35:30 -0600 Sender: owner-ding@hpc.uh.edu Message-ID: <87d6w9ysql.fsf@squeaker.lickey.com> NNTP-Posting-Host: localhost.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: main.gmane.org 1020713809 29973 127.0.0.1 (6 May 2002 19:36:49 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Mon, 6 May 2002 19:36:49 +0000 (UTC) Return-path: Original-Received: from malifon.math.uh.edu ([129.7.128.13]) by main.gmane.org with esmtp (Exim 3.33 #1 (Debian)) id 174oHw-0007nJ-00 for ; Mon, 06 May 2002 21:36:48 +0200 Original-Received: from sina.hpc.uh.edu ([129.7.128.10] ident=lists) by malifon.math.uh.edu with esmtp (Exim 3.20 #1) id 174oH5-0007Mt-00; Mon, 06 May 2002 14:35:55 -0500 Original-Received: by sina.hpc.uh.edu (TLB v0.09a (1.20 tibbs 1996/10/09 22:03:07)); Mon, 06 May 2002 14:36:08 -0500 (CDT) Original-Received: from sclp3.sclp.com (qmailr@sclp3.sclp.com [209.196.61.66]) by sina.hpc.uh.edu (8.9.3/8.9.3) with SMTP id OAA03849 for ; Mon, 6 May 2002 14:35:55 -0500 (CDT) Original-Received: (qmail 21096 invoked by alias); 6 May 2002 19:35:35 -0000 Original-Received: (qmail 21091 invoked from network); 6 May 2002 19:35:34 -0000 Original-Received: from hank.lickey.com (ident-is-dumb@64.81.100.235) by gnus.org with SMTP; 6 May 2002 19:35:34 -0000 Original-Received: from squeaker.lickey.com (squeaker.lickey.com [192.168.100.10]) by hank.lickey.com (Postfix) with ESMTP id 2C234EE3F for ; Mon, 6 May 2002 13:35:33 -0600 (MDT) Original-Received: by squeaker.lickey.com (Postfix, from userid 1000) id 06C4BC080; Mon, 6 May 2002 13:35:30 -0600 (MDT) Mail-Copies-To: nobody Original-To: ding@gnus.org Mail-Followup-To: ding@gnus.org Original-Lines: 34 User-Agent: Gnus/5.090007 (Oort Gnus v0.07) Emacs/21.2 (i386-debian-linux-gnu) Precedence: list X-Majordomo: 1.94.jlt7 Xref: main.gmane.org gmane.emacs.gnus.general:44722 X-Report-Spam: http://spam.gmane.org/gmane.emacs.gnus.general:44722 --=-=-= In my opinion, Gnus is the #1 mail reader when it comes to dealing with a lot of incoming mail. You've got topics, group levels, scoring, adaptive scoring, etc. all working for you. But Gnus can't do this: - Don't show a group until there has been enough recent traffic on the list to make it worth my time to look at it. - Show the group anyway if it has been long time since I read it, regardless of how many unread messages it contains. I have no self control, so I *need* gnus to hide high volume mailing lists from me until there is a big chunk of mail to read in one go. The other gnus mechanisms for this (group levels, topics) are manual operations and only approximate what I want Gnus to do for me. So I went and implemented the idea by adding a hide-unread and hide-unread-timeout group parameters. The flat and topic mode group buffer creation functions consult these parameters when deciding whether to list the group. A variable gnus-group-hide-unread-timeout is the default value for the hide-unread-timeout parameter. Attached is the patch. I'd appreciate any comments or review folks have as I'm a beginner at elisp. If folks are positive, I'll do some .texi docs and submit a final patch for CVS. -- Don't send mail to Jan.Welch@hole.lickey.com The address is there for spammers to harvest. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=hide-unread.patch Index: gnus-group.el =================================================================== RCS file: /usr/local/cvsroot/gnus/lisp/gnus-group.el,v retrieving revision 6.73 diff -u -r6.73 gnus-group.el --- gnus-group.el 2002/04/23 01:18:09 6.73 +++ gnus-group.el 2002/05/06 19:42:31 @@ -112,6 +112,29 @@ :group 'gnus-group-levels :type 'boolean) +(defcustom gnus-group-hide-unread-timeout 86400 + "*Ignore a group's hide-unread parameter after this many seconds. +The `hide-unread' group parameter can cause a group to not be listed +in the group buffer if it doesn't have enough unread messages. In low +volume groups, it makes sense to show the group anyway if you haven't +read it in a while. + +First, you must add `gnus-group-set-timestamp' to your +`gnus-select-group-hook'. Otherwise, Gnus doesn't know how long it +has been since you last read a group. + +Second, set this variable to the number of seconds you want to wait +before hide-unread has no effect. + +Note, you can also set the `hide-unread-timeout' parameter on each +group individually -- this variable merely provides a default if +`hide-unread-timeout' is not set on a group." + :group 'gnus-group-listing + :type '(radio (const :tag "No timeout" nil) + (const :tag "One hour" 3600) + (const :tag "One day" 86400) + (integer :tag "Seconds"))) + (defcustom gnus-group-sort-function 'gnus-group-sort-by-alphabet "*Function used for sorting the group buffer. This function will be called with group info entries as the arguments @@ -1130,6 +1153,30 @@ (not test) test)))))) +(defun gnus-group-hide-unread-timeout (group) + "Find the hide-unread timeout for GROUP." + (let ((timeout (or (gnus-group-find-parameter group 'hide-unread-timeout) + gnus-group-hide-unread-timeout))) + (if (numberp timeout) + timeout + nil))) + +(defun gnus-group-unread-threshold (group) + "Find the unread threshold for GROUP. +Any groups with fewer than this many unread articles won't be listed +in the group buffer (at least, simply because they have unread +articles). This function will normally return 0 unless the +`hide-unread' parameter is set on GROUP." + (let ((hide-unread (gnus-group-find-parameter group 'hide-unread)) + timeout) + (if (numberp hide-unread) + (if (and (numberp (setq timeout (gnus-group-hide-unread-timeout + group))) + (< timeout (gnus-group-timestamp-delta group))) + 0 + hide-unread) + 0))) + (defun gnus-group-prepare-flat (level &optional predicate lowest regexp) "List all newsgroups with unread articles of level LEVEL or lower. If PREDICATE is a function, list groups that the function returns non-nil; @@ -1173,7 +1220,7 @@ (if (eq unread t) ; Unactivated? gnus-group-list-inactive-groups ; We list unactivated - (> unread 0)) + (> unread (gnus-group-unread-threshold group))) ; We list groups with unread articles (and gnus-list-groups-with-ticked-articles (cdr (assq 'tick (gnus-info-marks info)))) Index: gnus-topic.el =================================================================== RCS file: /usr/local/cvsroot/gnus/lisp/gnus-topic.el,v retrieving revision 6.26 diff -u -r6.26 gnus-topic.el --- gnus-topic.el 2002/05/06 16:52:06 6.26 +++ gnus-topic.el 2002/05/06 19:42:34 @@ -228,7 +228,7 @@ (if (or (eq unread t) (eq unread nil)) gnus-group-list-inactive-groups - (> unread 0)) + (> unread (gnus-group-unread-threshold group))) (and gnus-list-groups-with-ticked-articles (cdr (assq 'tick (gnus-info-marks info)))) ;; Has right readedness. Index: nnmaildir.el =================================================================== RCS file: /usr/local/cvsroot/gnus/lisp/nnmaildir.el,v retrieving revision 6.17 diff -u -r6.17 nnmaildir.el --- nnmaildir.el 2002/04/22 02:28:17 6.17 +++ nnmaildir.el 2002/05/06 19:42:38 @@ -134,6 +134,7 @@ (error nil :type string) ;; last error message, or nil (mtime nil :type list) ;; modtime of dir (gnm nil) ;; flag: split from mail-sources? + (courier nil) ;; flag: create maildirs w/ leading '.' (create-dir nil :type string)) ;; group creation directory (defmacro nnmaildir--nlist-last-num (nlist) @@ -541,6 +542,10 @@ (car x) (setf (nnmaildir--srv-gnm server) t) (require 'nnmail)) + (and (setq x (assq 'courier-compatible defs)) + (setq x (cdr x)) + (car x) + (setf (nnmaildir--srv-courier server) t)) (setq x (assq 'create-directory defs)) (when x (setq x (cadr x) @@ -897,7 +902,7 @@ (nnmaildir--prepare server nil) (catch 'return (let ((create-dir (nnmaildir--srv-create-dir nnmaildir--cur-server)) - srv-dir dir groups) + srv-dir dir groups maildir) (when (zerop (length gname)) (setf (nnmaildir--srv-error nnmaildir--cur-server) "Invalid (empty) group name") @@ -922,13 +927,21 @@ (setq dir srv-dir dir (file-truename dir) dir (concat dir create-dir))) - (setq dir (nnmaildir--subdir (file-name-as-directory dir) gname)) + (setq dir (file-name-as-directory dir)) + (setq maildir (concat dir + (if (nnmaildir--srv-courier nnmaildir--cur-server) + (concat "." gname) + gname))) + (when (equal (file-name-as-directory maildir) (nnmaildir--nndir dir)) + (setf (nnmaildir--srv-error nnmaildir--cur-server) + (concat "Group name may not be " gname)) + (throw 'return nil)) + (setq dir (file-name-as-directory maildir)) (nnmaildir--mkdir dir) (nnmaildir--mkdir (nnmaildir--tmp dir)) (nnmaildir--mkdir (nnmaildir--new dir)) (nnmaildir--mkdir (nnmaildir--cur dir)) - (setq create-dir (file-name-as-directory create-dir)) - (make-symbolic-link (concat create-dir gname) (concat srv-dir gname)) + (make-symbolic-link maildir (concat srv-dir gname)) (nnmaildir-request-scan 'find-new-groups)))) (defun nnmaildir-request-rename-group (gname new-name &optional server) --=-=-=--