Subject: [sup-talk] Attempt at reply-from hook

From: [email-masked] (Edward Z. Yang)
Date: Mon, 01 Jun 2009 19:18:26 -0400

Hello,

I'm attempting to create a reply-from.rb hook that looks like this:

if message.has_label? 'twp':
    Person.from_address "Edward Z. Yang <edwardzyang at thewritingpot.com>"
end

Unfortunately, it doesn't seem to work. I'm running sup v0.7.

Cheers,
Edward

---

From: [email-masked] (Ingmar Vanhassel)
Date: Wed, 03 Jun 2009 00:09:16 +0200

>     Person.from_address "Edward Z. Yang <edwardzyang at thewritingpot.com>"

if message.has_label? twp
    Person.from_address "Edward Z. Yang <edwardzyang at thewritingpot.com>"
end

> Unfortunately, it doesn't seem to work. I'm running sup v0.7.

If the above doesn't work, post some relevant error output.

> Edward

Regards,
Ingmar

---

From: [email-masked] (Edward Z. Yang)
Date: Tue, 02 Jun 2009 22:54:02 -0400

> If the above doesn't work, post some relevant error output.

It silently fails. Is there any Sup way of making debug messages in
hooks?

Cheers,
Edward

---

From: [email-masked] (Ben Walton)
Date: Wed, 03 Jun 2009 07:44:24 -0400

> It silently fails. Is there any Sup way of making debug messages in

Redwood::log "my message"

Then, look in the log buffer.

HTH.
-Ben

-- 
Ben Walton
Systems Programmer - CHASS
University of Toronto
C:416.407.5610 | W:416.978.4302

GPG Key Id: 8E89F6D2; Key Server: pgp.mit.edu
Contact me to arrange for a CAcert assurance meeting.
-------------- 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/20090603/2d66ef11/attachment.bin>

---

From: [email-masked] (Edward Z. Yang)
Date: Fri, 05 Jun 2009 01:24:36 -0400

> Then, look in the log buffer.

I tried probing several ways.

- The reply-from.rb hook is being called.
- The message variable does exist.
- The message.has_label? "mylabel" returns false, as the body of the if
  statement never gets logged. (My contention is that the message very
  clearly has that label, so wtf).
- It is difficult to get a str representation of the message

I am still stymied.

Cheers,
Edward

---

From: [email-masked] (William Morgan)
Date: Fri, 05 Jun 2009 06:37:02 -0700

Reformatted excerpts from Edward Z. Yang's message of 2009-06-04:
> The message.has_label? "mylabel" returns false, as the body of the if

Try has_label? :mylabel. Sup represents labels as symbols instead of as
strings.

Sorry about that. The hook system is in need of much documentation.

A good environment for playing around with this stuff is to run the console:

  w at drspaceman:~/devel/sup$ sh devel/console.sh 
  [...]
  >> Index.run_query "label:potato"
  => [1000]
  >> m = Index.build_message 1000
  => #<Redwood::Message:0x7f187b394ac8 [...]>
  >> m.labels
  => [:inbox, :unread, :potato]
  >> m.has_label? :potato
  => true
  >> m.has_label? "potato"
  => false

HTH.
-- 
William <wmorgan-sup at masanjin.net>

---

From: [email-masked] (Edward Z. Yang)
Date: Fri, 05 Jun 2009 20:09:13 -0400

> Try has_label? :mylabel. Sup represents labels as symbols instead of as

Great! My hook works now. This is the sort of functionality that I think
is worth generalizing and implementing as a configuration twiddle (one,
I think, that should be on by default.)

>   => [:inbox, :unread, :potato]

Nice!

Cheers,
Edward

---

From: [email-masked] (William Morgan)
Date: Mon, 08 Jun 2009 14:34:31 -0700

Reformatted excerpts from Edward Z. Yang's message of 2009-06-05:
> Great! My hook works now. This is the sort of functionality that I
> think is worth generalizing and implementing as a configuration
> twiddle (one, I think, that should be on by default.)

I have a strong preference for hooks over configuration variables. Look
at the .muttrc documentation for why.
-- 
William <wmorgan-sup at masanjin.net>

---

From: [email-masked] (Edward Z. Yang)
Date: Mon, 08 Jun 2009 17:59:39 -0400

> at the .muttrc documentation for why.

There's an interesting usability argument there.  Right now, I still (possibly
naively) believe that if you organize your configuration properly, you can
have an arbitrarily large amount of it.

What's your opinion on making this default behavior, with no configuration
twiddle?

Cheers,
Edward

---

From: [email-masked] (Edward Z. Yang)
Date: Mon, 08 Jun 2009 20:12:44 -0400

Excerpts from Marc Hartstein's message of Mon Jun 08 19:09:16 -0400 2009:
> Reading the thread, it's not clear exactly what your hook does, or what
> behavior you want as the default.  I didn't see anything which said what
> you were trying to accomplish.

My apologies.

My sup email comes from three distinct sources, and as part of my
configuration they get a label as such (mit, twp or ita).  This label
is the most visible way of telling me which source my mail came from.

I am subscribed to numerous mailing lists, however, which do not
explicitly list my mail address in To or CC. As a result, Sup defaults
to my "main address".

What I would like Sup to do is look at the label, find the appropriate
source, and use the email in the source to populate the From field.
This is different from what you describe below.

> Attempting to figure it out from your code samples, I'm guessing that
> you're trying to get sup to always reply with a from address of the
> known address of yours found in the recipient list of the email being
> relied to, if any?

If Sup doesn't do the correct thing in this case, this additional hook
would be useful.

> I do get the sense that there might be a lot of people out there who
> want to use the default (always use default account) behavior, so I'm
> not sure about switching the default.  I wouldn't exactly be against it,
> though.

I would argue that most people have at least a personal and a work
email account, and that it is not appropriate to conflate the two.
They can write a hook that overrides an address (or, horror horror,
a twiddle in sources) to do it.

Cheers,
Edward

---

From: [email-masked] (Edward Z. Yang)
Date: Tue, 09 Jun 2009 00:06:40 -0400

Excerpts from Marc Hartstein's message of Mon Jun 08 23:46:48 -0400 2009:
> I think that's beyond what I'd personally think of as a "configuration
> twiddle", though...

Perhaps.

> You'd do it by, what, having a 1:1 mapping between email addresses and
> labels somewhere in the configuration, anything coming to the email
> address gets the label, and any reply to a message with the label
> (however it got it) gets the email address?

Yes.

> (It's also not as though the hook to only use your default address is
> hard to write.)

Indeed.

Cheers,
Edward

---

From: [email-masked] (William Morgan)
Date: Tue, 09 Jun 2009 09:52:37 -0700

> I think that's beyond what I'd personally think of as a "configuration

I tend to agree. I completely understand the use case, and I agree it's
probably a common one, but this is exactly the kind of thing I want to
address with hooks instead of with configuration. (Not that there's
*really* a distinction between these two things in the first place.)

Then when the next guy comes along and says, "I like this but I want my
from address based on X instead of the label", I can also avoid having
to do any work.

Edward, if you want to invest time on making this particular scheme easy
for users, I would be happy to include contributed hooks as part of the
Sup distribution, and you can supply one that reads a simple
configuration file and produces this behavior.
-- 
William <wmorgan-sup at masanjin.net>

---

From: [email-masked] (Edward Z. Yang)
Date: Wed, 10 Jun 2009 23:38:12 -0400

> configuration file and produces this behavior.

The thing is that this needs no configuration: sources.yaml will
tell us the correspondence between label and email.  If anything,
I would bill this as an improvement to the "From" detection algorithm.

Cheers,
Edward