diff options
-rwxr-xr-x | bin/tagmail | 28 | ||||
-rw-r--r-- | config/doom/config.org | 11 |
2 files changed, 21 insertions, 18 deletions
diff --git a/bin/tagmail b/bin/tagmail index 409aff1..687f0d3 100755 --- a/bin/tagmail +++ b/bin/tagmail @@ -27,8 +27,7 @@ LD_LIBRARY_PATH=$HOME/.guix-profile/lib exec guile -e main -s "$0" "$@" (utils) (srfi srfi-1) (system ffi-help-rt) - (system foreign) - (term ansi-color)) + (system foreign)) (define (on-all-messages-filenames query proc) (nm-iter messages (nm-result-messages query) @@ -40,16 +39,14 @@ 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 " [~a] ~a~%" - (colorize-string "rm" 'BOLD (if do? 'RED 'NONE)) - file-path) + (simple-format #t " [rm] ~a~%" file-path) (if do? (delete-file file-path)))) (with-nm-database (ffi-db (assq-ref options 'mail-repo) 0) (with-nm-query (ffi-db to-delete "tag:deleted") (display (string-append - (colorize-string "[DELETE] " 'BOLD 'YELLOW) + "[DELETE] " (number->string (nm-count-messages to-delete)) " files marked\n")) (on-all-messages-filenames to-delete logged-delete)))) @@ -60,8 +57,7 @@ LD_LIBRARY_PATH=$HOME/.guix-profile/lib exec guile -e main -s "$0" "$@" (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 " [~a] ~a -> ~a~%" - (colorize-string "mv" 'BOLD (if do? 'RED 'NONE)) + (simple-format #t " [mv] ~a -> ~a~%" (substring file sub-len) (substring target-file sub-len)) (when do? (rename-file file target-file))))) @@ -74,10 +70,10 @@ LD_LIBRARY_PATH=$HOME/.guix-profile/lib exec guile -e main -s "$0" "$@" (with-nm-query (ffi-db to-move (format #f "~a and folder:~a/~a" query account start-dir)) (display (string-append - (colorize-string "[MOVE] " 'BOLD 'YELLOW) + "[MOVE] " (number->string (nm-count-messages to-move)) " messages marked in " - (colorize-string account 'GREEN 'BOLD) + account "\n")) (on-all-messages-filenames to-move (move-file uidvalidity target-folder)))))) @@ -108,7 +104,7 @@ LD_LIBRARY_PATH=$HOME/.guix-profile/lib exec guile -e main -s "$0" "$@" (nm-iter messages (nm-result-messages query) (apply-tags-to-message options tags)))))) (define (list-tag options ffi-db new) - (display (colorize-string "[LISTS filters]\n" 'BOLD 'YELLOW)) + (display "[LISTS filters]\n") (let ((query-str (query-with-new '("+lists" "not tag:lists") new)) (tags-str (tags-with-new '("+lists" "not tag:lists") new)) (reg (make-regexp "<([a-z0-9=_-]+)\\." regexp/icase))) @@ -146,7 +142,7 @@ LD_LIBRARY_PATH=$HOME/.guix-profile/lib exec guile -e main -s "$0" "$@" (call-with-pipe "bogofilter -bTv" (lambda (push result) - (display (colorize-string "[SPAM Flag]\n" 'BOLD 'YELLOW)) + (display "[SPAM Flag]\n") (let ((spam? (spam-channel push result))) (with-nm-query (ffi-db query query-str) @@ -176,7 +172,7 @@ LD_LIBRARY_PATH=$HOME/.guix-profile/lib exec guile -e main -s "$0" "$@" ("+calls" "folder:hi_pers/Calls"))) (define (clear-inbox options ffi-db) - (display (colorize-string "[Inbox]\n" 'BOLD 'YELLOW)) + (display "[Inbox]\n") (let* ((my-emails (list "hi@oscarnajera.com" "hello@oscarnajera.com" "najera.oscar@gmail.com")) (sent (format #f "(~{from:~a~^ OR ~}) AND NOT (~:*~{to:~a~^ OR ~})" my-emails))) (map (notmuch-tag options ffi-db #t) @@ -205,15 +201,15 @@ LD_LIBRARY_PATH=$HOME/.guix-profile/lib exec guile -e main -s "$0" "$@" (unless (option-ref options 'dry-run #f) - (display (colorize-string "[SYNC]\n" 'BOLD 'YELLOW)) + (display "[SYNC]\n") (system (string-append "mbsync " (if (null? account) " -a" (car account)))) - (display (colorize-string "[notmuch new]\n" 'BOLD 'YELLOW)) + (display "[notmuch new]\n") (system "notmuch new")) (with-nm-database (ffi-db (assq-ref options 'mail-repo) 1) (let ((new (not (option-ref options 'all #f)))) - (display (colorize-string "[TAG rules]\n" 'BOLD 'YELLOW)) + (display "[TAG rules]\n") (map (notmuch-tag options ffi-db new) tag-rules) (list-tag options ffi-db new) (clear-inbox options ffi-db) diff --git a/config/doom/config.org b/config/doom/config.org index 3e1a422..cce1403 100644 --- a/config/doom/config.org +++ b/config/doom/config.org @@ -379,13 +379,20 @@ this new window. (completing-read "Which mailbox")) (kill-buffer buffer))))) + +(define-derived-mode mail-sync-log-mode comint-mode "mail-sync-log" + "Major mode for reading mail sync." + ;; code for syntax highlighting + (setq font-lock-defaults `(((,(rx bol "[" (1+ (or letter space)) "]") . font-lock-warning-face) + (,(rx bol " [mv]") . font-lock-constant-face) + (,(rx bol " [rm]") . font-lock-keyword-face))))) + (defun on/fetch-all-email () "Start tagmail fetch on a subprocess." (interactive) (with-current-buffer (get-buffer-create "*E-mail fetch*") (pop-to-buffer (current-buffer)) - (comint-mode) - (ansi-color-for-comint-mode-on) + (mail-sync-log-mode) (make-process :name "E-mail fetch" :buffer (current-buffer) |