Re: [PATCH] emacs: Split the function notmuch-show-clean-address
authorTomi Ollila <tomi.ollila@iki.fi>
Tue, 31 Jul 2012 07:47:22 +0000 (10:47 +0300)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:48:41 +0000 (09:48 -0800)
73/e2228a906ebe62d4c6e13bee44d1f2fbad8255 [new file with mode: 0644]

diff --git a/73/e2228a906ebe62d4c6e13bee44d1f2fbad8255 b/73/e2228a906ebe62d4c6e13bee44d1f2fbad8255
new file mode 100644 (file)
index 0000000..aaeb5fe
--- /dev/null
@@ -0,0 +1,121 @@
+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 9F0BD431FAF\r
+       for <notmuch@notmuchmail.org>; Tue, 31 Jul 2012 00:47:14 -0700 (PDT)\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 vXrjVQMBqqCq for <notmuch@notmuchmail.org>;\r
+       Tue, 31 Jul 2012 00:47:13 -0700 (PDT)\r
+Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
+       by olra.theworths.org (Postfix) with ESMTP id B73F1431FAE\r
+       for <notmuch@notmuchmail.org>; Tue, 31 Jul 2012 00:47:13 -0700 (PDT)\r
+Received: by guru.guru-group.fi (Postfix, from userid 501)\r
+       id 76F4710036F; Tue, 31 Jul 2012 10:47:22 +0300 (EEST)\r
+From: Tomi Ollila <tomi.ollila@iki.fi>\r
+To: Mark Walters <markwalters1009@gmail.com>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH] emacs: Split the function notmuch-show-clean-address\r
+In-Reply-To: <87ehnw84e5.fsf@qmul.ac.uk>\r
+References: <87ehnw84e5.fsf@qmul.ac.uk>\r
+User-Agent: Notmuch/0.13.2+103~g9610d35 (http://notmuchmail.org) Emacs/23.1.1\r
+       (x86_64-redhat-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: Tue, 31 Jul 2012 10:47:22 +0300\r
+Message-ID: <m2mx2gl6d1.fsf@guru.guru-group.fi>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\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: Tue, 31 Jul 2012 07:47:14 -0000\r
+\r
+On Sat, Jul 28 2012, Mark Walters <markwalters1009@gmail.com> wrote:\r
+\r
+> This function is also used by pick so split it out. Since, pick and show\r
+> want a slightly different combination of name and email make the\r
+> separated function return them as a pair, and let show or pick extract\r
+> the combination they want from that.\r
+> ---\r
+\r
+Put notmuch-clean-address before notmuch-show-clean-address so that\r
+byte compilation don't complain about missing function.\r
+\r
+(or move it to another file --- maybe later if it is sensible thing to do)\r
+\r
+You could return the name-address pair as cons cell instead of list (?).\r
+\r
+(If you continue to use list you can replace (car (cdr ...)) with (cadr ...))\r
+\r
+Anyway, LGTM.\r
+\r
+Tomi\r
+\r
+>\r
+> This change allows the removal of about 50 lines of duplicated code from\r
+> notmuch-pick. Later, we may want to move the split out function to lib.\r
+>\r
+>  emacs/notmuch-show.el |   19 ++++++++++++++-----\r
+>  1 files changed, 14 insertions(+), 5 deletions(-)\r
+>\r
+> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+> index 6335d45..0d8569d 100644\r
+> --- a/emacs/notmuch-show.el\r
+> +++ b/emacs/notmuch-show.el\r
+> @@ -354,6 +354,19 @@ operation on the contents of the current buffer."\r
+>  (defun notmuch-show-clean-address (address)\r
+>    "Try to clean a single email ADDRESS for display.  Return\r
+>  unchanged ADDRESS if parsing fails."\r
+> +  (let* ((clean-address (notmuch-clean-address address))\r
+> +     (p-address (car clean-address))\r
+> +     (p-name (car (cdr clean-address))))\r
+> +    ;; If no name, return just the address.\r
+> +    (if (not p-name)\r
+> +    p-address\r
+> +      ;; Otherwise format the name and address together.\r
+> +      (concat p-name " <" p-address ">"))))\r
+> +\r
+> +(defun notmuch-clean-address (address)\r
+> +  "Try to clean a single email ADDRESS for display.\r
+> +Return (AUTHOR_EMAIL AUTHOR_NAME). Return (ADDRESS nil) if\r
+> +parsing fails."\r
+>    (condition-case nil\r
+>      (let (p-name p-address)\r
+>        ;; It would be convenient to use `mail-header-parse-address',\r
+> @@ -401,11 +414,7 @@ unchanged ADDRESS if parsing fails."\r
+>        (when (string= p-name p-address)\r
+>      (setq p-name nil))\r
+>  \r
+> -      ;; If no name results, return just the address.\r
+> -      (if (not p-name)\r
+> -      p-address\r
+> -    ;; Otherwise format the name and address together.\r
+> -    (concat p-name " <" p-address ">")))\r
+> +      (list p-address p-name))\r
+>      (error address)))\r
+>  \r
+>  (defun notmuch-show-insert-headerline (headers date tags depth)\r
+> -- \r
+> 1.7.9.1\r
+>\r
+> _______________________________________________\r
+> notmuch mailing list\r
+> notmuch@notmuchmail.org\r
+> http://notmuchmail.org/mailman/listinfo/notmuch\r