From: Dmitry Kurochkin <dmitry.kurochkin@gmail.com>
To: notmuch@notmuchmail.org
Subject: [PATCH 1/2] test: add general Emacs hook counter
Date: Wed, 21 Dec 2011 22:18:25 +0400 [thread overview]
Message-ID: <1324491506-1134-1-git-send-email-dmitry.kurochkin@gmail.com> (raw)
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
next reply other threads:[~2011-12-21 18:19 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-21 18:18 Dmitry Kurochkin [this message]
2011-12-21 18:18 ` [PATCH 2/2] test: add test for `notmuch-hello-refresh-hook' Dmitry Kurochkin
2011-12-21 21:49 ` Thomas Jost
2011-12-21 21:54 ` Dmitry Kurochkin
2011-12-21 22:09 ` Thomas Jost
2011-12-22 8:55 ` Tomi Ollila
2011-12-22 11:29 ` [PATCH 1/2] test: add general Emacs hook counter David Bremner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1324491506-1134-1-git-send-email-dmitry.kurochkin@gmail.com \
--to=dmitry.kurochkin@gmail.com \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).