]> git.eshelyaron.com Git - emacs.git/commitdiff
(rfc2047-encodable-p): Avoid mm-find-charset-region.
authorDave Love <fx@gnu.org>
Wed, 26 Jun 2002 18:57:48 +0000 (18:57 +0000)
committerDave Love <fx@gnu.org>
Wed, 26 Jun 2002 18:57:48 +0000 (18:57 +0000)
(rfc2047-dissect-region): Don't record charsets.
(rfc2047-encode): Remove arg CHARSET.
(rfc2047-encode-region): Change rfc2047-encode call.

lisp/gnus/ChangeLog
lisp/gnus/rfc2047.el

index caf3e94c2e370625a0dfa49698f6416a95d9142c..200e4b92848b2acb157e7cb03f2eebf6e808be10 100644 (file)
@@ -1,3 +1,10 @@
+2002-06-26  Dave Love  <fx@gnu.org>
+
+       * rfc2047.el (rfc2047-encodable-p): Avoid mm-find-charset-region.
+       (rfc2047-dissect-region): Don't record charsets.
+       (rfc2047-encode): Remove arg CHARSET.
+       (rfc2047-encode-region): Change rfc2047-encode call.
+
 2002-06-24  Dave Love  <fx@gnu.org>
 
        * mm-util.el (mm-mule4-p, mm-enable-multibyte-mule4)
index a5f3151d436dc16236395cf571df3e73c0e41a4f..303fb00070d880779399d127e7d4f1e36e7d97ae 100644 (file)
@@ -169,43 +169,41 @@ Should be called narrowed to the head of the message."
 The buffer may be narrowed."
   (require 'message)                   ; for message-posting-charset
   (let ((charsets
-        (mapcar
-         'mm-mime-charset
-         (mm-find-charset-region (point-min) (point-max))))
-       (cs (list 'us-ascii (car message-posting-charset)))
-       found)
-    (while charsets
-      (unless (memq (pop charsets) cs)
-       (setq found t)))
-    found))
+        (mm-find-mime-charset-region (point-min) (point-max))))
+    (and charsets (not (equal charsets (list message-posting-charset))))))
 
 (defun rfc2047-dissect-region (b e)
   "Dissect the region between B and E into words."
   (let ((word-chars "-A-Za-z0-9!*+/")
        ;; Not using ietf-drums-specials-token makes life simple.
        mail-parse-mule-charset
-       words point current
+       words point nonascii
        result word)
     (save-restriction
       (narrow-to-region b e)
       (goto-char (point-min))
       (skip-chars-forward "\000-\177")
+      ;; Fixme: This loop used to check charsets when it found
+      ;; non-ASCII characters.  That's removed, since it doesn't make
+      ;; much sense in Emacs 22 and doesn't seem necessary in Emacs
+      ;; 21, even.  I'm not sure exactly what it should be doing, and
+      ;; it needs another look, especially for efficiency's sake.  -- fx
       (while (not (eobp))
-       (setq point (point))
+       (setq point (point)
+             nonascii nil)
        (skip-chars-backward word-chars b)
        (unless (eq b (point))
          (push (cons (buffer-substring b (point)) nil) words))
-       (setq b (point))
+       (setq b (point)
+             nonascii t)
        (goto-char point)
-       (setq current (mm-charset-after))
        (forward-char 1)
        (skip-chars-forward word-chars)
-       (while (and (not (eobp))
-                   (eq (mm-charset-after) current))
+       (while (not (eobp))
          (forward-char 1)
          (skip-chars-forward word-chars))
        (unless (eq b (point))
-         (push (cons (buffer-substring b (point)) current) words))
+         (push (cons (buffer-substring b (point)) nonascii) words))
        (setq b (point))
        (skip-chars-forward "\000-\177"))
       (unless (eq b (point))
@@ -251,8 +249,7 @@ The buffer may be narrowed."
          ;; Insert blank between encoded words
          (if (eq (char-before) ?=) (insert " "))
          (rfc2047-encode (point)
-                         (progn (insert (car word)) (point))
-                         (cdr word))))
+                         (progn (insert (car word)) (point)))))
       (rfc2047-fold-region (point-min) (point-max)))))
 
 (defun rfc2047-encode-string (string)
@@ -262,10 +259,15 @@ The buffer may be narrowed."
     (rfc2047-encode-region (point-min) (point-max))
     (buffer-string)))
 
-(defun rfc2047-encode (b e charset)
-  "Encode the word in the region B to E with CHARSET."
-  (let* ((mime-charset (mm-mime-charset charset))
-        (cs (mm-charset-to-coding-system mime-charset))
+(defun rfc2047-encode (b e)
+  "Encode the word in the region B to E."
+  (let* ((buff (current-buffer))
+        (mime-charset (with-temp-buffer
+                        (insert-buffer-substring buff b e)
+                        (mm-find-mime-charset-region b e)))
+        (cs (if (> (length mime-charset) 1)
+                (mm-charset-to-coding-system mime-charset)
+              (error "Can't encode word: %s" (buffer-substring b e))))
         (encoding (or (cdr (assq mime-charset
                                  rfc2047-charset-encoding-alist))
                       'B))