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