* 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., # note, we need top_builddir for snarfing with 'make distcheck' (ie.,
# with separate builddir) # with separate builddir)
SUBDIRS= . mu SUBDIRS= . mu examples
INCLUDES=-I. -I${top_builddir} -I${top_srcdir}/src ${GUILE_CFLAGS} ${GLIB_CFLAGS} INCLUDES=-I. -I${top_builddir} -I${top_srcdir}/src ${GUILE_CFLAGS} ${GLIB_CFLAGS}
# don't use -Werror, as it might break on other compilers # don't use -Werror, as it might break on other compilers

View File

@ -17,4 +17,5 @@
include $(top_srcdir)/gtest.mk include $(top_srcdir)/gtest.mk
noinst_DIST= \ 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 (ice-9 getopt-long))
(use-modules (mu) (mu contacts)) (use-modules (mu) (mu contacts))
(define (sort-by-freq) #f) (define (sort-by-freq c1 c2)
(define (sort-by-newness) #f) (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) (define (main args)
@ -40,6 +47,7 @@ exec guile -e main -s $0 $@
"--format=<org-contacts|wl|mutt-ab|plain(*)> " "--format=<org-contacts|wl|mutt-ab|plain(*)> "
"--sort-by=<freq(*)|newness> [--revert] [--limit=<n>]\n")) "--sort-by=<freq(*)|newness> [--revert] [--limit=<n>]\n"))
(help (option-ref options 'help #f)) (help (option-ref options 'help #f))
(muhome (option-ref options 'muhome #f))
(sort-by (or (option-ref options 'sort-by #f) "freq")) (sort-by (or (option-ref options 'sort-by #f) "freq"))
(revert (option-ref options 'revert #f)) (revert (option-ref options 'revert #f))
(format (or (option-ref options 'format #f) "plain")) (format (or (option-ref options 'format #f) "plain"))
@ -49,16 +57,21 @@ exec guile -e main -s $0 $@
(display msg) (display msg)
(exit 0)) (exit 0))
(begin (begin
(if (option-ref options 'muhome #f) (if muhome
(mu:init (option-ref options 'muhome)) (mu:init muhome)
(mu:init)) (mu:init))
(let* ((sort-func (let* ((sort-func
(cond (cond
((string= sort-by "freq") 'sort-by-freq) ((string= sort-by "freq") 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 (mu:contacts:list))) (for-each
(display "%S" contacts)))))) (lambda (c) (format #t "~S\n" (vector-ref c 0)))
(mu:contacts:list)))))))
;;(mu:contacts:export 'plain sort-func 100))))))
;; Local Variables: ;; Local Variables:
;; mode: scheme ;; mode: scheme

View File

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