]> git.cworth.org Git - obsolete/notmuch-wiki/commitdiff
notmuch-hello refresh status message
authorJani Nikula <jani@nikula.org>
Sat, 29 Sep 2012 21:53:45 +0000 (00:53 +0300)
committerJani Nikula <jani@nikula.org>
Sat, 29 Sep 2012 21:53:45 +0000 (00:53 +0300)
emacstips.mdwn

index 311de7101ad08597809bfe30e82ca8fe5b263f2a..e63ab3137f9d45fc2a3802bc043523392050fb13 100644 (file)
@@ -551,3 +551,31 @@ show mode.
             (interactive "sBounce To: ")
             (notmuch-show-view-raw-message)
             (message-resend address)))
+
+## `notmuch-hello` refresh status message
+
+Add the following to your `.emacs` to get a status message about the change in
+the number of messages in the mail store when refreshing the `notmuch-hello`
+buffer.
+
+        (defvar notmuch-hello-refresh-count 0)
+
+        (defun notmuch-hello-refresh-status-message ()
+          (unless no-display
+            (let* ((new-count
+                    (string-to-number
+                     (car (process-lines notmuch-command "count"))))
+                   (diff-count (- new-count notmuch-hello-refresh-count)))
+              (cond
+               ((= notmuch-hello-refresh-count 0)
+                (message "You have %s messages."
+                         (notmuch-hello-nice-number new-count)))
+               ((> diff-count 0)
+                (message "You have %s more messages since last refresh."
+                         (notmuch-hello-nice-number diff-count)))
+               ((< diff-count 0)
+                (message "You have %s fewer messages since last refresh."
+                         (notmuch-hello-nice-number (- diff-count)))))
+              (setq notmuch-hello-refresh-count new-count))))
+
+        (add-hook 'notmuch-hello-refresh-hook 'notmuch-hello-refresh-status-message)