Function: ietf-drums-parse-address
ietf-drums-parse-address is a byte-compiled function defined in
ietf-drums.el.gz.
Signature
(ietf-drums-parse-address STRING &optional DECODE)
Documentation
Parse STRING and return a MAILBOX / DISPLAY-NAME pair.
If DECODE, the DISPLAY-NAME will have RFC2047 decoding performed
(that's the "=?utf...q...=?") stuff.
Aliases
Source Code
;; Defined in /usr/src/emacs/lisp/mail/ietf-drums.el.gz
(defun ietf-drums-parse-address (string &optional decode)
"Parse STRING and return a MAILBOX / DISPLAY-NAME pair.
If DECODE, the DISPLAY-NAME will have RFC2047 decoding performed
(that's the \"=?utf...q...=?\") stuff."
(with-temp-buffer
(let (display-name mailbox c display-string)
(ietf-drums-init string)
(while (not (eobp))
(setq c (char-after))
;; If we have an uneven number of quote characters,
;; `forward-sexp' will fail. In these cases, just delete the
;; final of these quote characters.
(when (and (eq c ?\")
(not
(save-excursion
(ignore-errors
(forward-sexp 1)
t))))
(delete-char 1)
(setq c (char-after)))
(cond
((or (eq c ? )
(eq c ?\t))
(forward-char 1))
((eq c ?\()
(forward-sexp 1))
((eq c ?\")
(push (buffer-substring
(1+ (point)) (progn (forward-sexp 1) (1- (point))))
display-name))
((looking-at (concat "[" ietf-drums-atext-token "@" "]"))
(push (buffer-substring (point) (progn (forward-sexp 1) (point)))
display-name))
((eq c ?<)
(setq mailbox
(ietf-drums-remove-whitespace
(ietf-drums-remove-comments
(buffer-substring
(1+ (point))
(progn (forward-sexp 1) (1- (point))))))))
(t
(forward-char 1))))
;; If we found no display-name, then we look for comments.
(if display-name
(setq display-string
(mapconcat #'identity (reverse display-name) " "))
(setq display-string (ietf-drums-get-comment string)))
(if (not mailbox)
(when (and display-string
(string-search "@" display-string))
(cons
(mapconcat #'identity (nreverse display-name) "")
(ietf-drums-get-comment string)))
(cons mailbox (if decode
(rfc2047-decode-string display-string)
display-string))))))