aboutsummaryrefslogtreecommitdiffstats
path: root/lib/guile
diff options
context:
space:
mode:
authorÓscar Nájera <hi@oscarnajera.com>2022-10-08 15:08:42 +0200
committerÓscar Nájera <hi@oscarnajera.com>2022-10-08 15:08:42 +0200
commitf4baef952b1f054aa632b86bc336650ce6d6e767 (patch)
treef7893ee21513f4f5aa1420b4c29505cec637dc57 /lib/guile
parent1324f71540659fa6c95f3ed7f0ee8f15748db136 (diff)
downloaddotfiles-f4baef952b1f054aa632b86bc336650ce6d6e767.tar.gz
dotfiles-f4baef952b1f054aa632b86bc336650ce6d6e767.tar.bz2
dotfiles-f4baef952b1f054aa632b86bc336650ce6d6e767.zip
mail tagging & rules
Diffstat (limited to 'lib/guile')
-rw-r--r--lib/guile/mail-tools.scm11
-rwxr-xr-xlib/guile/tests.scm14
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")