From: Michael Stapelberg <michael+sup@stapelberg.de>
To: sup-devel <sup-devel@rubyforge.org>
Subject: [sup-devel] [PATCH] Use multiple body arrays when calling before-edit for each reply type
Date: Wed, 20 Jan 2010 23:30:11 +0100 [thread overview]
Message-ID: <1264026370-sup-8092@midna.zekjur.net> (raw)
[-- Attachment #1: Type: text/plain, Size: 899 bytes --]
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
[-- Attachment #2: 0001-Use-multiple-body-arrays-when-calling-before-edit-fo.patch --]
[-- Type: application/octet-stream, Size: 1777 bytes --]
From 96440145b5ea06e418ca301e01a1bfda5e1527e6 Mon Sep 17 00:00:00 2001
From: Michael Stapelberg <michael@stapelberg.de>
Date: Wed, 20 Jan 2010 23:23:12 +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 | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/lib/sup/modes/reply-mode.rb b/lib/sup/modes/reply-mode.rb
index 3d39a8a..7f1ae34 100644
--- a/lib/sup/modes/reply-mode.rb
+++ b/lib/sup/modes/reply-mode.rb
@@ -150,11 +150,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 +166,7 @@ protected
super
if @headers[@type_selector.val] != self.header
self.header = @headers[@type_selector.val]
+ self.body = @bodies[@type_selector.val]
update
end
end
@@ -172,6 +175,7 @@ protected
super
if @headers[@type_selector.val] != self.header
self.header = @headers[@type_selector.val]
+ self.body = @bodies[@type_selector.val]
update
end
end
--
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 reply other threads:[~2010-01-20 22:36 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-20 22:30 Michael Stapelberg [this message]
2010-02-27 18:29 ` Rich Lane
2010-03-09 22:58 ` Michael Stapelberg
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=1264026370-sup-8092@midna.zekjur.net \
--to=michael+sup@stapelberg.de \
--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