From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/66921 Path: news.gmane.org!not-for-mail From: Ted Zlatanov Newsgroups: gmane.emacs.gnus.general Subject: Re: Wrappers for gnus-extract-address-components Date: Wed, 07 May 2008 14:04:08 -0500 Organization: =?utf-8?B?0KLQtdC+0LTQvtGAINCX0LvQsNGC0LDQvdC+0LI=?= @ Cienfuegos Message-ID: <86fxsuueaf.fsf@lifelogs.com> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1210186942 5675 80.91.229.12 (7 May 2008 19:02:22 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 7 May 2008 19:02:22 +0000 (UTC) To: ding@gnus.org Original-X-From: ding-owner+M15399=ding+2Daccount=gmane.org@lists.math.uh.edu Wed May 07 21:02:58 2008 Return-path: Envelope-to: ding-account@gmane.org Original-Received: from util0.math.uh.edu ([129.7.128.18]) by lo.gmane.org with esmtp (Exim 4.50) id 1Jtou9-0004ID-4q for ding-account@gmane.org; Wed, 07 May 2008 21:02:17 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.math.uh.edu) by util0.math.uh.edu with smtp (Exim 4.63) (envelope-from ) id 1JtotQ-0003PC-FD for ding-account@gmane.org; Wed, 07 May 2008 14:01:32 -0500 Original-Received: from mx1.math.uh.edu ([129.7.128.32]) by util0.math.uh.edu with esmtps (TLSv1:AES256-SHA:256) (Exim 4.63) (envelope-from ) id 1JtotP-0003P7-Fp for ding@lists.math.uh.edu; Wed, 07 May 2008 14:01:31 -0500 Original-Received: from quimby.gnus.org ([80.91.231.51]) by mx1.math.uh.edu with esmtp (Exim 4.67) (envelope-from ) id 1JtotJ-0005Uw-6G for ding@lists.math.uh.edu; Wed, 07 May 2008 14:01:31 -0500 Original-Received: from mail.blockstar.com ([170.224.69.95]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1JtotW-00078K-00 for ; Wed, 07 May 2008 21:01:38 +0200 Original-Received: from tzlatanov-ubuntu-desktop.jumptrading.com (unknown [38.98.147.130]) by mail.blockstar.com (Postfix) with ESMTP id 1A7DD7D909D for ; Wed, 7 May 2008 12:12:45 -0700 (PDT) X-Face: bd.DQ~'29fIs`T_%O%C\g%6jW)yi[zuz6;d4V0`@y-~$#3P_Ng{@m+e4o<4P'#(_GJQ%TT= D}[Ep*b!\e,fBZ'j_+#"Ps?s2!4H2-Y"sx" X-Hashcash: 1:20:080507:ding@gnus.org::4mpFZNkBtWgyt8JT:00001jbP In-Reply-To: (Reiner Steib's message of "Wed, 07 May 2008 20:08:49 +0200") User-Agent: Gnus/5.110009 (No Gnus v0.9) Emacs/23.0.60 (gnu/linux) X-Spam-Score: -2.6 (--) List-ID: Precedence: bulk Xref: news.gmane.org gmane.emacs.gnus.general:66921 Archived-At: (please note my address still shows up in CVS commits but has not been otherwise active in 7 years) On Wed, 07 May 2008 20:08:49 +0200 Reiner Steib wrote: RS> On Wed, May 07 2008, Ted Zlatanov on ding-patches: >> * gnus-util.el (gnus-extract-address-component-name) >> (gnus-extract-address-component-email): Convenience functions around >> `gnus-extract-address-components'. RS> I doubt that we need these wrappers. Just using `car' and `cadr' is RS> sufficiently convenient for me. IMO, car/cadr used in this fashion are annoying in code because you have to know the data structure (from comments or reading the source further). It's cleaner for someone reading the code to see (gnus-extract-address-component-email sender) than (cadr (gnus-extract-address-components sender)) I think it's nice to have these, obviously, but if you don't like them then just remove them and adjust gnus-registry.el accordingly. OTOH if you decide they are OK to stay, I can look through all the Gnus code to see if I should rewrite anything to use the wrappers. >> +(defun gnus-extract-address-component-name (from) >> + "Extract name from a From header. >> +Uses `gnus-extract-address-components'." >> + (nth 0 (gnus-extract-address-components from))) >> + >> +(defun gnus-extract-address-component-email (from) >> + "Extract e-mail address from a From header. >> +Uses `gnus-extract-address-components'." >> + (nth 1 (gnus-extract-address-components from))) RS> When introducing such wrapper, we might use (funcall RS> gnus-extract-address-components ...) instead. RS> And the names should be something more simple like `...-extract-name' RS> and `...-extract-address'. As they should be usable in `message.el' RS> as well, we should put them in `gmm-utils.el' to avoid code like this: RS> (funcall (if (boundp gnus-extract-address-components) RS> gnus-extract-address-components RS> 'mail-extract-address-components) RS> from) mail-extract-address-components and gnus-extract-address-components can return different things, that's why I didn't merge them in the wrapper. If you think it's useful, feel free to make the change. I don't have an opinion. The function name doesn't matter much to me, so renaming to remove -component from the name is fine. But I won't do it until you decide if the wrappers are staying. RS> Or, `gnus-extract-address-components' could use an optional argument, RS> which can have the values 'name or 'address. I think it's a very common thing to require the address or name from a >From header, so these functions should not be hidden behind an optional argument. I realize it's not good to clutter the namespace, but these functions are pretty basic for Gnus since it's a MUA. Also, gnus-extract-address-components returns a list, and with the optional argument it wouldn't, which is unnecessarily inconsistent. You could make it always return a list but then there's no point to have the wrapper. Ted