Subject: Re: [sup-talk] reply-from.rb troubles

From: Philipp Überbacher <[email-masked]>
Date: Sun, 17 Jan 2010 21:08:15 +0100

Excerpts from William Morgan's message of Sun Jan 17 20:45:38 +0100 2010:
> Reformatted excerpts from Philipp Überbacher's message of 2010-01-17:
> > [Sun Jan 17 20:21:19 +0100 2010] Looks like replying to a mailinglist.
> > [Sun Jan 17 20:21:19 +0100 2010] This is person hollunder
> > <[email-masked]>
> 
> You see this and *then*, in the reply-mode buffer, you see a different
> address in the From: field? I don't see how that's possible.
> 
> > btw., does anyone have tips regarding copy/pasting with vim? I always
> > have to trim lots of whitespace.
> 
> :set :paste should do it.

But this is exactly what I see in the log when replying to this message:
[Sun Jan 17 21:00:33 +0100 2010] Looks like replying to a mailinglist.
[Sun Jan 17 21:00:33 +0100 2010] This is person hollunder
<[email-masked]>

And the address was set to [email-masked] again..

Now that you say this is impossible, I had a look at my before-edit.rb
and suspect it to be the culprit, since it ends with:
else                                                                                                                                                         
  header["From"] = "Philipp Überbacher <[email-masked]>"                                                                                                  
end

Now how can one do both without trouble, replying sanely and using a sane address for new messages?

And sorry for the trouble, I should have thought about that other hook earlier..

Regards,
Philipp

_______________________________________________
sup-talk mailing list
[email-masked]
http://rubyforge.org/mailman/listinfo/sup-talk

---

From: Philipp Überbacher <[email-masked]>
Date: Sun, 17 Jan 2010 17:40:36 +0100

Excerpts from William Morgan's message of Sun Jan 17 17:01:31 +0100 2010:
> > So it seems the issue is that
> > Person.from_address "<[email-masked]>"
> > doesn't get executed or doesn't work for some reason.
> > 
> > I don't know what's the issue here...
> 
> When I copy your code to my reply-from.rb, add a label "mailinglists" to
> a message, and reply, I see "From: hollunder <[email-masked]>".
> So, it works for me...
> 
> You can add more logging and see what Person object it's returning.
> Failing that, you can add some info statements to reply-mode.rb and see
> what's happening in there.

Now I did:
if message.has_label? :mailinglists
  info "Looks like replying to a mailinglist."
  Person.from_address "<[email-masked]>"
  a = Person.from_address "<[email-masked]>"
  info 'This is Person.from_address "<[email-masked]>": '
elsif message.has_label? :murks_lavabit
  info "Looks like replying with default."
  Person.from_address "<[email-masked]>"
end

Which is probably not clever, but I got:
[Sun Jan 17 17:38:17 +0100 2010] Looks like replying to a mailinglist.
[Sun Jan 17 17:38:17 +0100 2010] This is Person.from_address
"<[email-masked]>":
[Sun Jan 17 17:38:17 +0100 2010] reply-from returned non-Person, using
default from.

It seems this is trying to tell me what's wrong..

---

From: Philipp Überbacher <[email-masked]>
Date: Fri, 15 Jan 2010 21:38:23 +0100

Excerpts from Tero Tilus's message of Fri Jan 15 19:41:15 +0100 2010:
> Philipp Überbacher, 2010-01-15 18:03:
> > It currently looks like this:
> > 
> > if message.has_label?(:mailinglists)
> >   Person.from_address("<[email-masked]>")
> > elsif message.has_label?(:murks_lavabit)
> >   Person.from_address("<[email-masked]>")
> > end
> > 
> > Yet it replies to messages with label mailinglists using murks@.
> 
> Have you tried[1] what Person.from_address("<[email-masked]>")
> actually returns?  I bet its nil and thus sup uses default address.
> You can try it interactively for example using sup console, it is your
> dearest friend when you debug.

>> Person.from_address("<[email-masked]>")
=> #<Redwood::Person:0x7f6d045b1ff8
 @email="[email-masked]",
  @name="hollunder">

> Iirc #from_address expects plain email address.  Try
> 
> if message.has_label?(:mailinglists)
>   Person.from_address("[email-masked]")
> elsif message.has_label?(:murks_lavabit)
>   Person.from_address("[email-masked]")
> end

Changing that changed nothing, as I'm writing this it's at default
again and I have to edit it manually.
I usually restarted sup, this time I did clear_hooks tough, which
returned nil.

---

From: Philipp Überbacher <[email-masked]>
Date: Sun, 17 Jan 2010 20:23:35 +0100

Excerpts from Cameron Matheson's message of Sun Jan 17 19:30:30 +0100 2010:
> Excerpts from Philipp Überbacher's message of Sun Jan 17 09:40:36 -0700 2010:
> > Now I did:
> It looks like your hook is now returning the output of info instead of a
> person.  Try this:
> 
>   p = Person.from_address "<[email-masked]>"
>   info "This is person #{p.full_address}"
>   p

This is the output:

Regards,
Philipp

---

From: Tero Tilus <[email-masked]>
Date: Fri, 15 Jan 2010 20:41:15 +0200

-- 
Tero Tilus ## 050 3635 235 ## http://tero.tilus.net/
_______________________________________________
sup-talk mailing list
[email-masked]
http://rubyforge.org/mailman/listinfo/sup-talk

---

From: Philipp Überbacher <[email-masked]>
Date: Sun, 17 Jan 2010 03:01:16 +0100

Excerpts from Tero Tilus's message of Sat Jan 16 22:38:16 +0100 2010:
> Philipp Überbacher, 2010-01-15 22:38:
> >> actually returns?
> So no problem there.  Does your log show anything when replying?  If
> not, you could add logging to your hook (logging things you do in your
> hooks ain't a bad habit).
> 
>   info "Looks like replying as murks."
I added said lines but after attempting a reply I don't see the messages
in any log files. So far I've discovered in ~/.sup/ exception-log.txt
and sup-exception-log.txt but I see none of these entries in there.
Where are those supposed to end up?

Regards,
Philipp

---

From: Philipp Überbacher <[email-masked]>
Date: Sun, 17 Jan 2010 16:43:07 +0100

Excerpts from William Morgan's message of Sun Jan 17 16:24:36 +0100 2010:
> Reformatted excerpts from Philipp Überbacher's message of 2010-01-16:
> > I added said lines but after attempting a reply I don't see the
> > messages in any log files. So far I've discovered in ~/.sup/
> > exception-log.txt and sup-exception-log.txt but I see none of these
> > entries in there.  Where are those supposed to end up?
> 
> In the log buffer. If you hit ';' you'll see it.

Thanks. Now when replying to this message I see:
[Sun Jan 17 16:37:06 +0100 2010] Looks like replying to a mailinglist.

Yet it doesn't use the right address.
This is the hook:

Thanks,
Philipp

---

From: Cameron Matheson <[email-masked]>
Date: Sun, 17 Jan 2010 11:30:30 -0700

---

From: Philipp Überbacher <[email-masked]>
Date: Fri, 15 Jan 2010 17:03:54 +0100

Yet it replies to messages with label mailinglists using murks@... which is the default address.
I really don't know what to do...

Regards,
Philipp

---

From: William Morgan <[email-masked]>
Date: Sun, 17 Jan 2010 14:45:38 -0500

:set :paste should do it.
-- 
William <[email-masked]>
_______________________________________________
sup-talk mailing list
[email-masked]
http://rubyforge.org/mailman/listinfo/sup-talk

---

From: hollunder <[email-masked]>
Date: Wed, 20 Jan 2010 22:50:03 +0100

Excerpts from William Morgan's message of Sun Jan 17 21:36:01 +0100 2010:
> Hah, nice catch. That would do it.
> 
> I think the proper answer is to change reply-mode, so that any addresses
> set by the reply-* hooks overrides anything set by the before-edit hook.
> 
> In the mean time, you can probably work around this with a nasty hack: in
> before-edit hook, if the "In-reply-to" header is set, don't set the From
> address (because it is a reply, and will have been set by the reply-from
> hook).

It took me a while to get to it since I was kind of afraid of ruby, but
I tried today and it seems to work like this:

if header["In-reply-to"] = nil
        if header["To"] =~ /talk|list|lists|linux|devel|user|daw/
                header["From"] = "Philipp Überbacher <[email-masked]>"
        else
                header["From"] = "Philipp Überbacher <[email-masked]>"
        end
end

Thanks a lot. I recommended sup today on my distros mailinglist and briefly showed it to some colleagues who had never seen something like it.

Regards,
Philipp

---

From: William Morgan <[email-masked]>
Date: Sun, 17 Jan 2010 10:24:36 -0500

---

From: William Morgan <[email-masked]>
Date: Sun, 17 Jan 2010 15:36:01 -0500

---

From: Tero Tilus <[email-masked]>
Date: Sat, 16 Jan 2010 23:38:16 +0200

---

From: William Morgan <[email-masked]>
Date: Sun, 17 Jan 2010 11:01:31 -0500