Gnus development mailing list
 help / color / mirror / Atom feed
* [patch] Filter History for nnmail.el
@ 1999-11-18 19:28 BrYan P. Johnson
  1999-11-24 20:17 ` Danny Siu
  0 siblings, 1 reply; 4+ messages in thread
From: BrYan P. Johnson @ 1999-11-18 19:28 UTC (permalink / raw)


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

Here's a proposed patch for nnmail.el that gives some nice output
about the split history. I wrote this because I find it useful to see
at a glance where my mail was split to.

The output looks something like this:

Wed Nov 10 15:34:00 1999
 -- Current Split -- 
dense-list : 1
 -- Session Split -- 
dense-list : 1
ding: 2
gnome-devel : 15


Where current split is where mail was split the last time you checked
mail, and session split is where mail was split since you either
started gnus or cleared the session.

I've seen talk of a feature freeze, so I've made this available as a
package rather than a patch at my web site if this doesn't make it
into this release. <URL:http://www.comsecmilnavpac.net/elisp/>

BrYan


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: split history output for nnmail --]
[-- Type: text/x-patch, Size: 4133 bytes --]

--- gnus-new/lisp/nnmail.el	Sun Nov  7 23:11:07 1999
+++ gnus-working/lisp/nnmail.el	Wed Nov 10 15:23:24 1999
@@ -107,6 +107,20 @@
 		 (function-item nnmail-split-fancy)
 		 (function :tag "Other")))
 
+(defcustom nnmail-filter-history-show-session-history t
+  "If t, show the session history when doing nnmail-filter-history."
+  :group 'nnmail-split
+  :type 'boolean
+  )
+
+(defcustom nnmail-filter-history-show-current-split t
+  "If t, show the current split when doing nnmail-filter-history."
+  :group 'nnmail-split
+  :type 'boolean
+  )
+
+
+
 ;; Suggested by Erik Selberg <speed@cs.washington.edu>.
 (defcustom nnmail-crosspost t
   "If non-nil, do crossposting if several split methods match the mail.
@@ -1608,6 +1622,61 @@
     (save-excursion
       (and (nnmail-search-unix-mail-delim-backward)
 	   (not (search-forward "\n\n" pos t))))))
+
+
+(defvar nnmail-session-split-history nil
+  "Session history for mail splits")
+
+(defun nnmail-filter-history-clear-session ()
+  "Clear the current nnmail-filter-history-session."
+  (interactive)
+  (setq nnmail-session-split-history nil))
+
+(defun nnmail-filter-history () 
+  "Creates a buffer with a summary of the number of messages you've
+received per mailbox.  The buffer name is *Filter History* To run, add
+it to a hook called when you check for new mail, such as
+gnus-group-mode-hook or gnus-after-getting-new-news-hook or it may be
+called interactively."
+  (interactive)
+  (with-output-to-temp-buffer "*Filter History*"
+    (let* ((my-split-history nnmail-split-history)
+	  (my-session-split-history (append nnmail-session-split-history nnmail-split-history)))
+      (progn
+	(princ (current-time-string))
+		(if nnmail-filter-history-show-current-split
+	(princ (concat
+		    "\n -- Current Split -- \n"
+		  (mapconcat (lambda (elem) (concat (car elem) " : " (number-to-string (cdr elem))))
+			   (let ((history (sort (mapcar 'caar my-split-history)
+						'string<)))
+			     (mapcar (lambda (x) (cons x (count x history :test 'string=)))
+				     (let (new (tail history))
+				       (while tail
+					 (or (member (car tail) new)
+					     (setq new (cons (car tail) new)))
+					 (setq tail (cdr tail)))
+				       (nreverse new))))
+			   "\n"))))
+	(if nnmail-filter-history-show-session-history
+	(princ (concat
+		"\n -- Session Split -- \n"
+		(mapconcat (lambda (elem) (concat (car elem) " : " (number-to-string (cdr elem))))
+			   (let ((history (sort (mapcar 'caar my-session-split-history)
+						'string<)))
+			     (mapcar (lambda (x) (cons x (count x history :test 'string=)))
+				     (let (new (tail history))
+				       (while tail
+					 (or (member (car tail) new)
+					     (setq new (cons (car tail) new)))
+					 (setq tail (cdr tail)))
+				       (nreverse new))))
+			   "\n"))))
+	(setq nnmail-session-split-history my-session-split-history)
+	)))
+      (setq nnmail-split-history nil)
+    )
+
 
 (run-hooks 'nnmail-load-hook)
 

--- gnus/lisp/ChangeLog	Thu Nov 18 13:16:52 1999
+++ gnus-new/lisp/ChangeLog	Thu Nov 18 14:24:31 1999
@@ -1,3 +1,22 @@
+1999-11-18  BrYan P. Johnson  <beej@mindspring.net>
+
+	* nnmail.el (nnmail-filter-history): New function. Creates a
+ 	buffer with a summary of the number of messages you've received
+ 	per mailbox.  The buffer name is *Filter History* To run, add it
+ 	to a hook called when you check for new mail, such as
+ 	gnus-group-mode-hook or gnus-after-getting-new-news-hook or it may
+ 	be called interactively."
+	(nnmail-filter-history-clear-session): New function. Clear the
+ 	current nnmail-filter-history-session.
+	(nnmail-session-split-history): New variable. Session history for
+ 	mail splits for use with nnmail-filter-history.
+	(nnmail-filter-history-show-session-history): New configurable
+ 	variable. If t, show the session history when doing
+ 	nnmail-filter-history.
+	(nnmail-filter-history-show-current-split): New configurable
+ 	variable If t, show the current split when doing
+ 	nnmail-filter-history.
+	
 1999-11-18  Matthias Andree  <ma@dt.e-technik.uni-dortmund.de>
 
 	* imap.el (require): Added autoload for base64-encode-string.

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

* Re: [patch] Filter History for nnmail.el
  1999-11-18 19:28 [patch] Filter History for nnmail.el BrYan P. Johnson
@ 1999-11-24 20:17 ` Danny Siu
  1999-11-29 21:24   ` BrYan P. Johnson
  0 siblings, 1 reply; 4+ messages in thread
From: Danny Siu @ 1999-11-24 20:17 UTC (permalink / raw)



with 

(add-hook 'gnus-after-getting-new-news-hook 'gnus-filter-history)

%m in gnus-group-line-format will not be able to display % in group line even
%if there are new mails splitted to the group since gnus-filter-history set
%nnmail-history-split to nil and gnus-after-getting-new-news-hook is called
%before group buffer is prepared.

instead put gnus-filter-history in gnus-group-prepare-hook would solve the
problem. ie:

(add-hook 'gnus-group-prepare-hook 'gnus-filter-history)

-- 
Danny Dick-Fung Siu        mailto:dsiu@adobe.com
Acrobat Engineering @ Adobe Systems Incorporated



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

* Re: [patch] Filter History for nnmail.el
  1999-11-24 20:17 ` Danny Siu
@ 1999-11-29 21:24   ` BrYan P. Johnson
  1999-12-01 16:57     ` Lars Magne Ingebrigtsen
  0 siblings, 1 reply; 4+ messages in thread
From: BrYan P. Johnson @ 1999-11-29 21:24 UTC (permalink / raw)


>>>>> On 24 Nov 1999 12:17:42 -0800, Danny Siu <dsiu@Adobe.COM> said:

    > with

    > (add-hook 'gnus-after-getting-new-news-hook
    > 'gnus-filter-history)

    > %m in gnus-group-line-format will not be able to display % in
    > group line even %if there are new mails splitted to the group
    > since gnus-filter-history set %nnmail-history-split to nil and
    > gnus-after-getting-new-news-hook is called %before group buffer
    > is prepared.

    > instead put gnus-filter-history in gnus-group-prepare-hook would
    > solve the problem. ie:

    > (add-hook 'gnus-group-prepare-hook 'gnus-filter-history)

You are correct, except that adding gnus-filter-history to
gnus-group-prepare-hook causes it to be called every time a group is
read, a topic is folded, etc. Which wouldn't be a problem except that
the current split is lost once you perform one of these activities.

I've been looking at Gnus's hooks and can't seem to decide which one
to use. Ideally, one should use a hook that is only called when new
mail is received. That was why I initially chose
gnus-after-getting-new-news-hook. 

Hrm. 

There are two solutions. Find another hook, or make
gnus-filter-history non-destructive with regards to
nnmail-split-history. The latter seems to me to be the more ideal. I
wasn't too proud of the destruction.

There's an update at my site
<URL:http://www.comsecmilnavpac.net/elisp/>. It still requires being
added to a suitable hook (I use still
gnus-after-getting-new-news-hook) but no longer messes with
nnmail-split-history. After a bit more testing, I'll resubmit my patch
to nnmail.el.

I do have a question. I've added this to both
gnus-after-getting-new-news-hook and gnus-group-mode-hook in my
personal set up. That's because it seems that
gnus-after-getting-new-news-hook isn't called when Gnus is
started. It appears that it is only run after getting new news other
than when starting Gnus. So I added it to gnus-group-mode-hook which
is run *only* when Gnus is started. Please let me know if I'm
misunderstanding:

gnus-group-mode-hook is run only when gnus-group-mode is started
(which seems to only be at startup).

gnus-after-getting-new-news-hook is run after getting new news, unless 
you're getting new news as part of starting up gnus.

Thanks,
BrYan


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

* Re: [patch] Filter History for nnmail.el
  1999-11-29 21:24   ` BrYan P. Johnson
@ 1999-12-01 16:57     ` Lars Magne Ingebrigtsen
  0 siblings, 0 replies; 4+ messages in thread
From: Lars Magne Ingebrigtsen @ 1999-12-01 16:57 UTC (permalink / raw)


"BrYan P. Johnson" <bilko@onebabyzebra.com> writes:

> gnus-group-mode-hook is run only when gnus-group-mode is started
> (which seems to only be at startup).
> 
> gnus-after-getting-new-news-hook is run after getting new news, unless 
> you're getting new news as part of starting up gnus.

Yup; that's correct.

-- 
(domestic pets only, the antidote for overdose, milk.)
   larsi@gnus.org * Lars Magne Ingebrigtsen


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

end of thread, other threads:[~1999-12-01 16:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-11-18 19:28 [patch] Filter History for nnmail.el BrYan P. Johnson
1999-11-24 20:17 ` Danny Siu
1999-11-29 21:24   ` BrYan P. Johnson
1999-12-01 16:57     ` Lars Magne Ingebrigtsen

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