help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: mail-extract-address-components and silly address comments


From: Kevin Rodgers
Subject: Re: mail-extract-address-components and silly address comments
Date: Thu, 03 Apr 2003 10:11:12 -0700
User-agent: Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv:0.9.4.1) Gecko/20020406 Netscape6/6.2.2

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>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]