unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* mail-extract-address-components and silly address comments
@ 2003-04-03 13:21 Klaus Zeitler
  2003-04-03 17:11 ` Kevin Rodgers
  0 siblings, 1 reply; 2+ messages in thread
From: Klaus Zeitler @ 2003-04-03 13:21 UTC (permalink / raw)



I keep getting an increasing number of silly comments in email addresses
that cause mail-extract-address-components to return nonsense full names.
e.g. for the following 2 addresses mail-extract-address-components returns
these full names:
 user@host (via the vacation program)  -> "via the vacation program"
 "user via HyperNews" <HyperNews@host> -> "user via HyperNews"

Had a glance at mail-extract-address-components, but this function
looks way too complicated for me. Is there a hook or some other means to
remove uninteresting parts of an email address?

Thanks,

Klaus


-- 
 ------------------------------------------
|  Klaus Zeitler      Lucent Technologies  |
 ------------------------------------------
---
Linux: The best things in life are free

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: mail-extract-address-components and silly address comments
  2003-04-03 13:21 mail-extract-address-components and silly address comments Klaus Zeitler
@ 2003-04-03 17:11 ` Kevin Rodgers
  0 siblings, 0 replies; 2+ messages in thread
From: Kevin Rodgers @ 2003-04-03 17:11 UTC (permalink / raw)


Klaus Zeitler wrote:

> I keep getting an increasing number of silly comments in email addresses
> that cause mail-extract-address-components to return nonsense full names.
> e.g. for the following 2 addresses mail-extract-address-components returns
> these full names:
>  user@host (via the vacation program)  -> "via the vacation program"
>  "user via HyperNews" <HyperNews@host> -> "user via HyperNews"
> 
> Had a glance at mail-extract-address-components, but this function
> looks way too complicated for me. Is there a hook or some other means to
> remove uninteresting parts of an email address?

advice.el is your friend.  Try this:

(defadvice mail-extract-address-components (after via activate)
   "If the name contains the word \"via\", return nil as the FULL-NAME instead."
   (let ((full-name (car ad-return-value)))
     (if (and full-name (string-match "\\<via\\>" full-name))
	(setcar ad-return-value nil))))

Or this:

(defadvice mail-extract-address-components (after via activate)
   "If the name contains the word \"via\", strip that phrase from FULL-NAME."
   (let ((full-name (car ad-return-value)))
     (if (and full-name (string-match "\\<via\\>" full-name))
	(if (zerop (match-beginning 0))
	    (setcar ad-return-value nil)
	  (setcar ad-return-value
		  (substring full-name 0 (1- (match-beginning 0))))))))

-- 
<a href="mailto:&lt;kevin.rodgers&#64;ihs.com&gt;">Kevin Rodgers</a>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-04-03 17:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-04-03 13:21 mail-extract-address-components and silly address comments Klaus Zeitler
2003-04-03 17:11 ` Kevin Rodgers

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 read-only IMAP folder(s) and NNTP newsgroup(s).