Re: [PATCH v2] contrib: pick: use notmuch-clean-address
authorTomi Ollila <tomi.ollila@iki.fi>
Sat, 1 Dec 2012 20:44:41 +0000 (22:44 +0200)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:51:17 +0000 (09:51 -0800)
0a/1237ceabc46714e5a06cf0dfead2b0aa4d764d [new file with mode: 0644]

diff --git a/0a/1237ceabc46714e5a06cf0dfead2b0aa4d764d b/0a/1237ceabc46714e5a06cf0dfead2b0aa4d764d
new file mode 100644 (file)
index 0000000..d32d730
--- /dev/null
@@ -0,0 +1,156 @@
+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 45FEA431FBC\r
+       for <notmuch@notmuchmail.org>; Sat,  1 Dec 2012 12:44:51 -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 iP74RVSn4QLW for <notmuch@notmuchmail.org>;\r
+       Sat,  1 Dec 2012 12:44:46 -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 54CBD431FAF\r
+       for <notmuch@notmuchmail.org>; Sat,  1 Dec 2012 12:44:46 -0800 (PST)\r
+Received: from guru.guru-group.fi (localhost [IPv6:::1])\r
+       by guru.guru-group.fi (Postfix) with ESMTP id 1877B1000D0;\r
+       Sat,  1 Dec 2012 22:44:42 +0200 (EET)\r
+From: Tomi Ollila <tomi.ollila@iki.fi>\r
+To: Mark Walters <markwalters1009@gmail.com>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH v2] contrib: pick: use notmuch-clean-address\r
+In-Reply-To: <1354384922-14237-1-git-send-email-markwalters1009@gmail.com>\r
+References: <m28v9hhmhw.fsf@guru.guru-group.fi>\r
+       <1354384922-14237-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 22:44:41 +0200\r
+Message-ID: <m2sj7ptscm.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 20:44:51 -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
+> A neater version following Tomi's suggestion.\r
+\r
+LGTM (again :).\r
+\r
+Tomi\r
+\r
+\r
+>  contrib/notmuch-pick/notmuch-pick.el |   63 ++++-----------------------------\r
+>  1 files changed, 8 insertions(+), 55 deletions(-)\r
+>\r
+> diff --git a/contrib/notmuch-pick/notmuch-pick.el b/contrib/notmuch-pick/notmuch-pick.el\r
+> index eca1cba..a5005be 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
+> @@ -528,62 +527,16 @@ 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
+> +    (or p-name p-address)))\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