From: Damien Leone <damien.leone@fensalir.fr>
To: sup-devel <sup-devel@rubyforge.org>
Subject: Re: [sup-devel] [PATCHES] reply-mode, signatures and account selector
Date: Wed, 09 Jun 2010 15:15:11 +0200 [thread overview]
Message-ID: <1276089233-sup-510@mailer> (raw)
In-Reply-To: <1276087951-sup-7816@mailer>
[-- Attachment #1: Type: text/plain, Size: 1758 bytes --]
I noticed an error in the third patch.
Please consider the one attached to *this* email.
Regards,
Excerpts from Damien Leone's message of mer. juin 09 14:53:16 +0200 2010:
> Sup guys,
>
> Three patches are attached to this email, the commit messages should
> be self explanatory but here are some more details:
>
> As the first patch changes the way headers are handled in reply-mode
> there is a regression in the before-edit hook possibilities.
> Before, we could write something like:
>
> if header["Cc"] == "foo"
> header["Bcc"] = "bar"
> end
>
> Hence, switching the reply-to type using the selector would have
> changed the Bcc field if a type using Cc was selected.
>
> This would be no longer possible since there is now only one "set" of
> headers running the hook, however if you properly wrote your reply-to
> hook you can select the reply type you want and the previous code
> will be working as expected.
>
> On the other hand (in my opinion), the reply-mode now handles better
> its job, that is to say changing To and Cc without interfering with
> other fields that might have been edited manually by the user.
>
> I asked rlane about this on IRC:
> > <dleone> what is the reason for the before-edit hook being runned on @bodies and @header for each Reply-To types?
> > <rlane> that's so that when you switch reply-to type the right signature/etc is displayed
>
> I see no regression regarding this in the patch, so it should be okay.
>
> Other patches add an account selector in edit-mode (it is useful to me
> and I saw requests for such a feature) and a better signature handling
> regarding the edit_signature option.
>
> Regards,
--
Damien Leone <damien.leone@fensalir.fr>
Web: http://dleone.fensalir.fr/
GPG: 0x82EB4DDF
[-- Attachment #2: 0003-edit-mode-change-the-way-signatures-are-handled.patch --]
[-- Type: application/octet-stream, Size: 3257 bytes --]
From ef92e54e0cea12fb4ad42a18808d490d6cd4e084 Mon Sep 17 00:00:00 2001
From: Damien Leone <damien.leone@fensalir.fr>
Date: Wed, 9 Jun 2010 15:12:15 +0200
Subject: [PATCH 3/3] edit-mode: change the way signatures are handled
The current signatures handling was not suitable for account changing
in edit-mode. It was working fine when the edit_signature option was
false, but it could have a better behaviour if this option was
enabled.
This commit tries to do this by appending the signature to the body
text if the edit_signature is true, then after editing the message it
checks if the signature has been modified by comparing the end of the
file to the current account's signature. If it has been edited then we
stick to it by setting @sig_edited to true, otherwise the signature
will still be automatically changed if another account is selected.
---
lib/sup/modes/edit-message-mode.rb | 21 ++++++++++++++++++---
1 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/lib/sup/modes/edit-message-mode.rb b/lib/sup/modes/edit-message-mode.rb
index dd89b7b..672fd2b 100644
--- a/lib/sup/modes/edit-message-mode.rb
+++ b/lib/sup/modes/edit-message-mode.rb
@@ -81,7 +81,7 @@ EOS
@header_lines = []
@body = opts.delete(:body) || []
- @body += sig_lines if $config[:edit_signature] && !opts.delete(:have_signature)
+ @sig_edited = false
if opts[:attachments]
@attachments = opts[:attachments].values
@@ -166,12 +166,14 @@ EOS
def edit_subject; edit_field "Subject" end
def edit_message
+ sig = sig_lines.join("\n")
old_from = @header["From"] if @account_selector
@file = Tempfile.new "sup.#{self.class.name.gsub(/.*::/, '').camel_to_hyphy}"
@file.puts format_headers(@header - NON_EDITABLE_HEADERS).first
@file.puts
@file.puts @body.join("\n")
+ @file.puts sig if ($config[:edit_signature] and !@sig_edited)
@file.close
editor = $config[:editor] || ENV['EDITOR'] || "/usr/bin/vi"
@@ -185,6 +187,19 @@ EOS
header, @body = parse_file @file.path
@header = header - NON_EDITABLE_HEADERS
+ if $config[:edit_signature]
+ pbody = @body.join("\n")
+ blen = pbody.length
+ slen = sig.length
+
+ if blen > slen and pbody[blen-slen..blen] == sig
+ @sig_edited = false
+ @body = pbody[0..blen-slen].split("\n")
+ else
+ @sig_edited = true
+ end
+ end
+
if @account_selector and @header["From"] != old_from
@account_user = @header["From"]
@account_selector.set_to nil
@@ -288,7 +303,7 @@ protected
def regen_text
header, @header_lines = format_headers(@header - NON_EDITABLE_HEADERS) + [""]
@text = header + [""] + @body
- @text += sig_lines unless $config[:edit_signature]
+ @text += sig_lines unless @sig_edited
@attachment_lines_offset = 0
@@ -394,7 +409,7 @@ protected
m = RMail::Message.new
m.header["Content-Type"] = "text/plain; charset=#{$encoding}"
m.body = @body.join("\n")
- m.body += sig_lines.join("\n") unless $config[:edit_signature]
+ m.body += "\n" + sig_lines.join("\n") unless @sig_edited
## body must end in a newline or GPG signatures will be WRONG!
m.body += "\n" unless m.body =~ /\n\Z/
--
1.7.1
[-- 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-06-09 13:15 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-09 12:53 Damien Leone
2010-06-09 13:15 ` Damien Leone [this message]
2010-07-03 17:22 ` Damien Leone
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=1276089233-sup-510@mailer \
--to=damien.leone@fensalir.fr \
--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