aboutsummaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/tagmail23
1 files changed, 15 insertions, 8 deletions
diff --git a/bin/tagmail b/bin/tagmail
index 9f639b3..992bec1 100755
--- a/bin/tagmail
+++ b/bin/tagmail
@@ -17,6 +17,7 @@
(ffi notmuch)
(ice-9 and-let-star)
(ice-9 ftw)
+ (ice-9 format)
(ice-9 getopt-long)
(ice-9 match)
(ice-9 popen)
@@ -187,24 +188,30 @@
(notmuch-tag options ffi-db `(("+sent" ,sent "Emails I have sent")
("+inbox" "*" "Inbox for the rest")) #t)))
+
(define (main args)
- (let* ((option-spec '((version (single-char #\V) (value #f))
+ (let* ((mail-repo (string-append
+ (passwd:dir (getpwuid (geteuid)))
+ "/.mail/" ))
+ (option-spec '((version (single-char #\V) (value #f))
(help (single-char #\h) (value #f))
(all (value #f))
(dry-run (single-char #\n) (value #f))))
- (options (cons (cons 'mail-repo (string-append
- (passwd:dir (getpwuid (geteuid)))
- "/.mail/" ))
+ (options (cons (cons 'mail-repo mail-repo)
(getopt-long args option-spec)))
- (account (if (null? (assq-ref options '())) "hi_pers" (car (assq-ref options '())))))
+ (account (assq-ref options '()) ))
(delete-email-files! options)
- (if (string=? account "hi_pers")
- (move-mail! options account "tag:spam" "Inbox" "Junk"))
+
+ (when (or (and (null? '())
+ (access? (string-append mail-repo "hi_pers") W_OK))
+ (and (string? account)
+ (string=? account "hi_pers")))
+ (move-mail! options "hi_pers" "tag:spam" "Inbox" "Junk"))
(unless (option-ref options 'dry-run #f)
(display (colorize-string "[SYNC]\n" 'BOLD 'YELLOW))
- (system (string-append "mbsync " (if (null? (assq-ref options '())) " -a" account)))
+ (system (string-append "mbsync " (if (null? account) " -a" account)))
(display (colorize-string "[notmuch new]\n" 'BOLD 'YELLOW))
(system "notmuch new"))