Subject: Re: [sup-devel] [PATCH] Use multiple body arrays when calling before-edit for each reply type

From: Rich Lane <[email-masked]>
Date: Sat, 27 Feb 2010 13:29:27 -0500

What happens when you edit the message and then select another reply type?
_______________________________________________
Sup-devel mailing list
[email-masked]
http://rubyforge.org/mailman/listinfo/sup-devel

---

From: Michael Stapelberg <[email-masked]>
Date: Fri, 12 Mar 2010 11:17:44 +0100

Hi Rich,

Excerpts from Rich Lane's message of Fr Mär 12 05:20:52 +0100 2010:
> lib/sup/modes/reply-mode.rb:
> > +      @bodies[k] = Array.new(body)
> 
> Why is the body in an array?
That was left over while refactoring. It isn’t necessary.

> The idiomatic way to write this is:
> self.body = @bodies[@type_selector.val] unless @edited
Alright, changed.

> lib/sup/modes/reply-mode.rb:
> > +    if new_body != @bodies[@type_selector.val]
> > +      @bodies[@type_selector.val] = new_body
> > +      @edited = true
> > +    end
> 
> Is there a reason we can't do this unconditionally?
Yes, I wanted to avoid setting the @edited flag if the user exited the editor
without making any changes. That way, he can benefit from the changing bodies
for a longer time.

Updated patch attached.

Best regards,
Michael

---

From: Michael Stapelberg <[email-masked]>
Date: Wed, 20 Jan 2010 23:30:11 +0100

Hi,

I created a hook which modified the body of each new message to look like my
usual skeleton for mails (greeting, content, signature). I did not use the
signature function for that because I wanted to put in the greeting with the
correct recipient.

Now I wanted to make this even more comfortable for me by checking if the
recipient of my mail is speaking english and thus using the english signature
instead of the german one. This was possible to a certain degree, but failed
when I wanted to see if any of the CC'ed addresses matched a certain pattern.

Attached to this mail you can find a patch which will copy the body object
for each type of headers (sender, recipient, all, list) and use the right
version of it in each case (like for the headers).

I am not completely suure if the patch is 100% correct, so please review it
thoroughly. It works for me, though.

Best regards,
Michael

---

From: Rich Lane <[email-masked]>
Date: Thu, 11 Mar 2010 23:20:52 -0500

lib/sup/modes/reply-mode.rb:
> +      if !@edited
> +        self.body = @bodies[@type_selector.val]
> +      end

The EditMessageMode constructor also calls the before-edit hook, but I
guess if it wasn't broken before it won't be now.

---

From: Michael Stapelberg <[email-masked]>
Date: Tue, 09 Mar 2010 23:58:33 +0100

Hi Rich,

> What happens when you edit the message and then select another reply type?
You are right, there was a problem here. I reworked the patch, it now behaves
like this:
As long as you did not edit the message, selecting another reply type changes
the body. As soon as you edit one of the bodies, only the headers will be
changed if you switch to a different reply type.

You find the new version of the patch attached to this mail.

Best regards,
Michael

---

From: Rich Lane <[email-masked]>
Date: Mon, 15 Mar 2010 01:09:23 -0400

Applied to master.