Mercurial > emacs
comparison lisp/gnus/mm-util.el @ 57923:d7def5572cf3
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Merge from gnus--rel--5.10
Patches applied:
* miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-66
- miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-68
Update from CVS
2004-11-04 Katsumi Yamaoka <yamaoka@jpl.org>
* lisp/gnus/gnus-art. (gnus-article-edit-article): Don't associate the
article buffer with a draft file. This is a temporary measure
against the 2004-08-22 change to gnus-article-edit-mode.
2004-11-02 Katsumi Yamaoka <yamaoka@jpl.org>
* lisp/gnus/html2text.el (html2text-get-attr): Remove unused argument `tag'.
(html2text-format-tags): Remove unused variable `attr'.
* lisp/gnus/mm-util.el (mm-enrich-utf-8-by-mule-ucs): Fix cleaning of
after-load-alist.
* lisp/gnus/mm-util.el (mm-mime-mule-charset-alist): Add the windows-1251
entry. From Ilya N. Golubev <gin@mo.msk.ru>.
(mm-enrich-utf-8-by-mule-ucs): New function run when Mule-UCS is
loaded under XEmacs.
(): Don't make duplicated entries in mm-mime-mule-charset-alist.
* lisp/gnus/mm-util.el (mm-coding-system-p): Return a coding-system.
(mm-mime-mule-charset-alist): Use shift_jis instead of
iso-2022-jp-2 for the katakana-jisx0201 mule charset; add new
entries for the mime charsets iso-2022-jp-3 and shift_jis.
(mm-coding-system-priorities): Use shift_jis and iso-8859-1
instead of japanese-shift-jis and iso-latin-1 respectively in
order to share the default value with both Emacs and XEmacs-mule.
(mm-mule-charset-to-mime-charset): Make
mm-coding-system-priorities effective.
(mm-sort-coding-systems-predicate): Canonicalize coding-systems
while predicating of candidates upon the priorities.
2004-11-02 Katsumi Yamaoka <yamaoka@jpl.org>
* man/emacs-mime.texi (Encoding Customization): Fix
mm-coding-system-priorities entry.
author | Miles Bader <miles@gnu.org> |
---|---|
date | Thu, 04 Nov 2004 08:12:39 +0000 |
parents | 55829134ac17 |
children | 22da0004ae3c e24e2e78deda |
comparison
equal
deleted
inserted
replaced
57922:8089248edf3c | 57923:d7def5572cf3 |
---|---|
121 (or mm-coding-system-list | 121 (or mm-coding-system-list |
122 (setq mm-coding-system-list (mm-coding-system-list)))) | 122 (setq mm-coding-system-list (mm-coding-system-list)))) |
123 | 123 |
124 (defun mm-coding-system-p (cs) | 124 (defun mm-coding-system-p (cs) |
125 "Return non-nil if CS is a symbol naming a coding system. | 125 "Return non-nil if CS is a symbol naming a coding system. |
126 In XEmacs, also return non-nil if CS is a coding system object." | 126 In XEmacs, also return non-nil if CS is a coding system object. |
127 If CS is available, return CS itself in Emacs, and return a coding | |
128 system object in XEmacs." | |
127 (if (fboundp 'find-coding-system) | 129 (if (fboundp 'find-coding-system) |
128 (find-coding-system cs) | 130 (find-coding-system cs) |
129 (if (fboundp 'coding-system-p) | 131 (if (fboundp 'coding-system-p) |
130 (coding-system-p cs) | 132 (when (coding-system-p cs) |
133 cs) | |
131 ;; Is this branch ever actually useful? | 134 ;; Is this branch ever actually useful? |
132 (memq cs (mm-get-coding-system-list))))) | 135 (car (memq cs (mm-get-coding-system-list)))))) |
133 | 136 |
134 (defvar mm-charset-synonym-alist | 137 (defvar mm-charset-synonym-alist |
135 `( | 138 `( |
136 ;; Not in XEmacs, but it's not a proper MIME charset anyhow. | 139 ;; Not in XEmacs, but it's not a proper MIME charset anyhow. |
137 ,@(unless (mm-coding-system-p 'x-ctext) | 140 ,@(unless (mm-coding-system-p 'x-ctext) |
217 (euc-kr korean-ksc5601) | 220 (euc-kr korean-ksc5601) |
218 (gb2312 chinese-gb2312) | 221 (gb2312 chinese-gb2312) |
219 (big5 chinese-big5-1 chinese-big5-2) | 222 (big5 chinese-big5-1 chinese-big5-2) |
220 (tibetan tibetan) | 223 (tibetan tibetan) |
221 (thai-tis620 thai-tis620) | 224 (thai-tis620 thai-tis620) |
225 (windows-1251 cyrillic-iso8859-5) | |
222 (iso-2022-7bit ethiopic arabic-1-column arabic-2-column) | 226 (iso-2022-7bit ethiopic arabic-1-column arabic-2-column) |
223 (iso-2022-jp-2 latin-iso8859-1 greek-iso8859-7 | 227 (iso-2022-jp-2 latin-iso8859-1 greek-iso8859-7 |
224 latin-jisx0201 japanese-jisx0208-1978 | 228 latin-jisx0201 japanese-jisx0208-1978 |
225 chinese-gb2312 japanese-jisx0208 | 229 chinese-gb2312 japanese-jisx0208 |
226 korean-ksc5601 japanese-jisx0212 | 230 korean-ksc5601 japanese-jisx0212) |
227 katakana-jisx0201) | |
228 (iso-2022-int-1 latin-iso8859-1 greek-iso8859-7 | 231 (iso-2022-int-1 latin-iso8859-1 greek-iso8859-7 |
229 latin-jisx0201 japanese-jisx0208-1978 | 232 latin-jisx0201 japanese-jisx0208-1978 |
230 chinese-gb2312 japanese-jisx0208 | 233 chinese-gb2312 japanese-jisx0208 |
231 korean-ksc5601 japanese-jisx0212 | 234 korean-ksc5601 japanese-jisx0212 |
232 chinese-cns11643-1 chinese-cns11643-2) | 235 chinese-cns11643-1 chinese-cns11643-2) |
237 korean-ksc5601 japanese-jisx0212 | 240 korean-ksc5601 japanese-jisx0212 |
238 chinese-cns11643-1 chinese-cns11643-2 | 241 chinese-cns11643-1 chinese-cns11643-2 |
239 chinese-cns11643-3 chinese-cns11643-4 | 242 chinese-cns11643-3 chinese-cns11643-4 |
240 chinese-cns11643-5 chinese-cns11643-6 | 243 chinese-cns11643-5 chinese-cns11643-6 |
241 chinese-cns11643-7) | 244 chinese-cns11643-7) |
245 (iso-2022-jp-3 latin-jisx0201 japanese-jisx0208-1978 japanese-jisx0208 | |
246 japanese-jisx0213-1 japanese-jisx0213-2) | |
247 (shift_jis latin-jisx0201 katakana-jisx0201 japanese-jisx0208) | |
242 ,(if (or (not (fboundp 'charsetp)) ;; non-Mule case | 248 ,(if (or (not (fboundp 'charsetp)) ;; non-Mule case |
243 (charsetp 'unicode-a) | 249 (charsetp 'unicode-a) |
244 (not (mm-coding-system-p 'mule-utf-8))) | 250 (not (mm-coding-system-p 'mule-utf-8))) |
245 '(utf-8 unicode-a unicode-b unicode-c unicode-d unicode-e) | 251 '(utf-8 unicode-a unicode-b unicode-c unicode-d unicode-e) |
246 ;; If we have utf-8 we're in Mule 5+. | 252 ;; If we have utf-8 we're in Mule 5+. |
247 (append '(utf-8) | 253 (append '(utf-8) |
248 (delete 'ascii | 254 (delete 'ascii |
249 (coding-system-get 'mule-utf-8 'safe-charsets))))) | 255 (coding-system-get 'mule-utf-8 'safe-charsets))))) |
250 "Alist of MIME-charset/MULE-charsets.") | 256 "Alist of MIME-charset/MULE-charsets.") |
251 | 257 |
252 ;; Correct by construction, but should be unnecessary: | 258 (defun mm-enrich-utf-8-by-mule-ucs () |
253 ;; XEmacs hates it. | 259 "Make the `utf-8' MIME charset usable by the Mule-UCS package. |
254 (when (and (not (featurep 'xemacs)) | 260 This function will run when the `un-define' module is loaded under |
255 (fboundp 'coding-system-list) | 261 XEmacs, and fill the `utf-8' entry in `mm-mime-mule-charset-alist' |
256 (fboundp 'sort-coding-systems)) | 262 with Mule charsets. It is completely useless for Emacs." |
257 (setq mm-mime-mule-charset-alist | 263 (unless (cdr (delete '(mm-enrich-utf-8-by-mule-ucs) |
258 (apply | 264 (assoc "un-define" after-load-alist))) |
259 'nconc | 265 (setq after-load-alist |
260 (mapcar | 266 (delete '("un-define") after-load-alist))) |
261 (lambda (cs) | 267 (when (boundp 'unicode-basic-translation-charset-order-list) |
262 (when (and (or (coding-system-get cs :mime-charset) ; Emacs 22 | 268 (condition-case nil |
263 (coding-system-get cs 'mime-charset)) | 269 (let ((val (delq |
264 (not (eq t (coding-system-get cs 'safe-charsets)))) | 270 'ascii |
265 (list (cons (or (coding-system-get cs :mime-charset) | 271 (copy-sequence |
266 (coding-system-get cs 'mime-charset)) | 272 (symbol-value |
267 (delq 'ascii | 273 'unicode-basic-translation-charset-order-list)))) |
268 (coding-system-get cs 'safe-charsets)))))) | 274 (elem (assq 'utf-8 mm-mime-mule-charset-alist))) |
269 (sort-coding-systems (coding-system-list 'base-only)))))) | 275 (if elem |
276 (setcdr elem val) | |
277 (setq mm-mime-mule-charset-alist | |
278 (nconc mm-mime-mule-charset-alist | |
279 (list (cons 'utf-8 val)))))) | |
280 (error)))) | |
281 | |
282 ;; Correct by construction, but should be unnecessary for Emacs: | |
283 (if (featurep 'xemacs) | |
284 (eval-after-load "un-define" '(mm-enrich-utf-8-by-mule-ucs)) | |
285 (when (and (fboundp 'coding-system-list) | |
286 (fboundp 'sort-coding-systems)) | |
287 (let ((css (sort-coding-systems (coding-system-list 'base-only))) | |
288 cs mime mule alist) | |
289 (while css | |
290 (setq cs (pop css) | |
291 mime (or (coding-system-get cs :mime-charset) ; Emacs 22 | |
292 (coding-system-get cs 'mime-charset))) | |
293 (when (and mime | |
294 (not (eq t (setq mule | |
295 (coding-system-get cs 'safe-charsets)))) | |
296 (not (assq mime alist))) | |
297 (push (cons mime (delq 'ascii mule)) alist))) | |
298 (setq mm-mime-mule-charset-alist (nreverse alist))))) | |
270 | 299 |
271 (defvar mm-hack-charsets '(iso-8859-15 iso-2022-jp-2) | 300 (defvar mm-hack-charsets '(iso-8859-15 iso-2022-jp-2) |
272 "A list of special charsets. | 301 "A list of special charsets. |
273 Valid elements include: | 302 Valid elements include: |
274 `iso-8859-15' convert ISO-8859-1, -9 to ISO-8859-15 if ISO-8859-15 exists. | 303 `iso-8859-15' convert ISO-8859-1, -9 to ISO-8859-15 if ISO-8859-15 exists. |
330 | 359 |
331 (defun mm-mule-charset-to-mime-charset (charset) | 360 (defun mm-mule-charset-to-mime-charset (charset) |
332 "Return the MIME charset corresponding to the given Mule CHARSET." | 361 "Return the MIME charset corresponding to the given Mule CHARSET." |
333 (if (and (fboundp 'find-coding-systems-for-charsets) | 362 (if (and (fboundp 'find-coding-systems-for-charsets) |
334 (fboundp 'sort-coding-systems)) | 363 (fboundp 'sort-coding-systems)) |
335 (let (mime) | 364 (let ((css (sort (sort-coding-systems |
336 (dolist (cs (sort-coding-systems | 365 (find-coding-systems-for-charsets (list charset))) |
337 (copy-sequence | 366 'mm-sort-coding-systems-predicate)) |
338 (find-coding-systems-for-charsets (list charset))))) | 367 cs mime) |
339 (unless mime | 368 (while (and (not mime) |
340 (when cs | 369 css) |
341 (setq mime (or (coding-system-get cs :mime-charset) | 370 (when (setq cs (pop css)) |
342 (coding-system-get cs 'mime-charset)))))) | 371 (setq mime (or (coding-system-get cs :mime-charset) |
372 (coding-system-get cs 'mime-charset))))) | |
343 mime) | 373 mime) |
344 (let ((alist mm-mime-mule-charset-alist) | 374 (let ((alist (mapcar (lambda (cs) |
375 (assq cs mm-mime-mule-charset-alist)) | |
376 (sort (mapcar 'car mm-mime-mule-charset-alist) | |
377 'mm-sort-coding-systems-predicate))) | |
345 out) | 378 out) |
346 (while alist | 379 (while alist |
347 (when (memq charset (cdar alist)) | 380 (when (memq charset (cdar alist)) |
348 (setq out (caar alist) | 381 (setq out (caar alist) |
349 alist nil)) | 382 alist nil)) |
532 | 565 |
533 (defun mm-sort-coding-systems-predicate (a b) | 566 (defun mm-sort-coding-systems-predicate (a b) |
534 (let ((priorities | 567 (let ((priorities |
535 (mapcar (lambda (cs) | 568 (mapcar (lambda (cs) |
536 ;; Note: invalid entries are dropped silently | 569 ;; Note: invalid entries are dropped silently |
537 (and (coding-system-p cs) | 570 (and (setq cs (mm-coding-system-p cs)) |
538 (coding-system-base cs))) | 571 (coding-system-base cs))) |
539 mm-coding-system-priorities))) | 572 mm-coding-system-priorities))) |
540 (> (length (memq a priorities)) | 573 (and (setq a (mm-coding-system-p a)) |
541 (length (memq b priorities))))) | 574 (if (setq b (mm-coding-system-p b)) |
575 (> (length (memq (coding-system-base a) priorities)) | |
576 (length (memq (coding-system-base b) priorities))) | |
577 t)))) | |
542 | 578 |
543 (defun mm-find-mime-charset-region (b e &optional hack-charsets) | 579 (defun mm-find-mime-charset-region (b e &optional hack-charsets) |
544 "Return the MIME charsets needed to encode the region between B and E. | 580 "Return the MIME charsets needed to encode the region between B and E. |
545 nil means ASCII, a single-element list represents an appropriate MIME | 581 nil means ASCII, a single-element list represents an appropriate MIME |
546 charset, and a longer list means no appropriate charset." | 582 charset, and a longer list means no appropriate charset." |