aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Love2002-06-26 18:57:48 +0000
committerDave Love2002-06-26 18:57:48 +0000
commitd5291f517bc84deeb5ae045b20aa8d1eef5aced6 (patch)
treea65b10d27e7b8480d95071144f162764a9f9f044
parentc344ce790026e9ee7b40b380e6e6d4a078de3876 (diff)
downloademacs-d5291f517bc84deeb5ae045b20aa8d1eef5aced6.tar.gz
emacs-d5291f517bc84deeb5ae045b20aa8d1eef5aced6.zip
(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.
-rw-r--r--lisp/gnus/ChangeLog7
-rw-r--r--lisp/gnus/rfc2047.el46
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 @@
12002-06-26 Dave Love <fx@gnu.org>
2
3 * rfc2047.el (rfc2047-encodable-p): Avoid mm-find-charset-region.
4 (rfc2047-dissect-region): Don't record charsets.
5 (rfc2047-encode): Remove arg CHARSET.
6 (rfc2047-encode-region): Change rfc2047-encode call.
7
12002-06-24 Dave Love <fx@gnu.org> 82002-06-24 Dave Love <fx@gnu.org>
2 9
3 * mm-util.el (mm-mule4-p, mm-enable-multibyte-mule4) 10 * 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."
169The buffer may be narrowed." 169The buffer may be narrowed."
170 (require 'message) ; for message-posting-charset 170 (require 'message) ; for message-posting-charset
171 (let ((charsets 171 (let ((charsets
172 (mapcar 172 (mm-find-mime-charset-region (point-min) (point-max))))
173 'mm-mime-charset 173 (and charsets (not (equal charsets (list message-posting-charset))))))
174 (mm-find-charset-region (point-min) (point-max))))
175 (cs (list 'us-ascii (car message-posting-charset)))
176 found)
177 (while charsets
178 (unless (memq (pop charsets) cs)
179 (setq found t)))
180 found))
181 174
182(defun rfc2047-dissect-region (b e) 175(defun rfc2047-dissect-region (b e)
183 "Dissect the region between B and E into words." 176 "Dissect the region between B and E into words."
184 (let ((word-chars "-A-Za-z0-9!*+/") 177 (let ((word-chars "-A-Za-z0-9!*+/")
185 ;; Not using ietf-drums-specials-token makes life simple. 178 ;; Not using ietf-drums-specials-token makes life simple.
186 mail-parse-mule-charset 179 mail-parse-mule-charset
187 words point current 180 words point nonascii
188 result word) 181 result word)
189 (save-restriction 182 (save-restriction
190 (narrow-to-region b e) 183 (narrow-to-region b e)
191 (goto-char (point-min)) 184 (goto-char (point-min))
192 (skip-chars-forward "\000-\177") 185 (skip-chars-forward "\000-\177")
186 ;; Fixme: This loop used to check charsets when it found
187 ;; non-ASCII characters. That's removed, since it doesn't make
188 ;; much sense in Emacs 22 and doesn't seem necessary in Emacs
189 ;; 21, even. I'm not sure exactly what it should be doing, and
190 ;; it needs another look, especially for efficiency's sake. -- fx
193 (while (not (eobp)) 191 (while (not (eobp))
194 (setq point (point)) 192 (setq point (point)
193 nonascii nil)
195 (skip-chars-backward word-chars b) 194 (skip-chars-backward word-chars b)
196 (unless (eq b (point)) 195 (unless (eq b (point))
197 (push (cons (buffer-substring b (point)) nil) words)) 196 (push (cons (buffer-substring b (point)) nil) words))
198 (setq b (point)) 197 (setq b (point)
198 nonascii t)
199 (goto-char point) 199 (goto-char point)
200 (setq current (mm-charset-after))
201 (forward-char 1) 200 (forward-char 1)
202 (skip-chars-forward word-chars) 201 (skip-chars-forward word-chars)
203 (while (and (not (eobp)) 202 (while (not (eobp))
204 (eq (mm-charset-after) current))
205 (forward-char 1) 203 (forward-char 1)
206 (skip-chars-forward word-chars)) 204 (skip-chars-forward word-chars))
207 (unless (eq b (point)) 205 (unless (eq b (point))
208 (push (cons (buffer-substring b (point)) current) words)) 206 (push (cons (buffer-substring b (point)) nonascii) words))
209 (setq b (point)) 207 (setq b (point))
210 (skip-chars-forward "\000-\177")) 208 (skip-chars-forward "\000-\177"))
211 (unless (eq b (point)) 209 (unless (eq b (point))
@@ -251,8 +249,7 @@ The buffer may be narrowed."
251 ;; Insert blank between encoded words 249 ;; Insert blank between encoded words
252 (if (eq (char-before) ?=) (insert " ")) 250 (if (eq (char-before) ?=) (insert " "))
253 (rfc2047-encode (point) 251 (rfc2047-encode (point)
254 (progn (insert (car word)) (point)) 252 (progn (insert (car word)) (point)))))
255 (cdr word))))
256 (rfc2047-fold-region (point-min) (point-max))))) 253 (rfc2047-fold-region (point-min) (point-max)))))
257 254
258(defun rfc2047-encode-string (string) 255(defun rfc2047-encode-string (string)
@@ -262,10 +259,15 @@ The buffer may be narrowed."
262 (rfc2047-encode-region (point-min) (point-max)) 259 (rfc2047-encode-region (point-min) (point-max))
263 (buffer-string))) 260 (buffer-string)))
264 261
265(defun rfc2047-encode (b e charset) 262(defun rfc2047-encode (b e)
266 "Encode the word in the region B to E with CHARSET." 263 "Encode the word in the region B to E."
267 (let* ((mime-charset (mm-mime-charset charset)) 264 (let* ((buff (current-buffer))
268 (cs (mm-charset-to-coding-system mime-charset)) 265 (mime-charset (with-temp-buffer
266 (insert-buffer-substring buff b e)
267 (mm-find-mime-charset-region b e)))
268 (cs (if (> (length mime-charset) 1)
269 (mm-charset-to-coding-system mime-charset)
270 (error "Can't encode word: %s" (buffer-substring b e))))
269 (encoding (or (cdr (assq mime-charset 271 (encoding (or (cdr (assq mime-charset
270 rfc2047-charset-encoding-alist)) 272 rfc2047-charset-encoding-alist))
271 'B)) 273 'B))