aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorÓscar Nájera <hi@oscarnajera.com>2022-05-06 13:59:25 +0200
committerÓscar Nájera <hi@oscarnajera.com>2022-05-06 13:59:25 +0200
commit420116e83fba755b5d8e7b6f1645d6fac1fd209c (patch)
tree48081ade148bb0596909c7fb89ee9b0c26265480
parent206db42b91577677e61f9128653a8e81af3a5d80 (diff)
downloaddotfiles-420116e83fba755b5d8e7b6f1645d6fac1fd209c.tar.gz
dotfiles-420116e83fba755b5d8e7b6f1645d6fac1fd209c.tar.bz2
dotfiles-420116e83fba755b5d8e7b6f1645d6fac1fd209c.zip
more tagmail reorder
-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")))))