Archive of RubyForge sup-talk mailing list
 help / color / mirror / Atom feed
* [sup-talk] [PATCH] New hook: after-save
@ 2009-05-26 15:14 Henri Ducrocq
  2009-05-28 15:07 ` William Morgan
  0 siblings, 1 reply; 2+ messages in thread
From: Henri Ducrocq @ 2009-05-26 15:14 UTC (permalink / raw)


This hook is run when the user presses on '$' to save the state and
index.
I'm using this to update a file used by my dzen status bar to display the
number of unread emails in my inbox.

diff --git a/lib/sup/modes/thread-index-mode.rb b/lib/sup/modes/thread-index-mode.rb
index 56dcdff..e3e70bb 100644
--- a/lib/sup/modes/thread-index-mode.rb
+++ b/lib/sup/modes/thread-index-mode.rb
@@ -20,6 +20,12 @@ Variables:
   thread: The message thread being marked as spam.
 EOS
 
+  HookManager.register "after-save", <<EOS
+Executes immediately after saving the index.
+Variables:
+num_inbox_total_unread: the total number of unread messages in the inbox
+EOS
+
   register_keymap do |k|
     k.add :load_threads, "Load #{LOAD_MORE_THREAD_NUM} more threads", 'M'
     k.add_multi "Load all threads (! to confirm) :", '!' do |kk|
@@ -409,6 +415,7 @@ EOS
         end
       end
     end
+    HookManager.run "after-save", :num_inbox_total_unread => lambda { Index.num_results_for :labels => [:inbox, :unread] }
   end
 
   def cleanup

-- 
Henri


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [sup-talk] [PATCH] New hook: after-save
  2009-05-26 15:14 [sup-talk] [PATCH] New hook: after-save Henri Ducrocq
@ 2009-05-28 15:07 ` William Morgan
  0 siblings, 0 replies; 2+ messages in thread
From: William Morgan @ 2009-05-28 15:07 UTC (permalink / raw)


Reformatted excerpts from Henri Ducrocq's message of 2009-05-26:
> This hook is run when the user presses on '$' to save the state and
> index.
> I'm using this to update a file used by my dzen status bar to display the
> number of unread emails in my inbox.

I think I'd prefer to modify the current after-poll hook to an
"after-state-change-hook" (or a better name) and have it fire after
either a poll or a save happens.
-- 
William <wmorgan-sup at masanjin.net>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-05-28 15:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-05-26 15:14 [sup-talk] [PATCH] New hook: after-save Henri Ducrocq
2009-05-28 15:07 ` William Morgan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox