(rfc2047-quote-special-characters-in-quoted-strings): Don't quote characters
authorKatsumi Yamaoka <yamaoka@jpl.org>
Thu, 10 May 2007 01:20:38 +0000 (01:20 +0000)
committerKatsumi Yamaoka <yamaoka@jpl.org>
Thu, 10 May 2007 01:20:38 +0000 (01:20 +0000)
 that are within parentheses.

lisp/ChangeLog
lisp/rfc2047.el

index b3b5828..e91c666 100644 (file)
@@ -1,3 +1,8 @@
+2007-05-10  Katsumi Yamaoka  <yamaoka@jpl.org>
+
+       * rfc2047.el (rfc2047-quote-special-characters-in-quoted-strings):
+       Don't quote characters that are within parentheses.
+
 2007-05-09  Katsumi Yamaoka  <yamaoka@jpl.org>
 
        * gnus-sum.el (gnus-auto-select-on-ephemeral-exit): New variable.
index 59ac8e8..1b1e004 100644 (file)
@@ -146,37 +146,50 @@ This is either `base64' or `quoted-printable'."
                                                           encodable-regexp)
   "Quote special characters with `\\'s in quoted strings.
 Quoting will not be done in a quoted string if it contains characters
-matching ENCODABLE-REGEXP."
+matching ENCODABLE-REGEXP or it is within parentheses."
   (goto-char (point-min))
   (let ((tspecials (concat "[" ietf-drums-tspecials "]"))
+       (start (point))
        beg end)
     (with-syntax-table (standard-syntax-table)
-      (while (search-forward "\"" nil t)
-       (setq beg (match-beginning 0))
-       (unless (eq (char-before beg) ?\\)
-         (goto-char beg)
-         (setq beg (1+ beg))
-         (condition-case nil
-             (progn
-               (forward-sexp)
-               (setq end (1- (point)))
-               (goto-char beg)
-               (if (and encodable-regexp
-                        (re-search-forward encodable-regexp end t))
-                   (goto-char (1+ end))
-                 (save-restriction
-                   (narrow-to-region beg end)
-                   (while (re-search-forward tspecials nil 'move)
-                     (if (eq (char-before) ?\\)
-                         (if (looking-at tspecials) ;; Already quoted.
-                             (forward-char)
-                           (insert "\\"))
-                       (goto-char (match-beginning 0))
-                       (insert "\\")
-                       (forward-char))))
-                 (forward-char)))
-           (error
-            (goto-char beg))))))))
+      (while (not (eobp))
+       (if (ignore-errors
+             (forward-list 1)
+             (eq (char-before) ?\)))
+           (forward-list -1)
+         (goto-char (point-max)))
+       (save-restriction
+         (narrow-to-region start (point))
+         (goto-char start)
+         (while (search-forward "\"" nil t)
+           (setq beg (match-beginning 0))
+           (unless (eq (char-before beg) ?\\)
+             (goto-char beg)
+             (setq beg (1+ beg))
+             (condition-case nil
+                 (progn
+                   (forward-sexp)
+                   (setq end (1- (point)))
+                   (goto-char beg)
+                   (if (and encodable-regexp
+                            (re-search-forward encodable-regexp end t))
+                       (goto-char (1+ end))
+                     (save-restriction
+                       (narrow-to-region beg end)
+                       (while (re-search-forward tspecials nil 'move)
+                         (if (eq (char-before) ?\\)
+                             (if (looking-at tspecials) ;; Already quoted.
+                                 (forward-char)
+                               (insert "\\"))
+                           (goto-char (match-beginning 0))
+                           (insert "\\")
+                           (forward-char))))
+                     (forward-char)))
+               (error
+                (goto-char beg)))))
+         (goto-char (point-max)))
+       (forward-list 1)
+       (setq start (point))))))
 
 (defvar rfc2047-encoding-type 'address-mime
   "The type of encoding done by `rfc2047-encode-region'.