diff options
author | Richard M. Stallman <rms@gnu.org> | 1995-07-01 00:33:52 +0000 |
---|---|---|
committer | Richard M. Stallman <rms@gnu.org> | 1995-07-01 00:33:52 +0000 |
commit | c94af1aab5788370209bb1810cec0d27c2f195bd (patch) | |
tree | 204a2466094fca10f3d1b7d1346ddbefb42687d1 | |
parent | c4261d306aa682af3a9dd41acc536b5a6c448259 (diff) | |
download | emacs-c94af1aab5788370209bb1810cec0d27c2f195bd.tar.gz |
(sendmail-send-it): If mail-from-style is parens,
don't escape all parentheses; escape only the nonmatching ones.
-rw-r--r-- | lisp/mail/sendmail.el | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/lisp/mail/sendmail.el b/lisp/mail/sendmail.el index f30581cbb2a..f54b52cb4b5 100644 --- a/lisp/mail/sendmail.el +++ b/lisp/mail/sendmail.el @@ -537,12 +537,24 @@ the user from the mailer." (insert "\"")))) (insert " <" login ">\n")) ((eq mail-from-style 'parens) - (insert "From: " login " (" fullname) - (let ((fullname-end (point-marker))) - (backward-char (length fullname)) - ;; RFC 822 says ()\ must be escaped in comments. - (while (re-search-forward "[()\\]" fullname-end 1) - (replace-match "\\\\\\&" t))) + (insert "From: " login " (") + (let ((fullname-start (point))) + (insert fullname) + (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"))))) |