]> code.delx.au - gnu-emacs/blobdiff - lisp/mail/mail-utils.el
Update copyright year to 2014 by running admin/update-copyright.
[gnu-emacs] / lisp / mail / mail-utils.el
index 2e6f06a675840544b972252e8c65697a26a198e0..fce42feb3bc1a1dd581eabe420b18a43625cf9d3 100644 (file)
@@ -1,6 +1,6 @@
 ;;; mail-utils.el --- utility functions used both by rmail and rnews
 
-;; Copyright (C) 1985, 2001-201 Free Software Foundation, Inc.
+;; Copyright (C) 1985, 2001-2014 Free Software Foundation, Inc.
 
 ;; Maintainer: FSF
 ;; Keywords: mail, news
@@ -63,12 +63,16 @@ from START (inclusive) to END (exclusive)."
 
 ;;;###autoload
 (defun mail-quote-printable (string &optional wrapper)
-  "Convert a string to the \"quoted printable\" Q encoding.
+  "Convert a string to the \"quoted printable\" Q encoding if necessary.
+If the string contains only ASCII characters and no troublesome ones,
+we return it unconverted.
+
 If the optional argument WRAPPER is non-nil,
 we add the wrapper characters =?ISO-8859-1?Q?....?=."
   (let ((i 0) (result ""))
     (save-match-data
-      (while (string-match "[?=\"\200-\377]" string i)
+      (while (or (string-match "[?=\"]" string i)
+                (string-match "[^\000-\177]" string i))
        (setq result
              (concat result (substring string i (match-beginning 0))
                      (upcase (format "=%02x"
@@ -179,17 +183,15 @@ as Rmail does."
                   (error "Malformed MIME quoted-printable message"))))
          (not failed))))))
 
-(eval-when-compile (require 'rfc822))
+(autoload 'rfc822-addresses "rfc822")
 
 (defun mail-strip-quoted-names (address)
   "Delete comments and quoted strings in an address list ADDRESS.
 Also delete leading/trailing whitespace and replace FOO <BAR> with just BAR.
 Return a modified address list."
-  (if (null address)
-      nil
+  (when address
     (if mail-use-rfc822
-       (progn (require 'rfc822)
-              (mapconcat 'identity (rfc822-addresses address) ", "))
+       (mapconcat 'identity (rfc822-addresses address) ", ")
       (let (pos)
 
         ;; Strip comments.