mirror of https://github.com/djcb/mu.git
guile: update scripts
Some minor improvements to the existing scripts
This commit is contained in:
parent
e02df6c786
commit
46c741ec9a
|
@ -1,5 +1,5 @@
|
|||
;;
|
||||
;; Copyright (C) 2011-2013 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
||||
;; Copyright (C) 2011-2022 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
||||
;;
|
||||
;; 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
|
||||
|
@ -26,8 +26,8 @@
|
|||
(define (export-pairs pairs)
|
||||
"Write a temporary file with the list of PAIRS in table format, and
|
||||
return the file name."
|
||||
(let* ((datafile (tmpnam))
|
||||
(output (open datafile (logior O_CREAT O_WRONLY) #O0600)))
|
||||
(let* ((output (mkstemp "/tmp/mu-guile-XXXXXX" "w"))
|
||||
(datafile (port-filename output)))
|
||||
(for-each
|
||||
(lambda(pair)
|
||||
(display (format #f "~a ~a\n" (car pair) (cdr pair)) output))
|
||||
|
@ -62,9 +62,12 @@ EXTRA-GNUPLOT-OPTS is a list
|
|||
of any additional options for gnuplot."
|
||||
(if (not (find-program-in-path "gnuplot"))
|
||||
(error "cannot find 'gnuplot' in path"))
|
||||
(let ((datafile (export-pairs data))
|
||||
(gnuplot (open-pipe "gnuplot -p" OPEN_WRITE)))
|
||||
(display (string-append
|
||||
(when (zero? (length data))
|
||||
(error "No data for plotting"))
|
||||
(let* ((datafile (export-pairs data))
|
||||
(gnuplot (open-pipe "gnuplot -p" OPEN_WRITE))
|
||||
(recipe
|
||||
(string-append
|
||||
"reset\n"
|
||||
"set term " (or output "dumb") "\n"
|
||||
"set title \"" title "\"\n"
|
||||
|
@ -72,8 +75,8 @@ of any additional options for gnuplot."
|
|||
"set ylabel \"" y-label "\"\n"
|
||||
"set boxwidth 0.9\n"
|
||||
(string-join extra-gnuplot-opts "\n")
|
||||
"plot \"" datafile "\" using 2:xticlabels(1) with boxes fs solid\n")
|
||||
gnuplot)
|
||||
"plot \"" datafile "\" using 2:xticlabels(1) with boxes fs solid title \"\"\n")))
|
||||
(display recipe gnuplot)
|
||||
(close-pipe gnuplot)))
|
||||
|
||||
;; backward compatibility
|
||||
|
|
|
@ -41,6 +41,7 @@ then call FUNC with args SEARCHEXPR and OUTPUT."
|
|||
(let* ((optionspec '((muhome (value #t))
|
||||
(query (value #t))
|
||||
(output (value #f))
|
||||
(time-unit (value #t)) ;; Ignore.
|
||||
(help (single-char #\h) (value #f))))
|
||||
(options (getopt-long args optionspec))
|
||||
(query (option-ref options 'query #f))
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
;;
|
||||
;; Copyright (C) 2011-2013 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
||||
;; Copyright (C) 2011-2022 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
||||
;;
|
||||
;; 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
|
||||
|
@ -65,7 +65,8 @@ returns #t if A < B, #f otherwise), and then take the first N."
|
|||
(take (sort (mu:tabulate func expr) less) n))
|
||||
|
||||
(define* (mu:top-n-most-frequent func n #:optional (expr #t))
|
||||
"Take the results of (mu:tabulate FUNC EXPR), and return the N items with the highest frequency."
|
||||
"Take the results of (mu:tabulate FUNC EXPR), and return the N items
|
||||
with the highest frequency."
|
||||
(top-n func (lambda (a b) (> (cdr a) (cdr b))) n expr))
|
||||
|
||||
(define* (mu:count #:optional (expr #t))
|
||||
|
@ -100,7 +101,8 @@ EXPR (or #t for all). Returns #f if undefined."
|
|||
|
||||
(define* (mu:stddev func #:optional (expr #t))
|
||||
"Get the standard deviation the the values of FUNC applied to all
|
||||
messages matching EXPR (or #t for all). This is the 'population' stddev, not the 'sample' stddev. Returns #f if undefined."
|
||||
messages matching EXPR (or #t for all). This is the 'population' stddev,
|
||||
not the 'sample' stddev. Returns #f if undefined."
|
||||
(stddev (map func (mu:message-list expr))))
|
||||
|
||||
(define* (mu:max func #:optional (expr #t))
|
||||
|
|
|
@ -19,7 +19,7 @@ exec guile -e main -s $0 $@
|
|||
;; along with this program; if not, write to the Free Software Foundation,
|
||||
;; Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
;; INFO: find duplicate messages
|
||||
;; INFO: Find duplicate messages
|
||||
;; INFO: options:
|
||||
;; INFO: --muhome=<muhome>: path to mu home dir
|
||||
;; INFO: --delete: delete all but the first one (experimental, be careful!)
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
#!/bin/sh
|
||||
exec guile -e main -s $0 $@
|
||||
!#
|
||||
;;
|
||||
;; Copyright (C) 2013 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
||||
;; Copyright (C) 2022 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
||||
;;
|
||||
;; 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
|
||||
|
@ -19,10 +18,11 @@ exec guile -e main -s $0 $@
|
|||
;; along with this program; if not, write to the Free Software Foundation,
|
||||
;; Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
;; INFO: graph the number of messages per day (using gnuplot)
|
||||
|
||||
;; INFO: Count the number of messages matching some query
|
||||
;; INFO: options:
|
||||
;; INFO: --query=<query>: limit to messages matching query
|
||||
;; INFO: --muhome=<muhome>: path to mu home dir
|
||||
;; INFO: --muhome=<muhome>: path to mu home dir (optional)
|
||||
|
||||
(use-modules (mu) (mu script) (mu stats))
|
||||
|
||||
|
|
Loading…
Reference in New Issue