From d5291f517bc84deeb5ae045b20aa8d1eef5aced6 Mon Sep 17 00:00:00 2001 From: Dave Love Date: Wed, 26 Jun 2002 18:57:48 +0000 Subject: [PATCH] (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. --- lisp/gnus/ChangeLog | 7 +++++++ lisp/gnus/rfc2047.el | 46 +++++++++++++++++++++++--------------------- 2 files changed, 31 insertions(+), 22 deletions(-) diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog index caf3e94c2e3..200e4b92848 100644 --- a/lisp/gnus/ChangeLog +++ b/lisp/gnus/ChangeLog @@ -1,3 +1,10 @@ +2002-06-26 Dave Love + + * 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 * mm-util.el (mm-mule4-p, mm-enable-multibyte-mule4) diff --git a/lisp/gnus/rfc2047.el b/lisp/gnus/rfc2047.el index a5f3151d436..303fb00070d 100644 --- a/lisp/gnus/rfc2047.el +++ b/lisp/gnus/rfc2047.el @@ -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)) -- 2.39.2