From 1324f71540659fa6c95f3ed7f0ee8f15748db136 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=93scar=20N=C3=A1jera?= Date: Sat, 8 Oct 2022 14:50:39 +0200 Subject: separate logging of tagged mails --- bin/tagmail | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/bin/tagmail b/bin/tagmail index d846d73..409aff1 100755 --- a/bin/tagmail +++ b/bin/tagmail @@ -87,18 +87,24 @@ 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 (log-msg-tag count rule new) + (let* ((query-str (query-with-new rule new)) + (tags (tags-with-new rule new)) + (info (if (null? (cddr rule)) query-str (caddr rule)))) + (when (< 0 count) + (simple-format #t " ~a messages: ~a~a~%" + count + (if (string=? info query-str) "" + (string-append info " | ")) + tags)))) + (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)))) + (let ((query-str (query-with-new rule new)) + (tags (tags-with-new rule new))) (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) + (log-msg-tag (nm-count-messages query) rule new) (nm-iter messages (nm-result-messages query) (apply-tags-to-message options tags)))))) (define (list-tag options ffi-db new) -- cgit v1.2.3