diff options
author | jao <jao@gnu.org> | 2019-12-01 17:46:04 +0000 |
---|---|---|
committer | jao <jao@gnu.org> | 2019-12-01 17:46:04 +0000 |
commit | 087c3881b2365de87c8707d728b06873d508d706 (patch) | |
tree | 295990232157e3e288498e1d27a641f3d683cf44 | |
parent | 29174501739991eef804e26d39448b7cc7fb59b3 (diff) | |
download | elibs-087c3881b2365de87c8707d728b06873d508d706.tar.gz elibs-087c3881b2365de87c8707d728b06873d508d706.tar.bz2 |
New: jao-maildir
-rw-r--r-- | net/jao-frm.el | 6 | ||||
-rw-r--r-- | net/jao-maildir.el | 76 |
2 files changed, 79 insertions, 3 deletions
diff --git a/net/jao-frm.el b/net/jao-frm.el index f04c0ce..d189423 100644 --- a/net/jao-frm.el +++ b/net/jao-frm.el @@ -202,16 +202,16 @@ (when (and (boundp 'display-time-mode) display-time-mode) (display-time-update))))) -(defun jao-frm-show-mail-numbers () +(defun jao-frm-show-mail-numbers (&optional fmt) (interactive) - (let ((counts (jao-frm-mail-counts nil))) + (let ((counts (jao-frm-mail-counts fmt))) (message (if counts (mapconcat 'identity counts ", ") "No mail")))) (defun jao-frm-mail-string () (let ((counts (jao-frm-mail-counts (lambda (m n) (let ((m (substring (file-name-nondirectory m) 0 1))) - (format "%s %s" m n)))))) + (format "%s%s" (capitalize m) n)))))) (mapconcat 'identity counts " "))) (provide 'jao-frm) diff --git a/net/jao-maildir.el b/net/jao-maildir.el new file mode 100644 index 0000000..ed082a0 --- /dev/null +++ b/net/jao-maildir.el @@ -0,0 +1,76 @@ +;; jao-maildir.el -- Utilities for reading maildirs -*- lexical-binding: t; -*- + +;; Copyright (c) 2019 jao + +;; Author: jao <mail@jao.io> +;; Start date: Sun Dec 01, 2019 15:48 +;; Keywords: mail + +;; This file is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 3, or (at your option) +;; any later version. + +;; This file is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs; see the file COPYING. If not, write to +;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +;; Boston, MA 02111-1307, USA. + +;;; Comentary: + +;; Inspecting the contents of maildirs and reporting it. + +;;; Code: + +(defvar jao-maildirs nil) +(defvar jao-maildir-counts nil) +(defvar jao-maildir-debug-p nil) + +(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)) + +(defun jao-maildir-counts () + (mapcar (lambda (mbox) (cons mbox (jao-maildir--maildir-new-count mbox))) + jao-maildirs)) + +(defvar jao-maildir--watches nil) + +(defun jao-maildir-cancel-watchers () + (dolist (w jao-maildir--watches) (file-notify-rm-watch w)) + (setq jao-maildir--watches nil)) + +(defun jao-maildir--log-watch (mbox e) + (when jao-maildir-debug-p + (message "watch: %s: %s" mbox e))) + +(defun jao-maildir--watcher (mbox) + (lambda (e) + (jao-maildir--log-watch e mbox) + (when (memq (cadr e) '(created deleted)) + (setcdr (assoc mbox jao-maildir-counts) + (jao-maildir--maildir-new-count mbox))))) + +(defun jao-maildir--setup-watches () + (jao-maildir-cancel-watchers) + (setq jao-maildir--watches + (mapcar (lambda (mbox) + (file-notify-add-watch (jao-maildir--maildir-new mbox) + '(change) + (jao-maildir--watcher mbox))) + jao-maildirs))) + +(defun jao-maildir-setup (maildirs) + (setq jao-maildirs maildirs) + (setq jao-maildir-counts (jao-maildir-counts)) + (jao-maildir--setup-watches)) + + +(provide 'jao-maildir) +;;; jao-maildir.el ends here |