Subject: [sup-talk] Setting reply to -- hook or config?

From: [email-masked] (Jeff Balogh)
Date: Sat, 05 Apr 2008 01:48:14 -0400

I'm terrible at remembering to reply to all, and today I realized that sup can
help!

I started off making a reply-to hook that takes the array of types sup is
planning to offer in the Reply To field.  I thought the hook would do some fancy
logic and return the right type.  Then I realized I could just list the order of
my reply-to preferences, and pick the first element of the intersection.

  ([:list, :all] & types)[0]

The return value is only used if it's in the types array, so no worries about
nil.

A hook seems like overkill for this one-liner, so maybe it would be more
appropriate for config.yaml?  It makes sense as something in config, but I
hesitate because it would be the first code object (well, the first that _looks_
like code), and because less config variables is good.

-- jeff

---

From: [email-masked] (Jeff Balogh)
Date: Thu, 24 Apr 2008 01:23:10 -0400

I prefer to reply to a mailing list, then all participants:

  $ cat .sup/hooks/reply-to.rb
  ([:list, :all] & types)[0]
---
I've been happily using this locally, and forgot to send it to the list. :P

 lib/sup/modes/reply-mode.rb |   15 ++++++++++++++-
 1 files changed, 14 insertions(+), 1 deletions(-)

diff --git a/lib/sup/modes/reply-mode.rb b/lib/sup/modes/reply-mode.rb
index e7b2929..ad50fed 100644
--- a/lib/sup/modes/reply-mode.rb
+++ b/lib/sup/modes/reply-mode.rb
@@ -19,6 +19,14 @@ Return value:
   A string containing the text of the quote line (can be multi-line)
 EOS
 
+  HookManager.register "reply-to", <<EOS
+Set the Reply To field.
+Variables:
+  types: the valid types to choose from
+Return value:
+  The reply type you desire, or nil to let sup set it.
+EOS
+
   def initialize message
     @m = message
 
@@ -92,8 +100,13 @@ EOS
     types = REPLY_TYPES.select { |t| @headers.member?(t) }
     @type_selector = HorizontalSelector.new "Reply to:", types, types.map { |x| TYPE_DESCRIPTIONS[x] }
 
+    hook_reply = HookManager.run "reply-to", :types => types
+    Redwood::log hook_reply.to_s
+
     @type_selector.set_to(
-      if @m.is_list_message?
+      if types.include? hook_reply
+        hook_reply
+      elsif @m.is_list_message?
         :list
       elsif @headers.member? :sender
         :sender
-- 
1.5.5.1

---

From: [email-masked] (Marc Hartstein)
Date: Thu, 24 Apr 2008 01:56:00 -0400

>   ([:list, :all] & types)[0]

Neat.  For reference for anybody interested in using this, possible
values are in lib/sup/modes/reply-mode.rb:5

:sender => "Sender",
:recipient => "Recipient",
:all => "All",
:list => "Mailing list",
:user => "Customized"

The default behavior should be equivalent [see line 97] to
([:list, :sender, :recipient] & types)[0]

Is there a reason you ended up going with a hook?

I wonder if the hook should be provided with the current message for
fuller processing.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://rubyforge.org/pipermail/sup-talk/attachments/20080424/1ab3f2e6/attachment.bin

---

From: [email-masked] (Jeff Balogh)
Date: Thu, 24 Apr 2008 10:38:28 -0400

> ([:list, :sender, :recipient] & types)[0]

Thanks.  Your documentation skills far exceed mine. :)

> Is there a reason you ended up going with a hook?

1. Laziness.
2. Reluctance to add to config.
3. Because I expected someone might want to be fancier, maybe getting the
message for fuller processing.

> I wonder if the hook should be provided with the current message for

If you (or anyone) finds that useful, we can add it.  I left it out to keep the
hook simple.