diff options
author | jao <jao@gnu.org> | 2020-07-10 03:00:40 +0100 |
---|---|---|
committer | jao <jao@gnu.org> | 2020-07-10 03:00:40 +0100 |
commit | fb2e0aad62a9497f048247d536ce8212e1b77bb1 (patch) | |
tree | 7da55bfd0b503f573b29a7d49708c2ac8ef9f2d0 /net | |
parent | 37b9aeb1b9713561c04edf788b05e13dcabda858 (diff) | |
download | elibs-fb2e0aad62a9497f048247d536ce8212e1b77bb1.tar.gz elibs-fb2e0aad62a9497f048247d536ce8212e1b77bb1.tar.bz2 |
maildir tweaks
Diffstat (limited to 'net')
-rw-r--r-- | net/jao-frm.el | 5 | ||||
-rw-r--r-- | net/jao-maildir.el | 37 |
2 files changed, 37 insertions, 5 deletions
diff --git a/net/jao-frm.el b/net/jao-frm.el index d189423..2658687 100644 --- a/net/jao-frm.el +++ b/net/jao-frm.el @@ -1,6 +1,6 @@ ;;; jao-frm.el --- use frm to show mailbox -;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2019 +;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2019, 2020 ;; Author: Jose Antonio Ortega Ruiz <jao@gnu.org> ;; Keywords: mail @@ -182,6 +182,7 @@ (list jao-frm-mailboxes))) (t (error "Error in mbox specification. Check `jao-frm-mailboxes'")))) +;;;###autoload (defun jao-frm () "Run frm." (interactive) @@ -202,11 +203,13 @@ (when (and (boundp 'display-time-mode) display-time-mode) (display-time-update))))) +;;;###autoload (defun jao-frm-show-mail-numbers (&optional fmt) (interactive) (let ((counts (jao-frm-mail-counts fmt))) (message (if counts (mapconcat 'identity counts ", ") "No mail")))) +;;;###autoload (defun jao-frm-mail-string () (let ((counts (jao-frm-mail-counts (lambda (m n) diff --git a/net/jao-maildir.el b/net/jao-maildir.el index 2c4d67c..8b0f6c9 100644 --- a/net/jao-maildir.el +++ b/net/jao-maildir.el @@ -1,6 +1,6 @@ ;; jao-maildir.el -- Utilities for reading maildirs -*- lexical-binding: t; -*- -;; Copyright (c) 2019 jao +;; Copyright (c) 2019, 2020 jao ;; Author: jao <mail@jao.io> ;; Start date: Sun Dec 01, 2019 15:48 @@ -30,15 +30,40 @@ (defvar jao-maildirs nil) (defvar jao-maildir-counts nil) (defvar jao-maildir-debug-p nil) +(defvar jao-maildir-echo-p t) (defun jao-maildir--maildir-new (mbox) (expand-file-name "new" mbox)) (defun jao-maildir--maildir-new-count (mbox) (- (length (directory-files (jao-maildir--maildir-new mbox))) 2)) +;;;###autoload (defun jao-maildir-counts () - (mapcar (lambda (mbox) (cons mbox (jao-maildir--maildir-new-count mbox))) - jao-maildirs)) + (setq jao-maildir-counts + (mapcar (lambda (mbox) + (cons mbox (jao-maildir--maildir-new-count mbox))) + jao-maildirs))) + +(defvar jao-maildir-tracked-maildirs) +(defvar jao-maildir-mode-line-string "") + +(defun jao-maildir--update-mode-line-string () + (let ((total 0) + (counts)) + (dolist (c jao-maildir-counts) + (when (> (cdr c) 0) + (let* ((m (car c)) + (n (cdr c)) + (a (cdr (assoc m jao-maildir-tracked-maildirs)))) + (when (null a) (setq total (+ n total))) + (when a (push (format "%s%s" a n) counts))))) + (let ((total (if (> total 0) (format " %d " total) " ")) + (s (propertize (mapconcat 'identity counts " ") + 'face 'font-lock-function-name-face))) + (setq jao-maildir-mode-line-string (format "%s%s" total s)) + (when (and jao-maildir-echo-p (not (string-empty-p s))) + (message "%s" s)) + (force-mode-line-update t)))) (defvar jao-maildir--watches nil) @@ -48,7 +73,7 @@ (defun jao-maildir--log-watch (mbox e) (when jao-maildir-debug-p - (message "watch: %s: %s" mbox e))) + (message "[%s] watch: %s: %s" (current-time-string) mbox e))) (defun jao-maildir--watcher (mbox cb) (lambda (e) @@ -56,6 +81,8 @@ (when (memq (cadr e) '(created deleted)) (setcdr (assoc mbox jao-maildir-counts) (jao-maildir--maildir-new-count mbox)) + ;; (jao-maildir-counts) + (jao-maildir--update-mode-line-string) (when cb (funcall cb mbox))))) (defun jao-maildir--setup-watches (cb) @@ -67,9 +94,11 @@ (jao-maildir--watcher mbox cb))) jao-maildirs))) +;;;###autoload (defun jao-maildir-setup (maildirs &optional cb) (setq jao-maildirs maildirs) (setq jao-maildir-counts (jao-maildir-counts)) + (add-to-list 'global-mode-string 'jao-maildir-mode-line-string t) (jao-maildir--setup-watches cb)) |