[PATCH 1/5] open_reply: fallback to use addr.local if addr.name is nil

Subject: [PATCH 1/5] open_reply: fallback to use addr.local if addr.name is nil

Date: Mon, 28 Jan 2013 17:52:16 +0200

To: Felipe Contreras

Cc: notmuch@notmuchmail.org

From: Kirill A. Shutemov


From: "Kirill A. Shutemov" <kirill@shutemov.name>

If address doesn't contain name we end up with " wrote:" as a reply
header. It doesn't look nice.

Let's use addr.local + "@" if name is not defined. If addr.local is not
defined too, let's just use "somebody".

Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
---
 notmuch-ruby.vim |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/notmuch-ruby.vim b/notmuch-ruby.vim
index 761c87f..d8a9878 100644
--- a/notmuch-ruby.vim
+++ b/notmuch-ruby.vim
@@ -492,7 +492,11 @@ ruby << EOF
 			lines << ''
 
 			body_lines = []
-			body_lines << "%s wrote:" % Mail::Address.new(orig[:from].value).name
+			addr = Mail::Address.new(orig[:from].value)
+			name = addr.name
+			name = addr.local + "@" if name.nil? && !addr.local.nil?
+			name = "somebody" if name.nil?
+			body_lines << "%s wrote:" % name
 			part = orig.find_first_text
 			part.convert.each_line do |l|
 				body_lines << "> %s" % l.chomp
-- 
1.7.10.4


Thread: