Gnus development mailing list
 help / color / mirror / Atom feed
* Hiding groups with unread messages
@ 2002-05-06 19:35 Matt Armstrong
  2002-05-07  8:31 ` Kai Großjohann
  0 siblings, 1 reply; 5+ messages in thread
From: Matt Armstrong @ 2002-05-06 19:35 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 1344 bytes --]

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.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: hide-unread.patch --]
[-- Type: text/x-patch, Size: 6061 bytes --]

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)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Hiding groups with unread messages
  2002-05-06 19:35 Hiding groups with unread messages Matt Armstrong
@ 2002-05-07  8:31 ` Kai Großjohann
  2002-05-07 16:07   ` Matt Armstrong
  0 siblings, 1 reply; 5+ messages in thread
From: Kai Großjohann @ 2002-05-07  8:31 UTC (permalink / raw)


After a cursory glance, your patch seems nice.  I am, however, a
little bit surprised to see a change in nnmaildir -- presumably this
is a bug in your patch :-)

Are you willing to sign copyright assignment papers for this?  It's a
pain, but necessary.

kai
-- 
Silence is foo!



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Hiding groups with unread messages
  2002-05-07  8:31 ` Kai Großjohann
@ 2002-05-07 16:07   ` Matt Armstrong
  2002-05-08 17:00     ` Kai Großjohann
  0 siblings, 1 reply; 5+ messages in thread
From: Matt Armstrong @ 2002-05-07 16:07 UTC (permalink / raw)
  Cc: ding

Kai.Grossjohann@CS.Uni-Dortmund.DE (Kai Großjohann) writes:

> After a cursory glance, your patch seems nice.  I am, however, a
> little bit surprised to see a change in nnmaildir -- presumably this
> is a bug in your patch :-)

Yeah, the nnmaildir stuff was included by accident.  Paul said he'd
work on a more general solution to what I was doing there (see the
archive if interested).


> Are you willing to sign copyright assignment papers for this?  It's a
> pain, but necessary.

Yes, I've already done that in prep for this feature getting in.


-- 
Don't send mail to Gail.Browning@hole.lickey.com
The address is there for spammers to harvest.



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Hiding groups with unread messages
  2002-05-07 16:07   ` Matt Armstrong
@ 2002-05-08 17:00     ` Kai Großjohann
  2002-05-08 19:36       ` Matt Armstrong
  0 siblings, 1 reply; 5+ messages in thread
From: Kai Großjohann @ 2002-05-08 17:00 UTC (permalink / raw)
  Cc: ding

Matt Armstrong <matt@lickey.com> writes:

> Kai.Grossjohann@CS.Uni-Dortmund.DE (Kai Großjohann) writes:
>
>> Are you willing to sign copyright assignment papers for this?  It's a
>> pain, but necessary.
>
> Yes, I've already done that in prep for this feature getting in.

Good.  How about the patch, now?  Do people have objections?  I like
it.

Do you want to submit a new patch (with docs), Matt?

kai
-- 
Silence is foo!



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Hiding groups with unread messages
  2002-05-08 17:00     ` Kai Großjohann
@ 2002-05-08 19:36       ` Matt Armstrong
  0 siblings, 0 replies; 5+ messages in thread
From: Matt Armstrong @ 2002-05-08 19:36 UTC (permalink / raw)
  Cc: ding

Kai.Grossjohann@CS.Uni-Dortmund.DE (Kai Großjohann) writes:

> Matt Armstrong <matt@lickey.com> writes:
>
>> Kai.Grossjohann@CS.Uni-Dortmund.DE (Kai Großjohann) writes:
>>
>>> Are you willing to sign copyright assignment papers for this?  It's a
>>> pain, but necessary.
>>
>> Yes, I've already done that in prep for this feature getting in.
>
> Good.  How about the patch, now?  Do people have objections?  I like
> it.
>
> Do you want to submit a new patch (with docs), Matt?

Yep, It is on my TODO and will happen sooner or later.  Hopefully
sooner.


-- 
Don't send mail to Theresa.Heiss@hole.lickey.com
The address is there for spammers to harvest.



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2002-05-08 19:36 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-05-06 19:35 Hiding groups with unread messages Matt Armstrong
2002-05-07  8:31 ` Kai Großjohann
2002-05-07 16:07   ` Matt Armstrong
2002-05-08 17:00     ` Kai Großjohann
2002-05-08 19:36       ` Matt Armstrong

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).