From: Michael Stapelberg <michael+sup@stapelberg.de>
To: Rich Lane <rlane@club.cc.cmu.edu>
Cc: sup-devel <sup-devel@rubyforge.org>
Subject: Re: [sup-devel] [PATCH] Use multiple body arrays when calling before-edit for each reply type
Date: Tue, 09 Mar 2010 23:58:33 +0100 [thread overview]
Message-ID: <1268175393-sup-8314@midna.zekjur.net> (raw)
In-Reply-To: <1267295207-sup-7090@zyrg.net>
[-- Attachment #1: Type: text/plain, Size: 530 bytes --]
Hi Rich,
Excerpts from Rich Lane's message of Sa Feb 27 19:29:27 +0100 2010:
> 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
[-- Attachment #2: 0001-Use-multiple-body-arrays-when-calling-before-edit-fo.patch --]
[-- Type: application/octet-stream, Size: 2475 bytes --]
From f939770ebe1a46b39d4f17c1c5447d71f79fb8bf Mon Sep 17 00:00:00 2001
From: Michael Stapelberg <michael@stapelberg.de>
Date: Tue, 9 Mar 2010 23:56:02 +0100
Subject: [PATCH] Use multiple body arrays when calling before-edit for each reply type
This allows for before-edit hooks which modify the body of the message
based on the different headers (previously, they could only modify
headers).
As an example, I use it to sign mail in english if one of the recipients
(not *the* recipient, but one of them) is speaking english.
---
lib/sup/modes/reply-mode.rb | 17 +++++++++++++++--
1 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/lib/sup/modes/reply-mode.rb b/lib/sup/modes/reply-mode.rb
index 3d39a8a..d6d6cd1 100644
--- a/lib/sup/modes/reply-mode.rb
+++ b/lib/sup/modes/reply-mode.rb
@@ -42,6 +42,7 @@ EOS
def initialize message, type_arg=nil
@m = message
+ @edited = false
## it's important to put this early because it forces a read of
## the full headers (most importantly the list-post header, if
@@ -150,11 +151,13 @@ EOS
:recipient
end)
+ @bodies = {}
@headers.each do |k, v|
- HookManager.run "before-edit", :header => v, :body => body
+ @bodies[k] = Array.new(body)
+ HookManager.run "before-edit", :header => v, :body => @bodies[k]
end
- super :header => @headers[@type_selector.val], :body => body, :twiddles => false
+ super :header => @headers[@type_selector.val], :body => @bodies[@type_selector.val], :twiddles => false
add_selector @type_selector
end
@@ -164,6 +167,9 @@ protected
super
if @headers[@type_selector.val] != self.header
self.header = @headers[@type_selector.val]
+ if !@edited
+ self.body = @bodies[@type_selector.val]
+ end
update
end
end
@@ -172,6 +178,9 @@ protected
super
if @headers[@type_selector.val] != self.header
self.header = @headers[@type_selector.val]
+ if !@edited
+ self.body = @bodies[@type_selector.val]
+ end
update
end
end
@@ -188,6 +197,10 @@ protected
end
def handle_new_text new_header, new_body
+ if new_body != @bodies[@type_selector.val]
+ @bodies[@type_selector.val] = new_body
+ @edited = true
+ end
old_header = @headers[@type_selector.val]
if new_header.size != old_header.size || old_header.any? { |k, v| new_header[k] != v }
@type_selector.set_to :user
--
1.6.5
[-- Attachment #3: Type: text/plain, Size: 143 bytes --]
_______________________________________________
Sup-devel mailing list
Sup-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-devel
next prev parent reply other threads:[~2010-03-09 22:58 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-20 22:30 Michael Stapelberg
2010-02-27 18:29 ` Rich Lane
2010-03-09 22:58 ` Michael Stapelberg [this message]
2010-03-12 4:20 ` Rich Lane
2010-03-12 10:17 ` Michael Stapelberg
2010-03-15 5:09 ` Rich Lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1268175393-sup-8314@midna.zekjur.net \
--to=michael+sup@stapelberg.de \
--cc=rlane@club.cc.cmu.edu \
--cc=sup-devel@rubyforge.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox