diff options
author | Óscar Nájera <hi@oscarnajera.com> | 2021-08-23 11:03:12 +0200 |
---|---|---|
committer | Óscar Nájera <hi@oscarnajera.com> | 2021-08-23 11:03:12 +0200 |
commit | 82446b9c17ef384caca76de31437a430e12d8c2d (patch) | |
tree | 466ee3d542990fcf0382d4318ff60d89b3fc0d6c | |
parent | a2573155bbfe662875c95d3aa18836a14cc6f22a (diff) | |
download | dotfiles-82446b9c17ef384caca76de31437a430e12d8c2d.tar.gz dotfiles-82446b9c17ef384caca76de31437a430e12d8c2d.tar.bz2 dotfiles-82446b9c17ef384caca76de31437a430e12d8c2d.zip |
tagmail at work doesn't need specific folder
-rwxr-xr-x | bin/tagmail | 23 |
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")) |