From 68ffefa544cf9ac2d534a6cc41a4d3f5b8c8d117 Mon Sep 17 00:00:00 2001 From: Jani Nikula Date: Fri, 15 Jun 2012 18:53:44 +0300 Subject: [PATCH] [PATCH 3/3] emacs: add notmuch hello refresh hook to display message count change --- a6/f6b0536a66f12106fdbfa9a6c64795f8ea5a9e | 130 ++++++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 a6/f6b0536a66f12106fdbfa9a6c64795f8ea5a9e diff --git a/a6/f6b0536a66f12106fdbfa9a6c64795f8ea5a9e b/a6/f6b0536a66f12106fdbfa9a6c64795f8ea5a9e new file mode 100644 index 000000000..64f5df43b --- /dev/null +++ b/a6/f6b0536a66f12106fdbfa9a6c64795f8ea5a9e @@ -0,0 +1,130 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id DEB10431FC0 + for ; Fri, 15 Jun 2012 08:53:59 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" +X-Spam-Flag: NO +X-Spam-Score: -0.7 +X-Spam-Level: +X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 + tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id EeV7ntdOqcul for ; + Fri, 15 Jun 2012 08:53:58 -0700 (PDT) +Received: from mail-lpp01m010-f53.google.com (mail-lpp01m010-f53.google.com + [209.85.215.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 59EDB431FC3 + for ; Fri, 15 Jun 2012 08:53:55 -0700 (PDT) +Received: by mail-lpp01m010-f53.google.com with SMTP id u2so2337793lag.26 + for ; Fri, 15 Jun 2012 08:53:55 -0700 (PDT) +X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=google.com; s=20120113; + h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references + :in-reply-to:references:x-gm-message-state; + bh=VzQTZiy3GXoadDahhaTRSeWkIxyRvSSBTnWReEwUKuA=; + b=jFuZUquyWou+uQ8pWWnQyhzJ1MJ8JxlxkESWfTMcoMW4B5zZ15kECODQgT4wLuh4gi + PodetXshlHLX7eNnjUUoIBWV/Ipp5W8csFZ3VHQe4z8+KCCxVNnaAL5D9A1LJXMFopbk + EuFVc3tAUWlNytsIHat3m0dP6QuriMHT9yjqw5YrwjAy5HGZggZML970gKzTYWCWGrxc + kHbo1kJ4YgXsUJ6eCehEEE21srWV5AI1QWXyvJunfKG1tPFeVuHoWYnJIINb9fzVl372 + eFuDLfiGNefRmKCkKHectkZy3Bx2fB4FG0//8AEewQqia+DrXpCWAqP/fW2JLdD0EpmQ + iePw== +Received: by 10.152.123.244 with SMTP id md20mr6085677lab.0.1339775634962; + Fri, 15 Jun 2012 08:53:54 -0700 (PDT) +Received: from localhost (dsl-hkibrasgw4-fe50dc00-68.dhcp.inet.fi. + [80.220.80.68]) + by mx.google.com with ESMTPS id k4sm6420333lbb.12.2012.06.15.08.53.53 + (version=SSLv3 cipher=OTHER); Fri, 15 Jun 2012 08:53:54 -0700 (PDT) +From: Jani Nikula +To: notmuch@notmuchmail.org +Subject: [PATCH 3/3] emacs: add notmuch hello refresh hook to display message + count change +Date: Fri, 15 Jun 2012 18:53:44 +0300 +Message-Id: + <627aea74b0080dcd903b801042a4b2fd3868c049.1339775602.git.jani@nikula.org> +X-Mailer: git-send-email 1.7.9.5 +In-Reply-To: + <37899e28dbf67e4620a53279a869be3174c02d6f.1339775602.git.jani@nikula.org> +References: + <37899e28dbf67e4620a53279a869be3174c02d6f.1339775602.git.jani@nikula.org> +In-Reply-To: + <37899e28dbf67e4620a53279a869be3174c02d6f.1339775602.git.jani@nikula.org> +References: + <37899e28dbf67e4620a53279a869be3174c02d6f.1339775602.git.jani@nikula.org> +X-Gm-Message-State: + ALoCoQmAdPfZETe1lMt1mGspoGL/Rp63pYH801N/czhy0CG82foGlZnajh8/CbCjZBaFs5cVfy0D +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Fri, 15 Jun 2012 15:54:00 -0000 + +Add a notmuch hello refresh hook to display a message about change in +message count in the database since the notmuch-hello buffer was last +refreshed manually (no-display is nil). + +Signed-off-by: Jani Nikula +--- + emacs/notmuch-hello.el | 27 +++++++++++++++++++++++++++ + 1 file changed, 27 insertions(+) + +diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el +index bc43178..bcca044 100644 +--- a/emacs/notmuch-hello.el ++++ b/emacs/notmuch-hello.el +@@ -148,6 +148,7 @@ International Bureau of Weights and Measures." + (defcustom notmuch-hello-refresh-hook nil + "Functions called after updating a `notmuch-hello' buffer." + :type 'hook ++ :options '(notmuch-hello-refresh-status-message) + :group 'notmuch-hello + :group 'notmuch-hooks) + +@@ -749,6 +750,32 @@ following: + (let ((fill-column (- (window-width) notmuch-hello-indent))) + (center-region start (point))))) + ++(defvar notmuch-hello-refresh-count 0 ++ "Number of messages in the database when `notmuch-hello' was last run. ++ ++Used internally by `notmuch-hello-refresh-status-message'.") ++ ++(defun notmuch-hello-refresh-status-message (no-display) ++ "Hook to display a status message when refreshing notmuch-hello buffer. ++ ++Display a status message about the difference in message count in ++the database since the last call." ++ (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)))) ++ + ;;;###autoload + (defun notmuch-hello (&optional no-display) + "Run notmuch and display saved searches, known tags, etc." +-- +1.7.9.5 + -- 2.26.2