Gnus development mailing list
 help / color / mirror / Atom feed
From: Ted Zlatanov <tzz@lifelogs.com>
To: ding@gnus.org
Subject: Re: Wrappers for gnus-extract-address-components
Date: Wed, 07 May 2008 14:04:08 -0500	[thread overview]
Message-ID: <86fxsuueaf.fsf@lifelogs.com> (raw)
In-Reply-To: <v9skwut2a6.fsf@marauder.physik.uni-ulm.de> (Reiner Steib's message of "Wed, 07 May 2008 20:08:49 +0200")

(please note my <Teodor.Zlatanov@divine.com> 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 <reinersteib+gmane@imap.cc> 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



  reply	other threads:[~2008-05-07 19:04 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <E1Jtlls-0003wE-00@quimby.gnus.org>
2008-05-07 18:08 ` Wrappers for gnus-extract-address-components (was: [...] gnus-util.el) Reiner Steib
2008-05-07 19:04   ` Ted Zlatanov [this message]
2008-05-07 22:17     ` Mail address in the commit lists (was: Wrappers for gnus-extract-address-components) Reiner Steib
2008-05-07 22:19     ` Reiner Steib
2008-05-08 12:46       ` Mail address in the commit lists Ted Zlatanov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86fxsuueaf.fsf@lifelogs.com \
    --to=tzz@lifelogs.com \
    --cc=ding@gnus.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).