On Tue, 17 Apr 2012 13:13:15 +0400, Dmitry Kurochkin <dmitry.kuroch...@gmail.com> wrote: > Jani Nikula <j...@nikula.org> writes: > > > 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). > > I like this idea. But IMO we should avoid another call to notmuch > count. Notmuch-hello buffer already displays the message count on the > first line. I would propose to implement this functionality not as a > hook but as part of the section which outputs the first line. We can > add an option to disable it if you prefer but I do not think it is > needed. This is less flexible than a hook, but IMO it is not a big > issue.
And what if someone has disabled the header section but would want the message? Also, you'd have to pass no-display there too. IMHO one call to notmuch count is not a big issue, especially for an optional feature. And having it as a hook very nicely isolates the feature from everything else. Jani. > > Regards, > Dmitry > > > --- > > emacs/notmuch-hello.el | 23 +++++++++++++++++++++++ > > 1 files changed, 23 insertions(+), 0 deletions(-) > > > > diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el > > index 0596bbe..13da146 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) > > > > @@ -729,6 +730,28 @@ 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." > > + (unless no-display > > + (let* ((new-count > > + (string-to-number (car (process-lines notmuch-command "count")))) > > + (diff-count (- new-count notmuch-hello-refresh-count))) > > + (if (= notmuch-hello-refresh-count 0) > > + (message "You have %s messages." > > + (notmuch-hello-nice-number new-count)) > > + (if (not (= diff-count 0)) > > + (if (>= diff-count 0) > > + (message "You have %s more messages since last refresh." > > + (notmuch-hello-nice-number diff-count)) > > + (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.1 > > > > _______________________________________________ > > notmuch mailing list > > notmuch@notmuchmail.org > > http://notmuchmail.org/mailman/listinfo/notmuch _______________________________________________ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch