comparison lisp/mail/mail-extr.el @ 57391:dd2896f4c2b7

(mail-extr-ignore-realname-equals-mailbox-name): New defcustom. (extract-address-components): Use it.
author Eli Zaretskii <eliz@gnu.org>
date Fri, 08 Oct 2004 17:51:02 +0000
parents 57c8c9029251
children aac0a33f5772 ff0e824afa37
comparison
equal deleted inserted replaced
57390:6755a4a4f532 57391:dd2896f4c2b7
230 "*Whether to ignore a name that is just a single word. 230 "*Whether to ignore a name that is just a single word.
231 If true, then when we see an address like \"Idiot <dumb@stupid.com>\" 231 If true, then when we see an address like \"Idiot <dumb@stupid.com>\"
232 we will act as though we couldn't find a full name in the address." 232 we will act as though we couldn't find a full name in the address."
233 :type 'boolean 233 :type 'boolean
234 :version "21.4" 234 :version "21.4"
235 :group 'mail-extr)
236
237 (defcustom mail-extr-ignore-realname-equals-mailbox-name t
238 "*Whether to ignore a name that is equal to the mailbox name.
239 If true, then when the address is like \"Single <single@address.com>\"
240 we will act as though we couldn't find a full name in the address."
241 :type 'boolean
235 :group 'mail-extr) 242 :group 'mail-extr)
236 243
237 ;; Matches a leading title that is not part of the name (does not 244 ;; Matches a leading title that is not part of the name (does not
238 ;; contribute to uniquely identifying the person). 245 ;; contribute to uniquely identifying the person).
239 (defcustom mail-extr-full-name-prefixes 246 (defcustom mail-extr-full-name-prefixes
692 ;;;###autoload 699 ;;;###autoload
693 (defun mail-extract-address-components (address &optional all) 700 (defun mail-extract-address-components (address &optional all)
694 "Given an RFC-822 address ADDRESS, extract full name and canonical address. 701 "Given an RFC-822 address ADDRESS, extract full name and canonical address.
695 Returns a list of the form (FULL-NAME CANONICAL-ADDRESS). 702 Returns a list of the form (FULL-NAME CANONICAL-ADDRESS).
696 If no name can be extracted, FULL-NAME will be nil. Also see 703 If no name can be extracted, FULL-NAME will be nil. Also see
697 `mail-extr-ignore-single-names'. 704 `mail-extr-ignore-single-names' and `mail-extr-ignore-realname-equals-mailbox-name'.
698 705
699 If the optional argument ALL is non-nil, then ADDRESS can contain zero 706 If the optional argument ALL is non-nil, then ADDRESS can contain zero
700 or more recipients, separated by commas, and we return a list of 707 or more recipients, separated by commas, and we return a list of
701 the form ((FULL-NAME CANONICAL-ADDRESS) ...) with one element for 708 the form ((FULL-NAME CANONICAL-ADDRESS) ...) with one element for
702 each recipient. If ALL is nil, then if ADDRESS contains more than 709 each recipient. If ALL is nil, then if ADDRESS contains more than
1402 (downcase 1409 (downcase
1403 (char-after (+ i buffer-length (point-min))))) 1410 (char-after (+ i buffer-length (point-min)))))
1404 (setq names-match-flag nil)) 1411 (setq names-match-flag nil))
1405 (setq i (1+ i))) 1412 (setq i (1+ i)))
1406 (delete-region (+ (point-min) buffer-length) (point-max)) 1413 (delete-region (+ (point-min) buffer-length) (point-max))
1407 (if names-match-flag 1414 (and names-match-flag
1408 (narrow-to-region (point) (point))))) 1415 mail-extr-ignore-realname-equals-mailbox-name
1416 (narrow-to-region (point) (point)))))
1409 1417
1410 ;; Nuke name if it's just one word. 1418 ;; Nuke name if it's just one word.
1411 (goto-char (point-min)) 1419 (goto-char (point-min))
1412 (and mail-extr-ignore-single-names 1420 (and mail-extr-ignore-single-names
1413 (not (re-search-forward "[- ]" nil t)) 1421 (not (re-search-forward "[- ]" nil t))