diff options
Diffstat (limited to 'bin/tagmail')
-rwxr-xr-x | bin/tagmail | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/bin/tagmail b/bin/tagmail index 52bcc7c..9febae5 100755 --- a/bin/tagmail +++ b/bin/tagmail @@ -38,9 +38,9 @@ LD_LIBRARY_PATH=$HOME/.guix-profile/lib exec guile -e main -s "$0" "$@" (define (delete-email-files! options) (define (logged-delete file-path) - (let ((do? (not (option-ref options 'dry-run #f)))) - (simple-format #t " [rm] ~a~%" file-path) - (if do? (delete-file file-path)))) + (simple-format #t " [rm] ~a~%" file-path) + (unless (option-ref options 'dry-run #f) + (delete-file file-path))) (with-nm-database (ffi-db (assq-ref options 'mail-repo) 0) (with-nm-query @@ -53,14 +53,14 @@ LD_LIBRARY_PATH=$HOME/.guix-profile/lib exec guile -e main -s "$0" "$@" (define (move-mail! options account query start-dir end-dir) (define (move-file uidvalidity target-folder) - (lambda (file) - (let* ((target-file (new-path (rename-higher file uidvalidity) target-folder)) - (sub-len (string-prefix-length file target-file)) - (do? (not (option-ref options 'dry-run #f)))) - (simple-format #t " [mv] ~a -> ~a~%" - (substring file sub-len) - (substring target-file sub-len)) - (when do? (rename-file file target-file))))) + (let ((dry-run? (option-ref options 'dry-run #f))) + (lambda (file) + (let* ((target-file (new-path (rename-higher file uidvalidity) target-folder)) + (sub-len (string-prefix-length file target-file))) + (simple-format #t " [mv] ~a -> ~a~%" + (substring file sub-len) + (substring target-file sub-len)) + (unless dry-run? (rename-file file target-file)))))) (let* ((mail-repo (assq-ref options 'mail-repo)) (target-folder (format #f "~a~a/~a" mail-repo account end-dir)) @@ -78,10 +78,11 @@ LD_LIBRARY_PATH=$HOME/.guix-profile/lib exec guile -e main -s "$0" "$@" (on-all-messages-filenames to-move (move-file uidvalidity target-folder)))))) (define (apply-tags-to-message options tags) - (lambda (message) - (simple-format #t " ~a~%" (nm-header message "subject")) - (unless (option-ref options 'dry-run #f) - (nm-apply-tags message tags)) #t)) + (let ((dry-run? (option-ref options 'dry-run #f))) + (lambda (message) + (simple-format #t " ~a~%" (nm-header message "subject")) + (unless dry-run? + (nm-apply-tags message tags)) #t))) (define (log-msg-tag count rule new) (let* ((query-str (query-with-new rule new)) @@ -178,7 +179,12 @@ LD_LIBRARY_PATH=$HOME/.guix-profile/lib exec guile -e main -s "$0" "$@" ("+meetups" "from:info@meetup.com or from:info@email.meetup.com" "Meetups info mails") ("+immonews" "from:immobilienscout24.de") ("+newsletter" "from:venturebeat.com") + ("+zeihan" "from:zeihan.com") ("+freecodecamp" "from:freecodecamp.org") + ;; byteplant + ("+support" "to:support@byteplant.com") + ("+admin" "to:admin@byteplant.com") + ("+sent" "from:byteplant.com") )) (define (clear-inbox options ffi-db) @@ -201,7 +207,7 @@ LD_LIBRARY_PATH=$HOME/.guix-profile/lib exec guile -e main -s "$0" "$@" (dry-run (single-char #\n) (value #f)))) (options (append (list (cons 'mail-repo mail-repo) (cons 'my-emails my-emails)) - (getopt-long args option-spec))) + (getopt-long args option-spec))) (account (assq-ref options '()) )) (delete-email-files! options) |