* guile: update examples

This commit is contained in:
djcb
2012-01-09 08:23:56 +02:00
parent 55b7fcbaef
commit bb20ad375e
2 changed files with 17 additions and 16 deletions

View File

@ -21,7 +21,7 @@ exec guile -e main -s $0 $@
;; Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ;; Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
(use-modules (ice-9 getopt-long)) (use-modules (ice-9 getopt-long) (ice-9 format))
(use-modules (srfi srfi-1)) (use-modules (srfi srfi-1))
(use-modules (mu) (mu message) (mu contact)) (use-modules (mu) (mu message) (mu contact))
@ -32,16 +32,17 @@ exec guile -e main -s $0 $@
(< (timestamp c1) (timestamp c2))) (< (timestamp c1) (timestamp c2)))
(define (export-contact contact form) (define (export-contact contact form)
(cond "Convert CONTACT to a string in format FORM."
((string= form "org-contacts") (let ((email (email contact)) (name (name contact)))
(format #t "* ~a\n:PROPERTIES:\n:EMAIL:~a\n:END:\n\n" (if email ;; filter out anything *without* an email address
(or (name contact) (email contact)) (email contact))) (cond
((string= form "plain") ((string= form "org-contacts")
(format #t "~a~a\n" (format #t "* ~s\n:PROPERTIES:\n:EMAIL:~a\n:END:\n\n"
(or (name contact) "") (or name email) email))
(if (name contact) ((string= form "plain")
(string-append " <" (email contact) ">") (format #t "~a~a\n"
(email contact)))))) (or name "")
(if name (string-append " <" email ">") email)))))))
(define (main args) (define (main args)
(let* ((optionspec '( (muhome (value #t)) (let* ((optionspec '( (muhome (value #t))
@ -66,11 +67,12 @@ exec guile -e main -s $0 $@
(display msg) (display msg)
(exit 0)) (exit 0))
(begin (begin
(mu:initialize #t muhome) (setlocale LC_ALL "")
(mu:initialize muhome)
(let* ((sort-func (let* ((sort-func
(cond (cond
((string= sort-by "frequency") sort-by-freq) ((string= sort-by "frequency") sort-by-freq)
((string= sort-by "newness") sort-by-newness) ((string= sort-by "newness") sort-by-newness)
(else (begin (display msg) (exit 1))))) (else (begin (display msg) (exit 1)))))
(contacts '())) (contacts '()))
;; make a list of all contacts ;; make a list of all contacts
@ -90,7 +92,6 @@ exec guile -e main -s $0 $@
(export-contact c form)) (export-contact c form))
contacts)))))) contacts))))))
;; Local Variables: ;; Local Variables:
;; mode: scheme ;; mode: scheme
;; End: ;; End:

View File

@ -168,7 +168,7 @@ then be used in, e.g., R and gnuplot."
(begin (begin
(display msg) (display msg)
(exit (if help 0 1)))) (exit (if help 0 1))))
(mu:initialize #t muhome) (mu:initialize muhome)
(cond (cond
((string= period "hour") (mu:plot:per-hour expr)) ((string= period "hour") (mu:plot:per-hour expr))
((string= period "day") (mu:plot:per-weekday expr)) ((string= period "day") (mu:plot:per-weekday expr))