aboutsummaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorOscar Najera <hi@oscarnajera.com>2023-04-23 18:26:43 +0200
committerOscar Najera <hi@oscarnajera.com>2023-04-23 19:28:46 +0200
commit34103c087aeb885bf351b0c387dbbf08ae4327a5 (patch)
tree00ce9824f564e6fdc2db7c994f8bc69314515600 /bin
parentc88629b0c460e0206643a8f6f92c5fd24d14adce (diff)
downloaddotfiles-34103c087aeb885bf351b0c387dbbf08ae4327a5.tar.gz
dotfiles-34103c087aeb885bf351b0c387dbbf08ae4327a5.tar.bz2
dotfiles-34103c087aeb885bf351b0c387dbbf08ae4327a5.zip
tagmail more use unless and dry-run closure
Diffstat (limited to 'bin')
-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))