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