--- /dev/null
+Return-Path: <dmitry.kurochkin@gmail.com>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by olra.theworths.org (Postfix) with ESMTP id 0E567431FD0\r
+ for <notmuch@notmuchmail.org>; Wed, 21 Dec 2011 10:19:12 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.799\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5\r
+ tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+ FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id rmuuDcDGwBTK for <notmuch@notmuchmail.org>;\r
+ Wed, 21 Dec 2011 10:19:11 -0800 (PST)\r
+Received: from mail-ww0-f45.google.com (mail-ww0-f45.google.com\r
+ [74.125.82.45]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client\r
+ certificate requested) by olra.theworths.org (Postfix) with ESMTPS id\r
+ 701AA431FB6 for <notmuch@notmuchmail.org>; Wed, 21 Dec 2011 10:19:11 -0800\r
+ (PST)\r
+Received: by wgbds13 with SMTP id ds13so11998557wgb.2\r
+ for <notmuch@notmuchmail.org>; Wed, 21 Dec 2011 10:19:10 -0800 (PST)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;\r
+ h=from:to:subject:date:message-id:x-mailer;\r
+ bh=VFbLg3hqzrMHEMHjAlbUFCXiKTHQOoRNapLoHHtscXw=;\r
+ b=d+mTeRdConGv8BEvGjeRlKKkL8v0AlRPQJaZxpci3ckTd7o/yw/DrgcoQZEEzBa+oX\r
+ N+nZeVNHGs3LxbleqW6pJ43ZxnNIz1F23cZow1WnwGvk8Zc7U4ErMt6ILOKypF184HAL\r
+ GghjTtk/nm0M2NcGJtJbuP0QKG00jL6jBDarY=\r
+Received: by 10.227.59.205 with SMTP id m13mr7325535wbh.28.1324491550125;\r
+ Wed, 21 Dec 2011 10:19:10 -0800 (PST)\r
+Received: from localhost ([91.144.186.21])\r
+ by mx.google.com with ESMTPS id en10sm2805632wbb.11.2011.12.21.10.19.09\r
+ (version=TLSv1/SSLv3 cipher=OTHER);\r
+ Wed, 21 Dec 2011 10:19:09 -0800 (PST)\r
+From: Dmitry Kurochkin <dmitry.kurochkin@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 1/2] test: add general Emacs hook counter\r
+Date: Wed, 21 Dec 2011 22:18:25 +0400\r
+Message-Id: <1324491506-1134-1-git-send-email-dmitry.kurochkin@gmail.com>\r
+X-Mailer: git-send-email 1.7.7.3\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Wed, 21 Dec 2011 18:19:12 -0000\r
+\r
+Replace `notmuch-hello-mode-hook-counter' with general `hook-counter'\r
+and `add-hook-counter' functions to allow counting calls for any hook.\r
+---\r
+ test/test-lib.el | 21 +++++++++++++--------\r
+ 1 files changed, 13 insertions(+), 8 deletions(-)\r
+\r
+diff --git a/test/test-lib.el b/test/test-lib.el\r
+index 3bca138..83b8a65 100644\r
+--- a/test/test-lib.el\r
++++ b/test/test-lib.el\r
+@@ -62,11 +62,16 @@ running, quit if it terminated."\r
+ (kill-emacs)\r
+ (run-at-time "1 min" nil 'orphan-watchdog pid)))\r
+ \r
+-(defun notmuch-hello-mode-hook-counter ()\r
+- "Count how many times `notmuch-hello-mode-hook' is called.\r
+-Increments `notmuch-hello-mode-hook-counter' variable value if it\r
+-is bound, otherwise does nothing."\r
+- (if (boundp 'notmuch-hello-mode-hook-counter)\r
+- (setq notmuch-hello-mode-hook-counter\r
+- (1+ notmuch-hello-mode-hook-counter))))\r
+-(add-hook 'notmuch-hello-mode-hook 'notmuch-hello-mode-hook-counter)\r
++(defun hook-counter (hook)\r
++ "Count how many times a hook is called. Increments\r
++`hook'-counter variable value if it is bound, otherwise does\r
++nothing."\r
++ (let ((counter (intern (concat (symbol-name hook) "-counter"))))\r
++ (if (boundp counter)\r
++ (set counter (1+ (symbol-value counter))))))\r
++\r
++(defun add-hook-counter (hook)\r
++ "Add hook to count how many times `hook' is called."\r
++ (add-hook hook (apply-partially 'hook-counter hook)))\r
++\r
++(add-hook-counter 'notmuch-hello-mode-hook)\r
+-- \r
+1.7.7.3\r
+\r