diff --git a/configure.ac b/configure.ac index 759d599e..6e886276 100644 --- a/configure.ac +++ b/configure.ac @@ -14,7 +14,7 @@ ## along with this program; if not, write to the Free Software Foundation, ## Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -AC_INIT([mu],[0.9.9],[http://code.google.com/p/mu0/issues/list],[mu]) +AC_INIT([mu],[0.9.9.x],[http://code.google.com/p/mu0/issues/list],[mu]) AC_CONFIG_HEADERS([config.h]) AC_CONFIG_SRCDIR([mu/mu.cc]) # libtoolize wants to put some stuff in here; if you have an old @@ -317,6 +317,8 @@ guile/Makefile guile/mu/Makefile guile/examples/Makefile guile/tests/Makefile +guile/scripts/Makefile +guile/scripts/stats/Makefile toys/Makefile toys/mug/Makefile toys/msg2pdf/Makefile diff --git a/guile/Makefile.am b/guile/Makefile.am index 23d4c0a8..472732c2 100644 --- a/guile/Makefile.am +++ b/guile/Makefile.am @@ -18,7 +18,7 @@ include $(top_srcdir)/gtest.mk # note, we need top_builddir for snarfing with 'make distcheck' (ie., # with separate builddir) -SUBDIRS= . mu examples tests +SUBDIRS= . mu scripts examples tests INCLUDES=-I. -I${top_builddir} -I${top_srcdir}/lib ${GUILE_CFLAGS} ${GLIB_CFLAGS} diff --git a/guile/scripts/Makefile.am b/guile/scripts/Makefile.am new file mode 100644 index 00000000..643cda9f --- /dev/null +++ b/guile/scripts/Makefile.am @@ -0,0 +1,19 @@ +## Copyright (C) 2012 Dirk-Jan C. Binnema +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 3 of the License, or +## (at your option) any later version. +## +## This program is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with this program; if not, write to the Free Software Foundation, +## Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +include $(top_srcdir)/gtest.mk + +SUBDIRS=stats diff --git a/guile/scripts/stats/Makefile.am b/guile/scripts/stats/Makefile.am new file mode 100644 index 00000000..38ad81a1 --- /dev/null +++ b/guile/scripts/stats/Makefile.am @@ -0,0 +1,23 @@ +## Copyright (C) 2012 Dirk-Jan C. Binnema +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 3 of the License, or +## (at your option) any later version. +## +## This program is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with this program; if not, write to the Free Software Foundation, +## Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +include $(top_srcdir)/gtest.mk + +EXTRA_DIST= \ + msg-stats.scm + +muguiledistscriptdir = $(datadir)/$(PACKAGE)/scripts/stats +muguiledistscript_SCRIPTS = $(EXTRA_DIST) diff --git a/guile/scripts/stats/msg-stats.scm b/guile/scripts/stats/msg-stats.scm new file mode 100755 index 00000000..18a3a47b --- /dev/null +++ b/guile/scripts/stats/msg-stats.scm @@ -0,0 +1,128 @@ +#!/bin/sh +exec guile -e main -s $0 $@ +!# +;; +;; Copyright (C) 2011-2012 Dirk-Jan C. Binnema +;; +;; This program is free software; you can redistribute it and/or modify it +;; under the terms of the GNU General Public License as published by the +;; Free Software Foundation; either version 3, or (at your option) any +;; later version. +;; +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. +;; + +;; You should have received a copy of the GNU General Public License +;; along with this program; if not, write to the Free Software Foundation, +;; Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +(setlocale LC_ALL "") + +(use-modules (ice-9 getopt-long) (ice-9 optargs) (ice-9 popen) (ice-9 format)) +(use-modules (mu) (mu stats) (mu plot)) + +(define (per-hour expr plain-text) + "Count the total number of messages for each weekday (0-6 for +Sun..Sat) that match EXPR. If PLAIN-TEXT is true, use a plain-text +display, otherwise, use a graphical window." + (mu:plot + (sort + (mu:tabulate + (lambda (msg) + (tm:hour (localtime (mu:date msg)))) expr) + (lambda (x y) (< (car x) (car y)))) + (format #f "Messages per hour matching ~a" expr) "Hour" "Messages" plain-text)) + +(define (per-day expr plain-text) + "Count the total number of messages for each weekday (0-6 for +Sun..Sat) that match EXPR. If PLAIN-TEXT is true, use a plain-text +display, otherwise, use a graphical window." + (mu:plot + (mu:weekday-numbers->names + (sort (mu:tabulate + (lambda (msg) + (tm:wday (localtime (mu:date msg)))) expr) + (lambda (x y) (< (car x) (car y))))) + (format #f "Messages per weekday matching ~a" expr) "Day" "Messages" plain-text)) + +(define (per-month expr plain-text) + "Count the total number of messages for each weekday (0-6 for +Sun..Sat) that match EXPR. If PLAIN-TEXT is true, use a plain-text +display, otherwise, use a graphical window." + (mu:plot + (mu:month-numbers->names + (sort + (mu:tabulate + (lambda (msg) + (tm:mon (localtime (mu:date msg)))) expr) + (lambda (x y) (< (car x) (car y))))) + (format #f "Messages per month matching ~a" expr) "Month" "Messages" plain-text)) + + +(define (per-year-month expr plain-text) + "Count the total number of messages for each weekday (0-6 for +Sun..Sat) that match EXPR. If PLAIN-TEXT is true, use a plain-text +display, otherwise, use a graphical window." + (mu:plot + (sort (mu:tabulate + (lambda (msg) + (string->number + (format #f "~d~2'0d" + (+ 1900 (tm:year (localtime (mu:date msg)))) + (tm:mon (localtime (mu:date msg)))))) + expr) + (lambda (x y) (< (car x) (car y)))) + (format #f "Messages per year/month matching ~a" expr) + "Year/Month" "Messages" plain-text)) + + + +(define (per-year expr plain-text) + "Count the total number of messages for each weekday (0-6 for +Sun..Sat) that match EXPR. If PLAIN-TEXT is true, use a plain-text +display, otherwise, use a graphical window." + (mu:plot + (sort (mu:tabulate + (lambda (msg) + (+ 1900 (tm:year (localtime (mu:date msg))))) expr) + (lambda (x y) (< (car x) (car y)))) + (format #f "Messages per year matching ~a" expr) "Year" "Messages" plain-text)) + + +(define (main args) + (let* ((optionspec '( (muhome (value #t)) + (what (value #t)) + (text (value #f)) + (help (single-char #\h) (value #f)))) + (options (getopt-long args optionspec)) + (msg (string-append + "usage: mu-msg-stats [--help] [--text] " + "[--muhome=] " + "--what= [searchexpr]\n")) + (help (option-ref options 'help #f)) + (what (option-ref options 'what #f)) + (text (option-ref options 'text #f)) + (muhome (option-ref options 'muhome #f)) + (restargs (option-ref options '() #f)) + (expr (if restargs (string-join restargs) ""))) + (if (or help (not what)) + (begin + (display msg) + (exit (if help 0 1)))) + (mu:initialize muhome) + (cond + ((string= what "per-hour") (per-hour expr text)) + ((string= what "per-day") (per-day expr text)) + ((string= what "per-month") (per-month expr text)) + ((string= what "per-year-month") (per-year-month expr text)) + ((string= what "per-year") (per-year expr text)) + (else (begin + (display msg) + (exit 1)))))) + +;; Local Variables: +;; mode: scheme +;; End: