aboutsummaryrefslogtreecommitdiffstats
path: root/bin/tagmail
diff options
context:
space:
mode:
Diffstat (limited to 'bin/tagmail')
-rwxr-xr-xbin/tagmail58
1 files changed, 29 insertions, 29 deletions
diff --git a/bin/tagmail b/bin/tagmail
index 611d2f6..641706f 100755
--- a/bin/tagmail
+++ b/bin/tagmail
@@ -66,20 +66,20 @@ LD_LIBRARY_PATH=$HOME/.guix-profile/lib exec guile -e main -s "$0" "$@"
(unless (option-ref options 'dry-run #f)
(rename-file file target-file)))))
- (let ((mail-repo (assq-ref options 'mail-repo)))
+ (let* ((mail-repo (assq-ref options 'mail-repo))
+ (target-folder (format #f "~a~a/~a" mail-repo account end-dir))
+ (uidvalidity (get-folder-uidvalidity target-folder)))
(with-nm-database
(ffi-db mail-repo 0)
- (let* ((target-folder (format #f "~a~a/~a" mail-repo account end-dir))
- (uidvalidity (get-folder-uidvalidity target-folder)))
- (with-nm-query
- (ffi-db to-move (format #f "~a and folder:~a/~a" query account start-dir))
- (display (string-append
- (colorize-string "[MOVE] " 'BOLD 'YELLOW)
- (number->string (nm-count-messages to-move))
- " messages marked in "
- (colorize-string account 'GREEN 'BOLD)
- "\n"))
- (on-all-messages-filenames to-move (move-file uidvalidity target-folder)))))))
+ (with-nm-query
+ (ffi-db to-move (format #f "~a and folder:~a/~a" query account start-dir))
+ (display (string-append
+ (colorize-string "[MOVE] " 'BOLD 'YELLOW)
+ (number->string (nm-count-messages to-move))
+ " messages marked in "
+ (colorize-string account 'GREEN 'BOLD)
+ "\n"))
+ (on-all-messages-filenames to-move (move-file uidvalidity target-folder))))))
(define (apply-tags-to-message options tags)
(lambda (message)
@@ -87,20 +87,19 @@ LD_LIBRARY_PATH=$HOME/.guix-profile/lib exec guile -e main -s "$0" "$@"
(unless (option-ref options 'dry-run #f)
(nm-apply-tags message tags)) #t))
-(define (notmuch-tag options ffi-db rules new)
- (map (lambda (rule)
- (let* ((query-str (query-with-new rule new))
- (tags (tags-with-new rule new))
- (info (if (null? (cddr rule)) query-str (caddr rule))))
- (with-nm-query
- (ffi-db query query-str)
- (simple-format #t " ~a messages: ~a~a~%"
- (nm-count-messages query)
- (if (string=? info query-str) ""
- (string-append info " | "))
- tags)
- (nm-iter messages (nm-result-messages query) (apply-tags-to-message options tags)))))
- rules))
+(define (notmuch-tag options ffi-db new)
+ (lambda (rule)
+ (let* ((query-str (query-with-new rule new))
+ (tags (tags-with-new rule new))
+ (info (if (null? (cddr rule)) query-str (caddr rule))))
+ (with-nm-query
+ (ffi-db query query-str)
+ (simple-format #t " ~a messages: ~a~a~%"
+ (nm-count-messages query)
+ (if (string=? info query-str) ""
+ (string-append info " | "))
+ tags)
+ (nm-iter messages (nm-result-messages query) (apply-tags-to-message options tags))))))
(define (list-tag options ffi-db new)
(display (colorize-string "[LISTS filters]\n" 'BOLD 'YELLOW))
@@ -174,8 +173,9 @@ LD_LIBRARY_PATH=$HOME/.guix-profile/lib exec guile -e main -s "$0" "$@"
(display (colorize-string "[Inbox]\n" 'BOLD 'YELLOW))
(let* ((my-emails (list "hi@oscarnajera.com" "hello@oscarnajera.com" "najera.oscar@gmail.com"))
(sent (format #f "(~{from:~a~^ OR ~}) AND NOT (~:*~{to:~a~^ OR ~})" my-emails)))
- (notmuch-tag options ffi-db `(("+sent" ,sent "Emails I have sent")
- ("+inbox" "*" "Inbox for the rest")) #t)))
+ (map (notmuch-tag options ffi-db #t)
+ `(("+sent" ,sent "Emails I have sent")
+ ("+inbox" "*" "Inbox for the rest")))))
(define (main args)
@@ -208,7 +208,7 @@ LD_LIBRARY_PATH=$HOME/.guix-profile/lib exec guile -e main -s "$0" "$@"
(ffi-db (assq-ref options 'mail-repo) 1)
(let ((new (not (option-ref options 'all #f))))
(display (colorize-string "[TAG rules]\n" 'BOLD 'YELLOW))
- (notmuch-tag options ffi-db tag-rules new)
+ (map (notmuch-tag options ffi-db new) tag-rules)
(list-tag options ffi-db new)
(clear-inbox options ffi-db)
(tag-spam options ffi-db "tag:inbox")))))