[Top][All Lists]

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

Re: 2 nits about mailabbrev

From: Kevin Rodgers
Subject: Re: 2 nits about mailabbrev
Date: Mon, 27 Sep 2004 12:25:14 -0600
User-agent: Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv: Gecko/20020406 Netscape6/6.2.2

John Owens wrote:
> 1) .alias accepts a syntax like the following:
> alias gwbush "George W. Bush <address@hidden>"
> All good so far. I like this syntax; it's well-known, it's easy, pretty
> much every mailer likes it. Now, when I expand the alias
> (add-hook 'mail-mode-hook 'mail-abbrevs-setup)
> in mail mode, I get the following:
> To: George W. Bush <address@hidden>
> Now, while that looks nice, the . after W is not in fact good syntax,
> and to make it compliant (RFC 822), it should really expand to
> To: "George W. Bush" <address@hidden>

Yes, but don't those other MUAs that grok .alias also generate a
non-compliant To: header?  And isn't the solution to that problem to
explicitly include the necessary quotes:

alias gwbush "\"George W. Bush\" <address@hidden>"

> although if I just had
> alias gwbush "George W Bush <address@hidden>"
> I think it should expand to
> To: George W Bush <address@hidden>

Doesn't this code from sendmail-send-it do the right thing?

                  (cond ((eq mail-from-style 'angles)
                         (insert "From: " fullname)
                         (let ((fullname-start (+ (point-min) 6))
                               (fullname-end (point-marker)))
                           (goto-char fullname-start)
                           ;; Look for a character that cannot appear unquoted
                           ;; according to RFC 822.
                           (if (or (re-search-forward "[^- !#-'*+/-9=?A-Z^-~]"
                                                      fullname-end 1)
                                 ;; Quote fullname, escaping specials.
                                 (goto-char fullname-start)
                                 (insert "\"")
                                 (while (re-search-forward "[\"\\]"
                                                           fullname-end 1)
                                   (replace-match "\\\\\\&" t))
                                 (insert "\""))))
                         (insert " <" login ">\n"))
                        ((eq mail-from-style 'parens)
                         (insert "From: " login " (")
                         (let ((fullname-start (point)))
                           (if quote-fullname
                               (insert "\""))
                           (insert fullname)
                           (if quote-fullname
                               (insert "\""))
                           (let ((fullname-end (point-marker)))
                             (goto-char fullname-start)
                             ;; RFC 822 says \ and nonmatching parentheses
                             ;; must be escaped in comments.
                             ;; Escape every instance of ()\ ...
                             (while (re-search-forward "[()\\]" fullname-end 1)
                               (replace-match "\\\\\\&" t))
                             ;; ... then undo escaping of matching parentheses,
                             ;; including matching nested parentheses.
                             (goto-char fullname-start)
                             (while (re-search-forward
                                     fullname-end 1)
                               (replace-match "\\1(\\3)" t)
                               (goto-char fullname-start))))
                         (insert ")\n"))
                        ((null mail-from-style)
                         (insert "From: " login "\n"))
                        ((eq mail-from-style 'system-default)
                        (t (error "Invalid value for `mail-from-style'")))

Kevin Rodgers

reply via email to

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