Re: [PATCH v2] emacs: Split the function notmuch-show-clean-address
authorTomi Ollila <tomi.ollila@iki.fi>
Tue, 31 Jul 2012 17:59:40 +0000 (20:59 +0300)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:48:41 +0000 (09:48 -0800)
6f/78e12a0124110636f2748746404f417fc8fbeb [new file with mode: 0644]

diff --git a/6f/78e12a0124110636f2748746404f417fc8fbeb b/6f/78e12a0124110636f2748746404f417fc8fbeb
new file mode 100644 (file)
index 0000000..9cffe31
--- /dev/null
@@ -0,0 +1,123 @@
+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 6B38F431FAF\r
+       for <notmuch@notmuchmail.org>; Tue, 31 Jul 2012 10:59:32 -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 DpZdulzsrYRW for <notmuch@notmuchmail.org>;\r
+       Tue, 31 Jul 2012 10:59:31 -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 8BA0C431FAE\r
+       for <notmuch@notmuchmail.org>; Tue, 31 Jul 2012 10:59:31 -0700 (PDT)\r
+Received: by guru.guru-group.fi (Postfix, from userid 501)\r
+       id 95BD110036F; Tue, 31 Jul 2012 20:59:40 +0300 (EEST)\r
+From: Tomi Ollila <tomi.ollila@iki.fi>\r
+To: Mark Walters <markwalters1009@gmail.com>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH v2] emacs: Split the function notmuch-show-clean-address\r
+In-Reply-To: <878vdzzyfg.fsf@qmul.ac.uk>\r
+References: <87ehnw84e5.fsf@qmul.ac.uk> <m2mx2gl6d1.fsf@guru.guru-group.fi>\r
+       <87boivzyls.fsf@qmul.ac.uk> <878vdzzyfg.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 20:59:40 +0300\r
+Message-ID: <m21ujrn75f.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 17:59:32 -0000\r
+\r
+On Tue, Jul 31 2012, Mark Walters <markwalters1009@gmail.com> wrote:\r
+\r
+> This function is also used by pick so split it out in preperation for\r
+> moving to lib. In fact, pick and show want a slightly different\r
+> combination of name and email on return so make the separated function\r
+> return them as a pair, and let show or pick extract the combination\r
+> they want from that.\r
+> ---\r
+>  emacs/notmuch-show.el |   27 ++++++++++++++++++---------\r
+>  1 files changed, 18 insertions(+), 9 deletions(-)\r
+>\r
+> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+> index 6335d45..4ab6f92 100644\r
+> --- a/emacs/notmuch-show.el\r
+> +++ b/emacs/notmuch-show.el\r
+> @@ -351,9 +351,10 @@ operation on the contents of the current buffer."\r
+>                                           'face 'notmuch-tag-face)\r
+>                               ")"))))))\r
+>  \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
+> +(defun notmuch-clean-address (address)\r
+> +  "Try to clean a single email ADDRESS for display. Return a cons\r
+> +cell of (AUTHOR_EMAIL AUTHOR_NAME). Return (ADDRESS nil) if\r
+> +parsing fails."\r
+\r
+Looks good to me.\r
+\r
+It took a few iterations to understand that the error case in expression\r
+below can be experimented with:\r
+\r
+(condition-case nil (error "caught") (error (cons "car" "cdr"))) c-x c-e\r
+\r
+Tomi\r
+\r
+>    (condition-case nil\r
+>      (let (p-name p-address)\r
+>        ;; It would be convenient to use `mail-header-parse-address',\r
+> @@ -401,12 +402,20 @@ 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
+> -    (error address)))\r
+> +      (cons p-address p-name))\r
+> +    (error (cons address nil))))\r
+> +\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 (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-show-insert-headerline (headers date tags depth)\r
+>    "Insert a notmuch style headerline based on HEADERS for a\r
+> -- \r
+> 1.7.9.1\r
+>\r
+> _______________________________________________\r
+> notmuch mailing list\r
+> notmuch@notmuchmail.org\r
+> http://notmuchmail.org/mailman/listinfo/notmuch\r