[PATCH 1/5] open_reply: fallback to use addr.local if addr.name is nil
authorKirill A. Shutemov <kirill@shutemov.name>
Mon, 28 Jan 2013 15:52:16 +0000 (17:52 +0200)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:53:23 +0000 (09:53 -0800)
bb/ab682f79b046dfa713ecdf7f4286413095e29e [new file with mode: 0644]

diff --git a/bb/ab682f79b046dfa713ecdf7f4286413095e29e b/bb/ab682f79b046dfa713ecdf7f4286413095e29e
new file mode 100644 (file)
index 0000000..e34cbe2
--- /dev/null
@@ -0,0 +1,80 @@
+Return-Path: <kas@shutemov.name>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id D00F1431FAF\r
+       for <notmuch@notmuchmail.org>; Mon, 28 Jan 2013 07:57:08 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
+       autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id iSOU33VkFZT4 for <notmuch@notmuchmail.org>;\r
+       Mon, 28 Jan 2013 07:57:08 -0800 (PST)\r
+X-Greylist: delayed 380 seconds by postgrey-1.32 at olra;\r
+       Mon, 28 Jan 2013 07:57:08 PST\r
+Received: from shutemov.name (shutemov.name [204.155.152.216])\r
+       by olra.theworths.org (Postfix) with ESMTP id 1E6C0431FAE\r
+       for <notmuch@notmuchmail.org>; Mon, 28 Jan 2013 07:57:08 -0800 (PST)\r
+Received: by shutemov.name (Postfix, from userid 1000)\r
+       id 23CD0333D9; Mon, 28 Jan 2013 17:52:25 +0200 (EET)\r
+From: "Kirill A. Shutemov" <kirill@shutemov.name>\r
+To: Felipe Contreras <felipe.contreras@gmail.com>\r
+Subject: [PATCH 1/5] open_reply: fallback to use addr.local if addr.name is\r
+ nil\r
+Date: Mon, 28 Jan 2013 17:52:16 +0200\r
+Message-Id: <1359388340-27136-2-git-send-email-kirill@shutemov.name>\r
+X-Mailer: git-send-email 1.7.10.4\r
+In-Reply-To: <1359388340-27136-1-git-send-email-kirill@shutemov.name>\r
+References: <1359388340-27136-1-git-send-email-kirill@shutemov.name>\r
+Cc: notmuch@notmuchmail.org\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Mon, 28 Jan 2013 15:57:09 -0000\r
+\r
+From: "Kirill A. Shutemov" <kirill@shutemov.name>\r
+\r
+If address doesn't contain name we end up with " wrote:" as a reply\r
+header. It doesn't look nice.\r
+\r
+Let's use addr.local + "@" if name is not defined. If addr.local is not\r
+defined too, let's just use "somebody".\r
+\r
+Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>\r
+---\r
+ notmuch-ruby.vim |    6 +++++-\r
+ 1 file changed, 5 insertions(+), 1 deletion(-)\r
+\r
+diff --git a/notmuch-ruby.vim b/notmuch-ruby.vim\r
+index 761c87f..d8a9878 100644\r
+--- a/notmuch-ruby.vim\r
++++ b/notmuch-ruby.vim\r
+@@ -492,7 +492,11 @@ ruby << EOF\r
+                       lines << ''\r
\r
+                       body_lines = []\r
+-                      body_lines << "%s wrote:" % Mail::Address.new(orig[:from].value).name\r
++                      addr = Mail::Address.new(orig[:from].value)\r
++                      name = addr.name\r
++                      name = addr.local + "@" if name.nil? && !addr.local.nil?\r
++                      name = "somebody" if name.nil?\r
++                      body_lines << "%s wrote:" % name\r
+                       part = orig.find_first_text\r
+                       part.convert.each_line do |l|\r
+                               body_lines << "> %s" % l.chomp\r
+-- \r
+1.7.10.4\r
+\r