aboutsummaryrefslogtreecommitdiffstats
path: root/bin/tagmail
diff options
context:
space:
mode:
Diffstat (limited to 'bin/tagmail')
-rwxr-xr-xbin/tagmail31
1 files changed, 16 insertions, 15 deletions
diff --git a/bin/tagmail b/bin/tagmail
index 52bcc7c..0e8f0bc 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))