From: Edward Z. Yang Date: Fri, 26 Jun 2009 17:10:01 +0000 (-0400) Subject: add custom-search hook, for shortcuts for custom search queries X-Git-Url: https://git.cworth.org/git?a=commitdiff_plain;h=8a9f8761acc318f2bfb852480d6076dabb131825;p=sup add custom-search hook, for shortcuts for custom search queries Signed-off-by: Edward Z. Yang --- diff --git a/lib/sup/hook.rb b/lib/sup/hook.rb index 0a0a2f6..33a97b2 100644 --- a/lib/sup/hook.rb +++ b/lib/sup/hook.rb @@ -19,6 +19,11 @@ class HookManager attr_writer :__locals + ## an annoying gotcha here is that if you try something + ## like var = var.foo(), var will magically get allocated + ## to Nil and method_missing will never get called. You + ## can work around this by calling self.var or simply + ## not assigning it to itself. def method_missing m, *a case @__locals[m] when Proc diff --git a/lib/sup/index.rb b/lib/sup/index.rb index ca01ee7..9c985d9 100644 --- a/lib/sup/index.rb +++ b/lib/sup/index.rb @@ -24,6 +24,16 @@ class Index include Singleton + HookManager.register "custom-search", < s) || s + + subs = subs.gsub(/\b(to|from):(\S+)\b/) do field, name = $1, $2 if(p = ContactManager.contact_for(name)) [field, p.email]