diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/guile/mail-tools.scm | 11 | ||||
-rwxr-xr-x | lib/guile/tests.scm | 14 |
2 files changed, 15 insertions, 10 deletions
diff --git a/lib/guile/mail-tools.scm b/lib/guile/mail-tools.scm index b158d93..1186306 100644 --- a/lib/guile/mail-tools.scm +++ b/lib/guile/mail-tools.scm @@ -41,14 +41,13 @@ file-name-separator-string))) (define (tags-with-new rule new) - (if new (string-append (car rule) " -new") (car rule))) + (string-append (car rule) (if new " -new" ""))) (define (query-with-new rule new) - (if new - (if (string=? (cadr rule) "*") - "tag:new" - (simple-format #f "(~a) and ~a" (cadr rule) "tag:new")) - (cadr rule))) + (cond + ((and new (string=? (cadr rule) "*")) "tag:new") + (new (simple-format #f "(~a) and ~a" (cadr rule) "tag:new")) + (else (cadr rule)))) ;; NOTMUCH interface (define (nm-open-database path mode) diff --git a/lib/guile/tests.scm b/lib/guile/tests.scm index bc0606c..f481045 100755 --- a/lib/guile/tests.scm +++ b/lib/guile/tests.scm @@ -44,10 +44,16 @@ (test-equal 60 (call-with-input-string "1595684247\n60\n" get-uidvalidity)) (test-equal "Ha;S" (rename-higher "Ha,U=55;S" 5)) (test-equal "Ha,U=20;S" (rename-higher "Ha,U=20;S" 55)) -(test-equal '("+one -new" "(from:first) and tag:new") (with-new '("+one" "from:first") #t)) -(test-equal '("+one" "from:first") (with-new '("+one" "from:first") #f)) -(test-equal '(" -new" "tag:new") (with-new '("" "*") #t)) -(test-equal '("" "*") (with-new '("" "*") #f)) +(let ((rule '("+one" "from:first"))) + (test-equal "+one -new" (tags-with-new rule #t)) + (test-equal "+one" (tags-with-new rule #f)) + (test-equal "(from:first) and tag:new" (query-with-new rule #t)) + (test-equal "from:first" (query-with-new rule #f))) +(let ((rule '("" "*"))) + (test-equal " -new" (tags-with-new rule #t)) + (test-equal "" (tags-with-new rule #f)) + (test-equal "tag:new" (query-with-new rule #t)) + (test-equal "*" (query-with-new rule #f))) (test-end "Mail tools") (test-begin "Thread macros") |