--- /dev/null
+Return-Path: <tomi.ollila@iki.fi>\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 70A99431FBD\r
+ for <notmuch@notmuchmail.org>; Sat, 1 Dec 2012 06:32:03 -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 aOpc+tkHjX+q for <notmuch@notmuchmail.org>;\r
+ Sat, 1 Dec 2012 06:31:58 -0800 (PST)\r
+Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
+ by olra.theworths.org (Postfix) with ESMTP id 8EB8C431FAF\r
+ for <notmuch@notmuchmail.org>; Sat, 1 Dec 2012 06:31:58 -0800 (PST)\r
+Received: from guru.guru-group.fi (localhost [IPv6:::1])\r
+ by guru.guru-group.fi (Postfix) with ESMTP id D9D591000D0;\r
+ Sat, 1 Dec 2012 16:31:55 +0200 (EET)\r
+From: Tomi Ollila <tomi.ollila@iki.fi>\r
+To: Mark Walters <markwalters1009@gmail.com>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH] contrib: pick: use notmuch-clean-address\r
+In-Reply-To: <1354369006-1793-1-git-send-email-markwalters1009@gmail.com>\r
+References: <1354369006-1793-1-git-send-email-markwalters1009@gmail.com>\r
+User-Agent: Notmuch/0.14+116~g29fcdb5 (http://notmuchmail.org) Emacs/24.2.1\r
+ (x86_64-unknown-linux-gnu)\r
+X-Face: HhBM'cA~<r"^Xv\KRN0P{vn'Y"Kd;zg_y3S[4)KSN~s?O\"QPoL\r
+ $[Xv_BD:i/F$WiEWax}R(MPS`^UaptOGD`*/=@\1lKoVa9tnrg0TW?"r7aRtgk[F\r
+ !)g;OY^,BjTbr)Np:%c_o'jj,Z\r
+Date: Sat, 01 Dec 2012 16:31:55 +0200\r
+Message-ID: <m28v9hhmhw.fsf@guru.guru-group.fi>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain\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: Sat, 01 Dec 2012 14:32:03 -0000\r
+\r
+On Sat, Dec 01 2012, Mark Walters <markwalters1009@gmail.com> wrote:\r
+\r
+> Now notmuch-clean-address is split out in show pick can use that (with a small\r
+> wrapper).\r
+>\r
+> ---\r
+> This removes another 50 lines or so of duplicated code from notmuch-pick.\r
+>\r
+> Best wishes\r
+>\r
+> Mark\r
+>\r
+> contrib/notmuch-pick/notmuch-pick.el | 65 +++++----------------------------\r
+> 1 files changed, 10 insertions(+), 55 deletions(-)\r
+>\r
+> diff --git a/contrib/notmuch-pick/notmuch-pick.el b/contrib/notmuch-pick/notmuch-pick.el\r
+> index 5f9e456..6871d7b 100644\r
+> --- a/contrib/notmuch-pick/notmuch-pick.el\r
+> +++ b/contrib/notmuch-pick/notmuch-pick.el\r
+> @@ -35,7 +35,6 @@\r
+> (declare-function notmuch-show "notmuch-show" (&rest args))\r
+> (declare-function notmuch-tag "notmuch" (query &rest tags))\r
+> (declare-function notmuch-show-strip-re "notmuch-show" (subject))\r
+> -(declare-function notmuch-show-clean-address "notmuch-show" (parsed-address))\r
+> (declare-function notmuch-show-spaces-n "notmuch-show" (n))\r
+> (declare-function notmuch-read-query "notmuch" (prompt))\r
+> (declare-function notmuch-read-tag-changes "notmuch" (&optional initial-input &rest search-terms))\r
+> @@ -521,62 +520,18 @@ than only the current message."\r
+> (message (format "Command '%s' exited abnormally with code %d"\r
+> shell-command exit-code)))))))\r
+> \r
+> -;; Shamelessly stolen from notmuch-show.el: should be unified.\r
+> (defun notmuch-pick-clean-address (address)\r
+> - "Try to clean a single email ADDRESS for display. Return\r
+> + "Try to clean a single email ADDRESS for display. Return\r
+> +AUTHOR_NAME if present, otherwise return AUTHOR_EMAIL. Return\r
+> unchanged ADDRESS if parsing fails."\r
+> - (condition-case nil\r
+> - (let (p-name p-address)\r
+> - ;; It would be convenient to use `mail-header-parse-address',\r
+> - ;; but that expects un-decoded mailbox parts, whereas our\r
+> - ;; mailbox parts are already decoded (and hence may contain\r
+> - ;; UTF-8). Given that notmuch should handle most of the awkward\r
+> - ;; cases, some simple string deconstruction should be sufficient\r
+> - ;; here.\r
+> - (cond\r
+> - ;; "User <user@dom.ain>" style.\r
+> - ((string-match "\\(.*\\) <\\(.*\\)>" address)\r
+> - (setq p-name (match-string 1 address)\r
+> - p-address (match-string 2 address)))\r
+> -\r
+> - ;; "<user@dom.ain>" style.\r
+> - ((string-match "<\\(.*\\)>" address)\r
+> - (setq p-address (match-string 1 address)))\r
+> -\r
+> - ;; Everything else.\r
+> - (t\r
+> - (setq p-address address)))\r
+> -\r
+> - (when p-name\r
+> - ;; Remove elements of the mailbox part that are not relevant for\r
+> - ;; display, even if they are required during transport:\r
+> - ;;\r
+> - ;; Backslashes.\r
+> - (setq p-name (replace-regexp-in-string "\\\\" "" p-name))\r
+> -\r
+> - ;; Outer single and double quotes, which might be nested.\r
+> - (loop\r
+> - with start-of-loop\r
+> - do (setq start-of-loop p-name)\r
+> -\r
+> - when (string-match "^\"\\(.*\\)\"$" p-name)\r
+> - do (setq p-name (match-string 1 p-name))\r
+> -\r
+> - when (string-match "^'\\(.*\\)'$" p-name)\r
+> - do (setq p-name (match-string 1 p-name))\r
+> -\r
+> - until (string= start-of-loop p-name)))\r
+> -\r
+> - ;; If the address is 'foo@bar.com <foo@bar.com>' then show just\r
+> - ;; 'foo@bar.com'.\r
+> - (when (string= p-name p-address)\r
+> - (setq p-name nil))\r
+> -\r
+> - ;; If we have a name return that otherwise return the address.\r
+> - (if (not p-name)\r
+> - p-address\r
+> - p-name))\r
+> - (error address)))\r
+> + (let* ((clean-address (notmuch-clean-address address))\r
+> + (p-address (car clean-address))\r
+> + (p-name (cdr clean-address)))\r
+> +\r
+> + ;; If we have a name return that otherwise return the address.\r
+> + (if (not p-name)\r
+> + p-address\r
+> + p-name)))\r
+\r
+LGTM, but would this look so good... ?\r
+\r
+ ;; If we have a name return that otherwise return the address.\r
+ (or p-name p-address))\r
+\r
+Tomi\r
+\r
+\r
+> \r
+> (defun notmuch-pick-insert-field (field format-string msg)\r
+> (let* ((headers (plist-get msg :headers))\r
+> -- \r
+> 1.7.9.1\r
+>\r
+> _______________________________________________\r
+> notmuch mailing list\r
+> notmuch@notmuchmail.org\r
+> http://notmuchmail.org/mailman/listinfo/notmuch\r