* some renaming in guile/

This commit is contained in:
djcb 2011-12-23 16:48:12 +02:00
parent 9d182323e4
commit aa9b831682
5 changed files with 28 additions and 13 deletions

View File

@ -24,7 +24,7 @@ AM_CXXFLAGS=-Wall -Wextra -Wno-unused-parameter
# note, we need top_builddir for snarfing with 'make distcheck' (ie.,
# with separate builddir)
SUBDIRS= . mu
SUBDIRS= . mu examples
INCLUDES=-I. -I${top_builddir} -I${top_srcdir}/src ${GUILE_CFLAGS} ${GLIB_CFLAGS}
# don't use -Werror, as it might break on other compilers

View File

@ -17,4 +17,5 @@
include $(top_srcdir)/gtest.mk
noinst_DIST= \
mu-msg-stats
msg-stats \
contacts-export

View File

@ -24,8 +24,15 @@ exec guile -e main -s $0 $@
(use-modules (ice-9 getopt-long))
(use-modules (mu) (mu contacts))
(define (sort-by-freq) #f)
(define (sort-by-newness) #f)
(define (sort-by-freq c1 c2)
(let ((freq1 (vector-ref c1 2))
(freq2 (vector-ref c2 2)))
(< freq2 freq2)))
(define (sort-by-newness c1 c2)
(let ((tstamp1 (vector-ref c1 3))
(tstamp2 (vector-ref c2 3)))
(< tstamp1 tstamp2)))
(define (main args)
@ -40,6 +47,7 @@ exec guile -e main -s $0 $@
"--format=<org-contacts|wl|mutt-ab|plain(*)> "
"--sort-by=<freq(*)|newness> [--revert] [--limit=<n>]\n"))
(help (option-ref options 'help #f))
(muhome (option-ref options 'muhome #f))
(sort-by (or (option-ref options 'sort-by #f) "freq"))
(revert (option-ref options 'revert #f))
(format (or (option-ref options 'format #f) "plain"))
@ -49,16 +57,21 @@ exec guile -e main -s $0 $@
(display msg)
(exit 0))
(begin
(if (option-ref options 'muhome #f)
(mu:init (option-ref options 'muhome))
(if muhome
(mu:init muhome)
(mu:init))
(let* ((sort-func
(cond
((string= sort-by "freq") 'sort-by-freq)
((string= sort-by "newness") 'sort-by-newness)
(else (begin (display msg) (exit 1)))))
(contacts (mu:contacts:list)))
(display "%S" contacts))))))
((string= sort-by "freq") sort-by-freq)
((string= sort-by "newness") sort-by-newness)
(else (begin (display msg) (exit 1))))))
(for-each
(lambda (c) (format #t "~S\n" (vector-ref c 0)))
(mu:contacts:list)))))))
;;(mu:contacts:export 'plain sort-func 100))))))
;; Local Variables:
;; mode: scheme

View File

@ -29,6 +29,7 @@
:use-module (srfi srfi-1)
:export
(mu:contacts:list
mu:contacts:convert
mu:contacts:export))
(define (mu:contacts:hash)
@ -42,7 +43,7 @@
(let* ((tstamp (mu:msg:date msg))
;; the contact we just found
(name (car contact))
(email (cdr contact))
(email (cadr contact))
;; the contact found in the hash
(entry (hash-ref contacts-hash email))
(hash-name (and entry (vector-ref entry 0)))
@ -91,7 +92,7 @@ symbol, either 'org-contact, 'mutt-alias, 'bbdb, 'wl, or 'plain."
(freq (vector-ref contact 2))
(tstamp (vector-ref contact 3))
(nick (email))) ;; FIXME
(case
(case format
('mutt-alias
(format #f "alias ~a ~a <~a>\n" nick name email))
('org-contact