[PATCH 2/9] lib: private string map (associative array) API
[notmuch-archives.git] / 2f / 680506e1e049f7cc83bcc3245227615a8fc5d9
1 Return-Path: <dmitry.kurochkin@gmail.com>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id 0E567431FD0\r
6         for <notmuch@notmuchmail.org>; Wed, 21 Dec 2011 10:19:12 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.799\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5\r
12         tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
13         FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
14 Received: from olra.theworths.org ([127.0.0.1])\r
15         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
16         with ESMTP id rmuuDcDGwBTK for <notmuch@notmuchmail.org>;\r
17         Wed, 21 Dec 2011 10:19:11 -0800 (PST)\r
18 Received: from mail-ww0-f45.google.com (mail-ww0-f45.google.com\r
19  [74.125.82.45])        (using TLSv1 with cipher RC4-SHA (128/128 bits))        (No client\r
20  certificate requested) by olra.theworths.org (Postfix) with ESMTPS id\r
21  701AA431FB6    for <notmuch@notmuchmail.org>; Wed, 21 Dec 2011 10:19:11 -0800\r
22  (PST)\r
23 Received: by wgbds13 with SMTP id ds13so11998557wgb.2\r
24         for <notmuch@notmuchmail.org>; Wed, 21 Dec 2011 10:19:10 -0800 (PST)\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;\r
26         h=from:to:subject:date:message-id:x-mailer;\r
27         bh=VFbLg3hqzrMHEMHjAlbUFCXiKTHQOoRNapLoHHtscXw=;\r
28         b=d+mTeRdConGv8BEvGjeRlKKkL8v0AlRPQJaZxpci3ckTd7o/yw/DrgcoQZEEzBa+oX\r
29         N+nZeVNHGs3LxbleqW6pJ43ZxnNIz1F23cZow1WnwGvk8Zc7U4ErMt6ILOKypF184HAL\r
30         GghjTtk/nm0M2NcGJtJbuP0QKG00jL6jBDarY=\r
31 Received: by 10.227.59.205 with SMTP id m13mr7325535wbh.28.1324491550125;\r
32         Wed, 21 Dec 2011 10:19:10 -0800 (PST)\r
33 Received: from localhost ([91.144.186.21])\r
34         by mx.google.com with ESMTPS id en10sm2805632wbb.11.2011.12.21.10.19.09\r
35         (version=TLSv1/SSLv3 cipher=OTHER);\r
36         Wed, 21 Dec 2011 10:19:09 -0800 (PST)\r
37 From: Dmitry Kurochkin <dmitry.kurochkin@gmail.com>\r
38 To: notmuch@notmuchmail.org\r
39 Subject: [PATCH 1/2] test: add general Emacs hook counter\r
40 Date: Wed, 21 Dec 2011 22:18:25 +0400\r
41 Message-Id: <1324491506-1134-1-git-send-email-dmitry.kurochkin@gmail.com>\r
42 X-Mailer: git-send-email 1.7.7.3\r
43 X-BeenThere: notmuch@notmuchmail.org\r
44 X-Mailman-Version: 2.1.13\r
45 Precedence: list\r
46 List-Id: "Use and development of the notmuch mail system."\r
47         <notmuch.notmuchmail.org>\r
48 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
49         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
50 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
51 List-Post: <mailto:notmuch@notmuchmail.org>\r
52 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
53 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
54         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
55 X-List-Received-Date: Wed, 21 Dec 2011 18:19:12 -0000\r
56 \r
57 Replace `notmuch-hello-mode-hook-counter' with general `hook-counter'\r
58 and `add-hook-counter' functions to allow counting calls for any hook.\r
59 ---\r
60  test/test-lib.el |   21 +++++++++++++--------\r
61  1 files changed, 13 insertions(+), 8 deletions(-)\r
62 \r
63 diff --git a/test/test-lib.el b/test/test-lib.el\r
64 index 3bca138..83b8a65 100644\r
65 --- a/test/test-lib.el\r
66 +++ b/test/test-lib.el\r
67 @@ -62,11 +62,16 @@ running, quit if it terminated."\r
68        (kill-emacs)\r
69      (run-at-time "1 min" nil 'orphan-watchdog pid)))\r
70  \r
71 -(defun notmuch-hello-mode-hook-counter ()\r
72 -  "Count how many times `notmuch-hello-mode-hook' is called.\r
73 -Increments `notmuch-hello-mode-hook-counter' variable value if it\r
74 -is bound, otherwise does nothing."\r
75 -  (if (boundp 'notmuch-hello-mode-hook-counter)\r
76 -      (setq notmuch-hello-mode-hook-counter\r
77 -           (1+ notmuch-hello-mode-hook-counter))))\r
78 -(add-hook 'notmuch-hello-mode-hook 'notmuch-hello-mode-hook-counter)\r
79 +(defun hook-counter (hook)\r
80 +  "Count how many times a hook is called.  Increments\r
81 +`hook'-counter variable value if it is bound, otherwise does\r
82 +nothing."\r
83 +  (let ((counter (intern (concat (symbol-name hook) "-counter"))))\r
84 +    (if (boundp counter)\r
85 +       (set counter (1+ (symbol-value counter))))))\r
86 +\r
87 +(defun add-hook-counter (hook)\r
88 +  "Add hook to count how many times `hook' is called."\r
89 +  (add-hook hook (apply-partially 'hook-counter hook)))\r
90 +\r
91 +(add-hook-counter 'notmuch-hello-mode-hook)\r
92 -- \r
93 1.7.7.3\r
94 \r