annotate lisp/gnus/mm-util.el @ 111997:a5a188ddc758

Minor clean up to silence some gcc warnings. * src/window.c (Fset_window_buffer): * src/xterm.c (x_set_frame_alpha): Restructure code to silence compiler warning. (handle_one_xevent): Remove unused var `p'. (do_ewmh_fullscreen): Remove unused var `lval'. (xembed_set_info): Remove unused var `atom'. * src/textprop.c (Fremove_list_of_text_properties): Add braces to silence compiler warning. * src/fontset.c (fontset_id_valid_p, dump_fontset): * src/ftfont.c (ftfont_drive_otf): Modernize k&r declaration. * src/eval.c (Feval, Ffuncall): Avoid unneeded gotos. * src/dispnew.c (update_frame, update_frame_1): Compile the `do_pause' label only when it's used. * src/image.c (x_create_bitmap_from_xpm_data): * src/dispextern.h (x_create_bitmap_from_xpm_data): Use const char** like its callers. * src/coding.c (detect_coding_utf_16): Remove unused vars `src_base' and `consumed_chars'. (DECODE_EMACS_MULE_21_COMPOSITION): Remove unused var `charbuf_base'. (decode_coding_emacs_mule): Remove unused label `retry'. (detect_eol): Add parens to silence compiler warning. * src/alloc.c (bytes_used_when_reconsidered): Move to the #ifdef where it's used to silence the compiler. (make_number): Modernize k&r declaration. (mark_char_table): Add parens to silence compiler warning.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Sun, 19 Dec 2010 00:43:42 -0500
parents 9d94a05dfc5d
children 417b1e4d63cd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
1 ;;; mm-util.el --- Utility functions for Mule and low level things
64754
fafd692d1e40 Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 64736
diff changeset
2
104830
79c2323377ac Use default-value rather than default-enable-multibyte-characters.
Glenn Morris <rgm@gnu.org>
parents: 104682
diff changeset
3 ;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
106815
1d1d5d9bd884 Add 2010 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 105167
diff changeset
4 ;; 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
5
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
6 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
7 ;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
8 ;; This file is part of GNU Emacs.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
9
94662
f42ef85caf91 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93728
diff changeset
10 ;; GNU Emacs is free software: you can redistribute it and/or modify
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
94662
f42ef85caf91 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93728
diff changeset
12 ;; the Free Software Foundation, either version 3 of the License, or
f42ef85caf91 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93728
diff changeset
13 ;; (at your option) any later version.
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
14
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
94662
f42ef85caf91 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93728
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
18 ;; GNU General Public License for more details.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
19
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
94662
f42ef85caf91 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93728
diff changeset
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
22
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
23 ;;; Commentary:
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
24
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
25 ;;; Code:
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
26
110918
236342431786 nnimap.el (gnutls-negotiate): Silence the byte compiler.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110661
diff changeset
27 ;; For Emacs <22.2 and XEmacs.
87241
4d24ed4358ae Add declare-function compatibility definition.
Glenn Morris <rgm@gnu.org>
parents: 86154
diff changeset
28 (eval-and-compile
4d24ed4358ae Add declare-function compatibility definition.
Glenn Morris <rgm@gnu.org>
parents: 86154
diff changeset
29 (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
4d24ed4358ae Add declare-function compatibility definition.
Glenn Morris <rgm@gnu.org>
parents: 86154
diff changeset
30
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
31 (eval-when-compile (require 'cl))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
32 (require 'mail-prsvr)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
33
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
34 (eval-and-compile
85712
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
35 (if (featurep 'xemacs)
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
36 (unless (ignore-errors
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
37 (require 'timer-funcs))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
38 (require 'timer))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
39 (require 'timer)))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
40
86154
1cdfc94602cb * smime.el (from):
Dan Nicolaescu <dann@ics.uci.edu>
parents: 85888
diff changeset
41 (defvar mm-mime-mule-charset-alist )
111303
488230abc7fd Silence compilation of mm-util.el.
Glenn Morris <rgm@gnu.org>
parents: 111286
diff changeset
42 ;; Note this is not presently used on Emacs >= 23, which is good,
488230abc7fd Silence compilation of mm-util.el.
Glenn Morris <rgm@gnu.org>
parents: 111286
diff changeset
43 ;; since it means standalone message-mode (which requires mml and
488230abc7fd Silence compilation of mm-util.el.
Glenn Morris <rgm@gnu.org>
parents: 111286
diff changeset
44 ;; hence mml-util) does not load gnus-util.
488230abc7fd Silence compilation of mm-util.el.
Glenn Morris <rgm@gnu.org>
parents: 111286
diff changeset
45 (autoload 'gnus-completing-read "gnus-util")
86154
1cdfc94602cb * smime.el (from):
Dan Nicolaescu <dann@ics.uci.edu>
parents: 85888
diff changeset
46
100993
a16e9f7c2536 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100908
diff changeset
47 ;; Emulate functions that are not available in every (X)Emacs version.
a16e9f7c2536 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100908
diff changeset
48 ;; The name of a function is prefixed with mm-, like `mm-char-int' for
a16e9f7c2536 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100908
diff changeset
49 ;; `char-int' that is a native XEmacs function, not available in Emacs.
a16e9f7c2536 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100908
diff changeset
50 ;; Gnus programs all should use mm- functions, not the original ones.
85712
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
51 (eval-and-compile
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
52 (mapc
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
53 (lambda (elem)
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
54 (let ((nfunc (intern (format "mm-%s" (car elem)))))
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
55 (if (fboundp (car elem))
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
56 (defalias nfunc (car elem))
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
57 (defalias nfunc (cdr elem)))))
100993
a16e9f7c2536 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100908
diff changeset
58 `(;; `coding-system-list' is not available in XEmacs 21.4 built
a16e9f7c2536 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100908
diff changeset
59 ;; without the `file-coding' feature.
a16e9f7c2536 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100908
diff changeset
60 (coding-system-list . ignore)
a16e9f7c2536 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100908
diff changeset
61 ;; `char-int' is an XEmacs function, not available in Emacs.
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
62 (char-int . identity)
100993
a16e9f7c2536 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100908
diff changeset
63 ;; `coding-system-equal' is an Emacs function, not available in XEmacs.
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
64 (coding-system-equal . equal)
100993
a16e9f7c2536 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100908
diff changeset
65 ;; `annotationp' is an XEmacs function, not available in Emacs.
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
66 (annotationp . ignore)
100993
a16e9f7c2536 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100908
diff changeset
67 ;; `set-buffer-file-coding-system' is not available in XEmacs 21.4
a16e9f7c2536 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100908
diff changeset
68 ;; built without the `file-coding' feature.
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
69 (set-buffer-file-coding-system . ignore)
100993
a16e9f7c2536 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100908
diff changeset
70 ;; `read-charset' is an Emacs function, not available in XEmacs.
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
71 (read-charset
100516
0363096dbcf8 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100454
diff changeset
72 . ,(lambda (prompt)
0363096dbcf8 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100454
diff changeset
73 "Return a charset."
0363096dbcf8 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100454
diff changeset
74 (intern
110661
2b8ece636433 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110637
diff changeset
75 (gnus-completing-read
100516
0363096dbcf8 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100454
diff changeset
76 prompt
110661
2b8ece636433 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110637
diff changeset
77 (mapcar (lambda (e) (symbol-name (car e)))
100516
0363096dbcf8 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100454
diff changeset
78 mm-mime-mule-charset-alist)
110661
2b8ece636433 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110637
diff changeset
79 t))))
100993
a16e9f7c2536 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100908
diff changeset
80 ;; `subst-char-in-string' is not available in XEmacs 21.4.
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
81 (subst-char-in-string
100516
0363096dbcf8 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100454
diff changeset
82 . ,(lambda (from to string &optional inplace)
0363096dbcf8 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100454
diff changeset
83 ;; stolen (and renamed) from nnheader.el
0363096dbcf8 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100454
diff changeset
84 "Replace characters in STRING from FROM to TO.
61424
ad05d91d3598 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-243
Miles Bader <miles@gnu.org>
parents: 61126
diff changeset
85 Unless optional argument INPLACE is non-nil, return a new string."
100516
0363096dbcf8 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100454
diff changeset
86 (let ((string (if inplace string (copy-sequence string)))
0363096dbcf8 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100454
diff changeset
87 (len (length string))
0363096dbcf8 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100454
diff changeset
88 (idx 0))
0363096dbcf8 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100454
diff changeset
89 ;; Replace all occurrences of FROM with TO.
0363096dbcf8 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100454
diff changeset
90 (while (< idx len)
0363096dbcf8 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100454
diff changeset
91 (when (= (aref string idx) from)
0363096dbcf8 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100454
diff changeset
92 (aset string idx to))
0363096dbcf8 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100454
diff changeset
93 (setq idx (1+ idx)))
0363096dbcf8 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100454
diff changeset
94 string)))
100993
a16e9f7c2536 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100908
diff changeset
95 ;; `replace-in-string' is an XEmacs function, not available in Emacs.
85712
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
96 (replace-in-string
100516
0363096dbcf8 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100454
diff changeset
97 . ,(lambda (string regexp rep &optional literal)
0363096dbcf8 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100454
diff changeset
98 "See `replace-regexp-in-string', only the order of args differs."
0363096dbcf8 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100454
diff changeset
99 (replace-regexp-in-string regexp rep string nil literal)))
100993
a16e9f7c2536 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100908
diff changeset
100 ;; `string-as-unibyte' is an Emacs function, not available in XEmacs.
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
101 (string-as-unibyte . identity)
100993
a16e9f7c2536 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100908
diff changeset
102 ;; `string-make-unibyte' is an Emacs function, not available in XEmacs.
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
103 (string-make-unibyte . identity)
61434
6d07c19816b9 (mm-string-to-multibyte): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61424
diff changeset
104 ;; string-as-multibyte often doesn't really do what you think it does.
6d07c19816b9 (mm-string-to-multibyte): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61424
diff changeset
105 ;; Example:
6d07c19816b9 (mm-string-to-multibyte): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61424
diff changeset
106 ;; (aref (string-as-multibyte "\201") 0) -> 129 (aka ?\201)
6d07c19816b9 (mm-string-to-multibyte): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61424
diff changeset
107 ;; (aref (string-as-multibyte "\300") 0) -> 192 (aka ?\300)
6d07c19816b9 (mm-string-to-multibyte): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61424
diff changeset
108 ;; (aref (string-as-multibyte "\300\201") 0) -> 192 (aka ?\300)
6d07c19816b9 (mm-string-to-multibyte): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61424
diff changeset
109 ;; (aref (string-as-multibyte "\300\201") 1) -> 129 (aka ?\201)
6d07c19816b9 (mm-string-to-multibyte): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61424
diff changeset
110 ;; but
6d07c19816b9 (mm-string-to-multibyte): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61424
diff changeset
111 ;; (aref (string-as-multibyte "\201\300") 0) -> 2240
6d07c19816b9 (mm-string-to-multibyte): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61424
diff changeset
112 ;; (aref (string-as-multibyte "\201\300") 1) -> <error>
6d07c19816b9 (mm-string-to-multibyte): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61424
diff changeset
113 ;; Better use string-to-multibyte or encode-coding-string.
6d07c19816b9 (mm-string-to-multibyte): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61424
diff changeset
114 ;; If you really need string-as-multibyte somewhere it's usually
6d07c19816b9 (mm-string-to-multibyte): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61424
diff changeset
115 ;; because you're using the internal emacs-mule representation (maybe
6d07c19816b9 (mm-string-to-multibyte): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61424
diff changeset
116 ;; because you're using string-as-unibyte somewhere), which is
6d07c19816b9 (mm-string-to-multibyte): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61424
diff changeset
117 ;; generally a problem in itself.
6d07c19816b9 (mm-string-to-multibyte): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61424
diff changeset
118 ;; Here is an approximate equivalence table to help think about it:
6d07c19816b9 (mm-string-to-multibyte): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61424
diff changeset
119 ;; (string-as-multibyte s) ~= (decode-coding-string s 'emacs-mule)
6d07c19816b9 (mm-string-to-multibyte): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61424
diff changeset
120 ;; (string-to-multibyte s) ~= (decode-coding-string s 'binary)
6d07c19816b9 (mm-string-to-multibyte): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61424
diff changeset
121 ;; (string-make-multibyte s) ~= (decode-coding-string s locale-coding-system)
100993
a16e9f7c2536 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100908
diff changeset
122 ;; `string-as-multibyte' is an Emacs function, not available in XEmacs.
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
123 (string-as-multibyte . identity)
100993
a16e9f7c2536 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100908
diff changeset
124 ;; `multibyte-string-p' is an Emacs function, not available in XEmacs.
47949
33e1238070a2 (mm-mime-mule-charset-alist): Require when compiling.
Dave Love <fx@gnu.org>
parents: 44075
diff changeset
125 (multibyte-string-p . ignore)
100993
a16e9f7c2536 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100908
diff changeset
126 ;; `insert-byte' is available only in Emacs 23.1 or greater.
47949
33e1238070a2 (mm-mime-mule-charset-alist): Require when compiling.
Dave Love <fx@gnu.org>
parents: 44075
diff changeset
127 (insert-byte . insert-char)
100993
a16e9f7c2536 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100908
diff changeset
128 ;; `multibyte-char-to-unibyte' is an Emacs function, not available
a16e9f7c2536 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100908
diff changeset
129 ;; in XEmacs.
85712
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
130 (multibyte-char-to-unibyte . identity)
100993
a16e9f7c2536 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100908
diff changeset
131 ;; `set-buffer-multibyte' is an Emacs function, not available in XEmacs.
93106
e931cb410f95 (mm-set-buffer-multibyte): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92153
diff changeset
132 (set-buffer-multibyte . ignore)
100993
a16e9f7c2536 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100908
diff changeset
133 ;; `special-display-p' is an Emacs function, not available in XEmacs.
85712
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
134 (special-display-p
100516
0363096dbcf8 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100454
diff changeset
135 . ,(lambda (buffer-name)
0363096dbcf8 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100454
diff changeset
136 "Returns non-nil if a buffer named BUFFER-NAME gets a special frame."
0363096dbcf8 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100454
diff changeset
137 (and special-display-function
0363096dbcf8 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100454
diff changeset
138 (or (and (member buffer-name special-display-buffer-names) t)
0363096dbcf8 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100454
diff changeset
139 (cdr (assoc buffer-name special-display-buffer-names))
0363096dbcf8 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100454
diff changeset
140 (catch 'return
0363096dbcf8 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100454
diff changeset
141 (dolist (elem special-display-regexps)
0363096dbcf8 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100454
diff changeset
142 (and (stringp elem)
0363096dbcf8 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100454
diff changeset
143 (string-match elem buffer-name)
0363096dbcf8 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100454
diff changeset
144 (throw 'return t))
0363096dbcf8 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100454
diff changeset
145 (and (consp elem)
0363096dbcf8 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100454
diff changeset
146 (stringp (car elem))
0363096dbcf8 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100454
diff changeset
147 (string-match (car elem) buffer-name)
0363096dbcf8 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100454
diff changeset
148 (throw 'return (cdr elem)))))))))
100993
a16e9f7c2536 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100908
diff changeset
149 ;; `substring-no-properties' is available only in Emacs 22.1 or greater.
100516
0363096dbcf8 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100454
diff changeset
150 (substring-no-properties
0363096dbcf8 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100454
diff changeset
151 . ,(lambda (string &optional from to)
0363096dbcf8 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100454
diff changeset
152 "Return a substring of STRING, without text properties.
0363096dbcf8 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100454
diff changeset
153 It starts at index FROM and ending before TO.
0363096dbcf8 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100454
diff changeset
154 TO may be nil or omitted; then the substring runs to the end of STRING.
0363096dbcf8 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100454
diff changeset
155 If FROM is nil or omitted, the substring starts at the beginning of STRING.
0363096dbcf8 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100454
diff changeset
156 If FROM or TO is negative, it counts from the end.
0363096dbcf8 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100454
diff changeset
157
0363096dbcf8 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100454
diff changeset
158 With one argument, just copy STRING without its properties."
0363096dbcf8 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100454
diff changeset
159 (setq string (substring string (or from 0) to))
0363096dbcf8 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100454
diff changeset
160 (set-text-properties 0 (length string) nil string)
100993
a16e9f7c2536 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100908
diff changeset
161 string))
a16e9f7c2536 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100908
diff changeset
162 ;; `line-number-at-pos' is available only in Emacs 22.1 or greater
a16e9f7c2536 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100908
diff changeset
163 ;; and XEmacs 21.5.
a16e9f7c2536 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100908
diff changeset
164 (line-number-at-pos
a16e9f7c2536 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100908
diff changeset
165 . ,(lambda (&optional pos)
a16e9f7c2536 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100908
diff changeset
166 "Return (narrowed) buffer line number at position POS.
a16e9f7c2536 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100908
diff changeset
167 If POS is nil, use current buffer location.
a16e9f7c2536 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100908
diff changeset
168 Counting starts at (point-min), so the value refers
a16e9f7c2536 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100908
diff changeset
169 to the contents of the accessible portion of the buffer."
a16e9f7c2536 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100908
diff changeset
170 (let ((opoint (or pos (point))) start)
a16e9f7c2536 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100908
diff changeset
171 (save-excursion
a16e9f7c2536 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100908
diff changeset
172 (goto-char (point-min))
a16e9f7c2536 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100908
diff changeset
173 (setq start (point))
a16e9f7c2536 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100908
diff changeset
174 (goto-char opoint)
a16e9f7c2536 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100908
diff changeset
175 (forward-line 0)
a16e9f7c2536 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100908
diff changeset
176 (1+ (count-lines start (point))))))))))
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
177
100993
a16e9f7c2536 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100908
diff changeset
178 ;; `decode-coding-string', `encode-coding-string', `decode-coding-region'
a16e9f7c2536 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100908
diff changeset
179 ;; and `encode-coding-region' are available in Emacs and XEmacs built with
a16e9f7c2536 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100908
diff changeset
180 ;; the `file-coding' feature, but the XEmacs versions treat nil, that is
a16e9f7c2536 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100908
diff changeset
181 ;; given as the `coding-system' argument, as the `binary' coding system.
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
182 (eval-and-compile
78125
f0705c4da65a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 75347
diff changeset
183 (if (featurep 'xemacs)
f0705c4da65a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 75347
diff changeset
184 (if (featurep 'file-coding)
f0705c4da65a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 75347
diff changeset
185 (progn
f0705c4da65a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 75347
diff changeset
186 (defun mm-decode-coding-string (str coding-system)
f0705c4da65a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 75347
diff changeset
187 (if coding-system
f0705c4da65a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 75347
diff changeset
188 (decode-coding-string str coding-system)
f0705c4da65a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 75347
diff changeset
189 str))
f0705c4da65a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 75347
diff changeset
190 (defun mm-encode-coding-string (str coding-system)
f0705c4da65a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 75347
diff changeset
191 (if coding-system
f0705c4da65a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 75347
diff changeset
192 (encode-coding-string str coding-system)
f0705c4da65a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 75347
diff changeset
193 str))
f0705c4da65a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 75347
diff changeset
194 (defun mm-decode-coding-region (start end coding-system)
f0705c4da65a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 75347
diff changeset
195 (if coding-system
f0705c4da65a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 75347
diff changeset
196 (decode-coding-region start end coding-system)))
f0705c4da65a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 75347
diff changeset
197 (defun mm-encode-coding-region (start end coding-system)
f0705c4da65a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 75347
diff changeset
198 (if coding-system
f0705c4da65a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 75347
diff changeset
199 (encode-coding-region start end coding-system))))
f0705c4da65a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 75347
diff changeset
200 (defun mm-decode-coding-string (str coding-system) str)
f0705c4da65a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 75347
diff changeset
201 (defun mm-encode-coding-string (str coding-system) str)
f0705c4da65a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 75347
diff changeset
202 (defalias 'mm-decode-coding-region 'ignore)
f0705c4da65a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 75347
diff changeset
203 (defalias 'mm-encode-coding-region 'ignore))
f0705c4da65a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 75347
diff changeset
204 (defalias 'mm-decode-coding-string 'decode-coding-string)
f0705c4da65a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 75347
diff changeset
205 (defalias 'mm-encode-coding-string 'encode-coding-string)
f0705c4da65a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 75347
diff changeset
206 (defalias 'mm-decode-coding-region 'decode-coding-region)
f0705c4da65a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 75347
diff changeset
207 (defalias 'mm-encode-coding-region 'encode-coding-region)))
f0705c4da65a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 75347
diff changeset
208
111286
3f47a5cf9ad5 * lisp/gnus/mm-util.el (mm-string-to-multibyte): Simplify.
Glenn Morris <rgm@gnu.org>
parents: 110918
diff changeset
209 ;; `string-to-multibyte' is available only in Emacs.
3f47a5cf9ad5 * lisp/gnus/mm-util.el (mm-string-to-multibyte): Simplify.
Glenn Morris <rgm@gnu.org>
parents: 110918
diff changeset
210 (defalias 'mm-string-to-multibyte (if (featurep 'xemacs)
3f47a5cf9ad5 * lisp/gnus/mm-util.el (mm-string-to-multibyte): Simplify.
Glenn Morris <rgm@gnu.org>
parents: 110918
diff changeset
211 'identity
3f47a5cf9ad5 * lisp/gnus/mm-util.el (mm-string-to-multibyte): Simplify.
Glenn Morris <rgm@gnu.org>
parents: 110918
diff changeset
212 'string-to-multibyte))
74214
7cf0e45e7c70 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73546
diff changeset
213
100993
a16e9f7c2536 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100908
diff changeset
214 ;; `char-or-char-int-p' is an XEmacs function, not available in Emacs.
61126
c0aa521e0ca7 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-220
Miles Bader <miles@gnu.org>
parents: 60029
diff changeset
215 (eval-and-compile
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
216 (defalias 'mm-char-or-char-int-p
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
217 (cond
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
218 ((fboundp 'char-or-char-int-p) 'char-or-char-int-p)
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
219 ((fboundp 'char-valid-p) 'char-valid-p)
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
220 (t 'identity))))
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
221
100993
a16e9f7c2536 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100908
diff changeset
222 ;; `ucs-to-char' is a function that Mule-UCS provides.
111860
9d94a05dfc5d mm-util.el (mm-ucs-to-char): Use eval-and-compile.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111842
diff changeset
223 (eval-and-compile
9d94a05dfc5d mm-util.el (mm-ucs-to-char): Use eval-and-compile.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111842
diff changeset
224 (if (featurep 'xemacs)
9d94a05dfc5d mm-util.el (mm-ucs-to-char): Use eval-and-compile.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111842
diff changeset
225 (cond ((and (fboundp 'unicode-to-char) ;; XEmacs 21.5.
9d94a05dfc5d mm-util.el (mm-ucs-to-char): Use eval-and-compile.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111842
diff changeset
226 (subrp (symbol-function 'unicode-to-char)))
9d94a05dfc5d mm-util.el (mm-ucs-to-char): Use eval-and-compile.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111842
diff changeset
227 (if (featurep 'mule)
9d94a05dfc5d mm-util.el (mm-ucs-to-char): Use eval-and-compile.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111842
diff changeset
228 (defalias 'mm-ucs-to-char 'unicode-to-char)
9d94a05dfc5d mm-util.el (mm-ucs-to-char): Use eval-and-compile.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111842
diff changeset
229 (defun mm-ucs-to-char (codepoint)
9d94a05dfc5d mm-util.el (mm-ucs-to-char): Use eval-and-compile.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111842
diff changeset
230 "Convert Unicode codepoint to character."
9d94a05dfc5d mm-util.el (mm-ucs-to-char): Use eval-and-compile.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111842
diff changeset
231 (or (unicode-to-char codepoint) ?#))))
9d94a05dfc5d mm-util.el (mm-ucs-to-char): Use eval-and-compile.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111842
diff changeset
232 ((featurep 'mule)
100993
a16e9f7c2536 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100908
diff changeset
233 (defun mm-ucs-to-char (codepoint)
a16e9f7c2536 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100908
diff changeset
234 "Convert Unicode codepoint to character."
111860
9d94a05dfc5d mm-util.el (mm-ucs-to-char): Use eval-and-compile.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111842
diff changeset
235 (if (fboundp 'ucs-to-char) ;; Mule-UCS is loaded.
9d94a05dfc5d mm-util.el (mm-ucs-to-char): Use eval-and-compile.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111842
diff changeset
236 (progn
9d94a05dfc5d mm-util.el (mm-ucs-to-char): Use eval-and-compile.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111842
diff changeset
237 (defalias 'mm-ucs-to-char
9d94a05dfc5d mm-util.el (mm-ucs-to-char): Use eval-and-compile.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111842
diff changeset
238 (lambda (codepoint)
9d94a05dfc5d mm-util.el (mm-ucs-to-char): Use eval-and-compile.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111842
diff changeset
239 "Convert Unicode codepoint to character."
9d94a05dfc5d mm-util.el (mm-ucs-to-char): Use eval-and-compile.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111842
diff changeset
240 (condition-case nil
9d94a05dfc5d mm-util.el (mm-ucs-to-char): Use eval-and-compile.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111842
diff changeset
241 (or (ucs-to-char codepoint) ?#)
9d94a05dfc5d mm-util.el (mm-ucs-to-char): Use eval-and-compile.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111842
diff changeset
242 (error ?#))))
9d94a05dfc5d mm-util.el (mm-ucs-to-char): Use eval-and-compile.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111842
diff changeset
243 (mm-ucs-to-char codepoint))
9d94a05dfc5d mm-util.el (mm-ucs-to-char): Use eval-and-compile.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111842
diff changeset
244 (condition-case nil
9d94a05dfc5d mm-util.el (mm-ucs-to-char): Use eval-and-compile.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111842
diff changeset
245 (or (int-to-char codepoint) ?#)
9d94a05dfc5d mm-util.el (mm-ucs-to-char): Use eval-and-compile.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111842
diff changeset
246 (error ?#)))))
9d94a05dfc5d mm-util.el (mm-ucs-to-char): Use eval-and-compile.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111842
diff changeset
247 (t
9d94a05dfc5d mm-util.el (mm-ucs-to-char): Use eval-and-compile.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111842
diff changeset
248 (defun mm-ucs-to-char (codepoint)
9d94a05dfc5d mm-util.el (mm-ucs-to-char): Use eval-and-compile.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111842
diff changeset
249 "Convert Unicode codepoint to character."
100993
a16e9f7c2536 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100908
diff changeset
250 (condition-case nil
a16e9f7c2536 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100908
diff changeset
251 (or (int-to-char codepoint) ?#)
a16e9f7c2536 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100908
diff changeset
252 (error ?#)))))
111860
9d94a05dfc5d mm-util.el (mm-ucs-to-char): Use eval-and-compile.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111842
diff changeset
253 (if (let ((char (make-char 'japanese-jisx0208 36 34)))
9d94a05dfc5d mm-util.el (mm-ucs-to-char): Use eval-and-compile.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111842
diff changeset
254 (eq char (decode-char 'ucs char)))
9d94a05dfc5d mm-util.el (mm-ucs-to-char): Use eval-and-compile.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111842
diff changeset
255 ;; Emacs 23.
9d94a05dfc5d mm-util.el (mm-ucs-to-char): Use eval-and-compile.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111842
diff changeset
256 (defalias 'mm-ucs-to-char 'identity)
9d94a05dfc5d mm-util.el (mm-ucs-to-char): Use eval-and-compile.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111842
diff changeset
257 (defun mm-ucs-to-char (codepoint)
9d94a05dfc5d mm-util.el (mm-ucs-to-char): Use eval-and-compile.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111842
diff changeset
258 "Convert Unicode codepoint to character."
9d94a05dfc5d mm-util.el (mm-ucs-to-char): Use eval-and-compile.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111842
diff changeset
259 (or (decode-char 'ucs codepoint) ?#)))))
100993
a16e9f7c2536 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100908
diff changeset
260
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
261 ;; Fixme: This seems always to be used to read a MIME charset, so it
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
262 ;; should be re-named and fixed (in Emacs) to offer completion only on
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
263 ;; proper charset names (base coding systems which have a
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
264 ;; mime-charset defined). XEmacs doesn't believe in mime-charset;
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
265 ;; test with
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
266 ;; `(or (coding-system-get 'iso-8859-1 'mime-charset)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
267 ;; (coding-system-get 'iso-8859-1 :mime-charset))'
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
268 ;; Actually, there should be an `mm-coding-system-mime-charset'.
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
269 (eval-and-compile
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
270 (defalias 'mm-read-coding-system
111303
488230abc7fd Silence compilation of mm-util.el.
Glenn Morris <rgm@gnu.org>
parents: 111286
diff changeset
271 (if (featurep 'emacs) 'read-coding-system
488230abc7fd Silence compilation of mm-util.el.
Glenn Morris <rgm@gnu.org>
parents: 111286
diff changeset
272 (cond
488230abc7fd Silence compilation of mm-util.el.
Glenn Morris <rgm@gnu.org>
parents: 111286
diff changeset
273 ((fboundp 'read-coding-system)
488230abc7fd Silence compilation of mm-util.el.
Glenn Morris <rgm@gnu.org>
parents: 111286
diff changeset
274 (if (and (featurep 'xemacs)
488230abc7fd Silence compilation of mm-util.el.
Glenn Morris <rgm@gnu.org>
parents: 111286
diff changeset
275 (<= (string-to-number emacs-version) 21.1))
488230abc7fd Silence compilation of mm-util.el.
Glenn Morris <rgm@gnu.org>
parents: 111286
diff changeset
276 (lambda (prompt &optional default-coding-system)
488230abc7fd Silence compilation of mm-util.el.
Glenn Morris <rgm@gnu.org>
parents: 111286
diff changeset
277 (read-coding-system prompt))
488230abc7fd Silence compilation of mm-util.el.
Glenn Morris <rgm@gnu.org>
parents: 111286
diff changeset
278 'read-coding-system))
488230abc7fd Silence compilation of mm-util.el.
Glenn Morris <rgm@gnu.org>
parents: 111286
diff changeset
279 (t (lambda (prompt &optional default-coding-system)
488230abc7fd Silence compilation of mm-util.el.
Glenn Morris <rgm@gnu.org>
parents: 111286
diff changeset
280 "Prompt the user for a coding system."
488230abc7fd Silence compilation of mm-util.el.
Glenn Morris <rgm@gnu.org>
parents: 111286
diff changeset
281 (gnus-completing-read
488230abc7fd Silence compilation of mm-util.el.
Glenn Morris <rgm@gnu.org>
parents: 111286
diff changeset
282 prompt (mapcar (lambda (s) (symbol-name (car s)))
488230abc7fd Silence compilation of mm-util.el.
Glenn Morris <rgm@gnu.org>
parents: 111286
diff changeset
283 mm-mime-mule-charset-alist))))))))
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
284
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
285 (defvar mm-coding-system-list nil)
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
286 (defun mm-get-coding-system-list ()
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
287 "Get the coding system list."
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
288 (or mm-coding-system-list
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
289 (setq mm-coding-system-list (mm-coding-system-list))))
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
290
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
291 (defun mm-coding-system-p (cs)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
292 "Return non-nil if CS is a symbol naming a coding system.
57923
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
293 In XEmacs, also return non-nil if CS is a coding system object.
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
294 If CS is available, return CS itself in Emacs, and return a coding
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
295 system object in XEmacs."
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
296 (if (fboundp 'find-coding-system)
61424
ad05d91d3598 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-243
Miles Bader <miles@gnu.org>
parents: 61126
diff changeset
297 (and cs (find-coding-system cs))
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
298 (if (fboundp 'coding-system-p)
57923
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
299 (when (coding-system-p cs)
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
300 cs)
69135
12d289b6e5de Revision: emacs@sv.gnu.org/emacs--devo--0--patch-118
Miles Bader <miles@gnu.org>
parents: 68940
diff changeset
301 ;; no-MULE XEmacs:
57923
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
302 (car (memq cs (mm-get-coding-system-list))))))
36556
8af75e618534 (mm-mime-mule-charset-alist): Move it after definition of
Dave Love <fx@gnu.org>
parents: 36539
diff changeset
303
70052
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
304 (defun mm-codepage-setup (number &optional alias)
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
305 "Create a coding system cpNUMBER.
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
306 The coding system is created using `codepage-setup'. If ALIAS is
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
307 non-nil, an alias is created and added to
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
308 `mm-charset-synonym-alist'. If ALIAS is a string, it's used as
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
309 the alias. Else windows-NUMBER is used."
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
310 (interactive
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
311 (let ((completion-ignore-case t)
91718
89610dccd10a (mm-codepage-setup): If cp-supported-codepages isn't
Reiner Steib <Reiner.Steib@gmx.de>
parents: 91327
diff changeset
312 (candidates (if (fboundp 'cp-supported-codepages)
89610dccd10a (mm-codepage-setup): If cp-supported-codepages isn't
Reiner Steib <Reiner.Steib@gmx.de>
parents: 91327
diff changeset
313 (cp-supported-codepages)
98462
512497325cb3 (mm-codepage-setup): Tweak codepage error. Silence compiler warning.
Glenn Morris <rgm@gnu.org>
parents: 96275
diff changeset
314 ;; Removed in Emacs 23 (unicode), so signal an error:
105167
e14dfafc8256 * gnus-art.el (gnus-article-encrypt-body):
Juanma Barranquero <lekktu@gmail.com>
parents: 104836
diff changeset
315 (error "`codepage-setup' not present in this Emacs version"))))
110661
2b8ece636433 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110637
diff changeset
316 (list (gnus-completing-read "Setup DOS Codepage" candidates
2b8ece636433 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110637
diff changeset
317 t nil nil "437"))))
70052
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
318 (when alias
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
319 (setq alias (if (stringp alias)
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
320 (intern alias)
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
321 (intern (format "windows-%s" number)))))
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
322 (let* ((cp (intern (format "cp%s" number))))
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
323 (unless (mm-coding-system-p cp)
98462
512497325cb3 (mm-codepage-setup): Tweak codepage error. Silence compiler warning.
Glenn Morris <rgm@gnu.org>
parents: 96275
diff changeset
324 (if (fboundp 'codepage-setup) ; silence compiler
512497325cb3 (mm-codepage-setup): Tweak codepage error. Silence compiler warning.
Glenn Morris <rgm@gnu.org>
parents: 96275
diff changeset
325 (codepage-setup number)
105167
e14dfafc8256 * gnus-art.el (gnus-article-encrypt-body):
Juanma Barranquero <lekktu@gmail.com>
parents: 104836
diff changeset
326 (error "`codepage-setup' not present in this Emacs version")))
70052
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
327 (when (and alias
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
328 ;; Don't add alias if setup of cp failed.
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
329 (mm-coding-system-p cp))
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
330 (add-to-list 'mm-charset-synonym-alist (cons alias cp)))))
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
331
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
332 (defvar mm-charset-synonym-alist
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
333 `(
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
334 ;; Not in XEmacs, but it's not a proper MIME charset anyhow.
40621
11741b5b7d18 2001-11-01 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40542
diff changeset
335 ,@(unless (mm-coding-system-p 'x-ctext)
71926
e5faa9959a89 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 71262
diff changeset
336 '((x-ctext . ctext)))
73546
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
337 ;; ISO-8859-15 is very similar to ISO-8859-1. But it's _different_ in 8
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
338 ;; positions!
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
339 ,@(unless (mm-coding-system-p 'iso-8859-15)
71926
e5faa9959a89 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 71262
diff changeset
340 '((iso-8859-15 . iso-8859-1)))
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
341 ;; BIG-5HKSCS is similar to, but different than, BIG-5.
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
342 ,@(unless (mm-coding-system-p 'big5-hkscs)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
343 '((big5-hkscs . big5)))
70052
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
344 ;; A Microsoft misunderstanding.
73546
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
345 ,@(when (and (not (mm-coding-system-p 'unicode))
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
346 (mm-coding-system-p 'utf-16-le))
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
347 '((unicode . utf-16-le)))
70052
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
348 ;; A Microsoft misunderstanding.
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
349 ,@(unless (mm-coding-system-p 'ks_c_5601-1987)
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
350 (if (mm-coding-system-p 'cp949)
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
351 '((ks_c_5601-1987 . cp949))
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
352 '((ks_c_5601-1987 . euc-kr))))
71926
e5faa9959a89 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 71262
diff changeset
353 ;; Windows-31J is Windows Codepage 932.
73546
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
354 ,@(when (and (not (mm-coding-system-p 'windows-31j))
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
355 (mm-coding-system-p 'cp932))
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
356 '((windows-31j . cp932)))
79022
65ad63ddd4f6 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
357 ;; Charset name: GBK, Charset aliases: CP936, MS936, windows-936
65ad63ddd4f6 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
358 ;; http://www.iana.org/assignments/charset-reg/GBK
65ad63ddd4f6 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
359 ;; Emacs 22.1 has cp936, but not gbk, so we alias it:
65ad63ddd4f6 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
360 ,@(when (and (not (mm-coding-system-p 'gbk))
65ad63ddd4f6 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
361 (mm-coding-system-p 'cp936))
65ad63ddd4f6 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
362 '((gbk . cp936)))
100454
b8d5bfa98123 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100444
diff changeset
363 ;; UTF8 is a bogus name for UTF-8
b8d5bfa98123 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100444
diff changeset
364 ,@(when (and (not (mm-coding-system-p 'utf8))
b8d5bfa98123 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100444
diff changeset
365 (mm-coding-system-p 'utf-8))
b8d5bfa98123 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100444
diff changeset
366 '((utf8 . utf-8)))
85712
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
367 ;; ISO8859-1 is a bogus name for ISO-8859-1
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
368 ,@(when (and (not (mm-coding-system-p 'iso8859-1))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
369 (mm-coding-system-p 'iso-8859-1))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
370 '((iso8859-1 . iso-8859-1)))
100454
b8d5bfa98123 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100444
diff changeset
371 ;; ISO_8859-1 is a bogus name for ISO-8859-1
b8d5bfa98123 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100444
diff changeset
372 ,@(when (and (not (mm-coding-system-p 'iso_8859-1))
b8d5bfa98123 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100444
diff changeset
373 (mm-coding-system-p 'iso-8859-1))
b8d5bfa98123 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100444
diff changeset
374 '((iso_8859-1 . iso-8859-1)))
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
375 )
73546
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
376 "A mapping from unknown or invalid charset names to the real charset names.
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
377
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
378 See `mm-codepage-iso-8859-list' and `mm-codepage-ibm-list'.")
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
379
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
380 (defcustom mm-codepage-iso-8859-list
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
381 (list 1250 ;; Windows-1250 is a variant of Latin-2 heavily used by Microsoft
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
382 ;; Outlook users in Czech republic. Use this to allow reading of
110637
494ea2fb03d7 Remove Emacs 21 stuff.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110475
diff changeset
383 ;; their e-mails.
73546
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
384 '(1252 . 1) ;; Windows-1252 is a superset of iso-8859-1 (West
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
385 ;; Europe). See also `gnus-article-dumbquotes-map'.
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
386 '(1254 . 9) ;; Windows-1254 is a superset of iso-8859-9 (Turkish).
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
387 '(1255 . 8));; Windows-1255 is a superset of iso-8859-8 (Hebrew).
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
388 "A list of Windows codepage numbers and iso-8859 charset numbers.
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
389
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
390 If an element is a number corresponding to a supported windows
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
391 codepage, appropriate entries to `mm-charset-synonym-alist' are
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
392 added by `mm-setup-codepage-iso-8859'. An element may also be a
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
393 cons cell where the car is a codepage number and the cdr is the
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
394 corresponding number of an iso-8859 charset."
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
395 :type '(list (set :inline t
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
396 (const 1250 :tag "Central and East European")
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
397 (const (1252 . 1) :tag "West European")
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
398 (const (1254 . 9) :tag "Turkish")
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
399 (const (1255 . 8) :tag "Hebrew"))
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
400 (repeat :inline t
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
401 :tag "Other options"
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
402 (choice
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
403 (integer :tag "Windows codepage number")
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
404 (cons (integer :tag "Windows codepage number")
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
405 (integer :tag "iso-8859 charset number")))))
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
406 :version "22.1" ;; Gnus 5.10.9
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
407 :group 'mime)
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
408
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
409 (defcustom mm-codepage-ibm-list
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
410 (list 437 ;; (US etc.)
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
411 860 ;; (Portugal)
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
412 861 ;; (Iceland)
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
413 862 ;; (Israel)
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
414 863 ;; (Canadian French)
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
415 865 ;; (Nordic)
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
416 852 ;;
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
417 850 ;; (Latin 1)
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
418 855 ;; (Cyrillic)
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
419 866 ;; (Cyrillic - Russian)
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
420 857 ;; (Turkish)
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
421 864 ;; (Arabic)
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
422 869 ;; (Greek)
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
423 874);; (Thai)
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
424 ;; In Emacs 23 (unicode), cp... and ibm... are aliases.
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
425 ;; Cf. http://thread.gmane.org/v9lkng5nwy.fsf@marauder.physik.uni-ulm.de
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
426 "List of IBM codepage numbers.
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
427
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
428 The codepage mappings slighly differ between IBM and other vendors.
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
429 See \"ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/IBM/README.TXT\".
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
430
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
431 If an element is a number corresponding to a supported windows
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
432 codepage, appropriate entries to `mm-charset-synonym-alist' are
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
433 added by `mm-setup-codepage-ibm'."
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
434 :type '(list (set :inline t
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
435 (const 437 :tag "US etc.")
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
436 (const 860 :tag "Portugal")
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
437 (const 861 :tag "Iceland")
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
438 (const 862 :tag "Israel")
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
439 (const 863 :tag "Canadian French")
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
440 (const 865 :tag "Nordic")
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
441 (const 852)
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
442 (const 850 :tag "Latin 1")
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
443 (const 855 :tag "Cyrillic")
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
444 (const 866 :tag "Cyrillic - Russian")
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
445 (const 857 :tag "Turkish")
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
446 (const 864 :tag "Arabic")
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
447 (const 869 :tag "Greek")
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
448 (const 874 :tag "Thai"))
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
449 (repeat :inline t
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
450 :tag "Other options"
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
451 (integer :tag "Codepage number")))
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
452 :version "22.1" ;; Gnus 5.10.9
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
453 :group 'mime)
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
454
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
455 (defun mm-setup-codepage-iso-8859 (&optional list)
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
456 "Add appropriate entries to `mm-charset-synonym-alist'.
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
457 Unless LIST is given, `mm-codepage-iso-8859-list' is used."
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
458 (unless list
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
459 (setq list mm-codepage-iso-8859-list))
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
460 (dolist (i list)
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
461 (let (cp windows iso)
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
462 (if (consp i)
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
463 (setq cp (intern (format "cp%d" (car i)))
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
464 windows (intern (format "windows-%d" (car i)))
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
465 iso (intern (format "iso-8859-%d" (cdr i))))
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
466 (setq cp (intern (format "cp%d" i))
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
467 windows (intern (format "windows-%d" i))))
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
468 (unless (mm-coding-system-p windows)
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
469 (if (mm-coding-system-p cp)
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
470 (add-to-list 'mm-charset-synonym-alist (cons windows cp))
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
471 (add-to-list 'mm-charset-synonym-alist (cons windows iso)))))))
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
472
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
473 (defun mm-setup-codepage-ibm (&optional list)
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
474 "Add appropriate entries to `mm-charset-synonym-alist'.
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
475 Unless LIST is given, `mm-codepage-ibm-list' is used."
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
476 (unless list
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
477 (setq list mm-codepage-ibm-list))
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
478 (dolist (number list)
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
479 (let ((ibm (intern (format "ibm%d" number)))
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
480 (cp (intern (format "cp%d" number))))
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
481 (when (and (not (mm-coding-system-p ibm))
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
482 (mm-coding-system-p cp))
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
483 (add-to-list 'mm-charset-synonym-alist (cons ibm cp))))))
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
484
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
485 ;; Initialize:
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
486 (mm-setup-codepage-iso-8859)
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
487 (mm-setup-codepage-ibm)
70052
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
488
100429
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
489 ;; Note: this has to be defined before `mm-charset-to-coding-system'.
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
490 (defcustom mm-charset-eval-alist
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
491 (if (featurep 'xemacs)
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
492 nil ;; I don't know what would be useful for XEmacs.
110637
494ea2fb03d7 Remove Emacs 21 stuff.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110475
diff changeset
493 '(;; Emacs 22 provides autoloads for 1250-1258
494ea2fb03d7 Remove Emacs 21 stuff.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110475
diff changeset
494 ;; (i.e. `mm-codepage-setup' does nothing).
100429
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
495 (windows-1250 . (mm-codepage-setup 1250 t))
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
496 (windows-1251 . (mm-codepage-setup 1251 t))
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
497 (windows-1253 . (mm-codepage-setup 1253 t))
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
498 (windows-1257 . (mm-codepage-setup 1257 t))))
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
499 "An alist of (CHARSET . FORM) pairs.
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
500 If an article is encoded in an unknown CHARSET, FORM is
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
501 evaluated. This allows to load additional libraries providing
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
502 charsets on demand. If supported by your Emacs version, you
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
503 could use `autoload-coding-system' here."
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
504 :version "22.1" ;; Gnus 5.10.9
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
505 :type '(list (set :inline t
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
506 (const (windows-1250 . (mm-codepage-setup 1250 t)))
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
507 (const (windows-1251 . (mm-codepage-setup 1251 t)))
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
508 (const (windows-1253 . (mm-codepage-setup 1253 t)))
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
509 (const (windows-1257 . (mm-codepage-setup 1257 t)))
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
510 (const (cp850 . (mm-codepage-setup 850 nil))))
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
511 (repeat :inline t
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
512 :tag "Other options"
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
513 (cons (symbol :tag "charset")
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
514 (symbol :tag "form"))))
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
515 :group 'mime)
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
516 (put 'mm-charset-eval-alist 'risky-local-variable t)
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
517
100444
3e9018e11d27 (mm-charset-override-alist): Declare for compiler.
Glenn Morris <rgm@gnu.org>
parents: 100429
diff changeset
518 (defvar mm-charset-override-alist)
3e9018e11d27 (mm-charset-override-alist): Declare for compiler.
Glenn Morris <rgm@gnu.org>
parents: 100429
diff changeset
519
100429
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
520 ;; Note: this function has to be defined before `mm-charset-override-alist'
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
521 ;; since it will use this function in order to determine its default value
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
522 ;; when loading mm-util.elc.
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
523 (defun mm-charset-to-coding-system (charset &optional lbt
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
524 allow-override silent)
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
525 "Return coding-system corresponding to CHARSET.
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
526 CHARSET is a symbol naming a MIME charset.
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
527 If optional argument LBT (`unix', `dos' or `mac') is specified, it is
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
528 used as the line break code type of the coding system.
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
529
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
530 If ALLOW-OVERRIDE is given, use `mm-charset-override-alist' to
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
531 map undesired charset names to their replacement. This should
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
532 only be used for decoding, not for encoding.
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
533
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
534 A non-nil value of SILENT means don't issue a warning even if CHARSET
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
535 is not available."
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
536 ;; OVERRIDE is used (only) in `mm-decode-body' and `mm-decode-string'.
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
537 (when (stringp charset)
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
538 (setq charset (intern (downcase charset))))
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
539 (when lbt
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
540 (setq charset (intern (format "%s-%s" charset lbt))))
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
541 (cond
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
542 ((null charset)
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
543 charset)
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
544 ;; Running in a non-MULE environment.
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
545 ((or (null (mm-get-coding-system-list))
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
546 (not (fboundp 'coding-system-get)))
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
547 charset)
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
548 ;; Check override list quite early. Should only used for decoding, not for
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
549 ;; encoding!
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
550 ((and allow-override
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
551 (let ((cs (cdr (assq charset mm-charset-override-alist))))
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
552 (and cs (mm-coding-system-p cs) cs))))
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
553 ;; ascii
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
554 ((eq charset 'us-ascii)
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
555 'ascii)
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
556 ;; Check to see whether we can handle this charset. (This depends
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
557 ;; on there being some coding system matching each `mime-charset'
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
558 ;; property defined, as there should be.)
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
559 ((and (mm-coding-system-p charset)
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
560 ;;; Doing this would potentially weed out incorrect charsets.
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
561 ;;; charset
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
562 ;;; (eq charset (coding-system-get charset 'mime-charset))
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
563 )
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
564 charset)
107393
a2823b84b7fb (mm-charset-to-coding-system): Use coding-system-from-name
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 106815
diff changeset
565 ;; Use coding system Emacs knows.
a2823b84b7fb (mm-charset-to-coding-system): Use coding-system-from-name
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 106815
diff changeset
566 ((and (fboundp 'coding-system-from-name)
a2823b84b7fb (mm-charset-to-coding-system): Use coding-system-from-name
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 106815
diff changeset
567 (coding-system-from-name charset)))
100429
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
568 ;; Eval expressions from `mm-charset-eval-alist'
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
569 ((let* ((el (assq charset mm-charset-eval-alist))
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
570 (cs (car el))
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
571 (form (cdr el)))
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
572 (and cs
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
573 form
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
574 (prog2
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
575 ;; Avoid errors...
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
576 (condition-case nil (eval form) (error nil))
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
577 ;; (message "Failed to eval `%s'" form))
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
578 (mm-coding-system-p cs)
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
579 (message "Added charset `%s' via `mm-charset-eval-alist'" cs))
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
580 cs)))
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
581 ;; Translate invalid charsets.
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
582 ((let ((cs (cdr (assq charset mm-charset-synonym-alist))))
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
583 (and cs
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
584 (mm-coding-system-p cs)
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
585 ;; (message
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
586 ;; "Using synonym `%s' from `mm-charset-synonym-alist' for `%s'"
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
587 ;; cs charset)
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
588 cs)))
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
589 ;; Last resort: search the coding system list for entries which
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
590 ;; have the right mime-charset in case the canonical name isn't
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
591 ;; defined (though it should be).
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
592 ((let (cs)
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
593 ;; mm-get-coding-system-list returns a list of cs without lbt.
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
594 ;; Do we need -lbt?
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
595 (dolist (c (mm-get-coding-system-list))
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
596 (if (and (null cs)
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
597 (eq charset (or (coding-system-get c :mime-charset)
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
598 (coding-system-get c 'mime-charset))))
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
599 (setq cs c)))
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
600 (unless (or silent cs)
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
601 ;; Warn the user about unknown charset:
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
602 (if (fboundp 'gnus-message)
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
603 (gnus-message 7 "Unknown charset: %s" charset)
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
604 (message "Unknown charset: %s" charset)))
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
605 cs))))
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
606
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
607 ;; Note: `mm-charset-to-coding-system' has to be defined before this.
70052
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
608 (defcustom mm-charset-override-alist
100429
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
609 ;; Note: pairs that cannot be used in the Emacs version currently running
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
610 ;; will be removed.
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
611 '((gb2312 . gbk)
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
612 (iso-8859-1 . windows-1252)
85712
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
613 (iso-8859-8 . windows-1255)
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
614 (iso-8859-9 . windows-1254))
70052
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
615 "A mapping from undesired charset names to their replacement.
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
616
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
617 You may add pairs like (iso-8859-1 . windows-1252) here,
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
618 i.e. treat iso-8859-1 as windows-1252. windows-1252 is a
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
619 superset of iso-8859-1."
100315
da90832da238 * rfc2047.el (rfc2047-charset-to-coding-system): Add new argument
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 98462
diff changeset
620 :type
da90832da238 * rfc2047.el (rfc2047-charset-to-coding-system): Add new argument
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 98462
diff changeset
621 '(list
da90832da238 * rfc2047.el (rfc2047-charset-to-coding-system): Add new argument
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 98462
diff changeset
622 :convert-widget
da90832da238 * rfc2047.el (rfc2047-charset-to-coding-system): Add new argument
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 98462
diff changeset
623 (lambda (widget)
da90832da238 * rfc2047.el (rfc2047-charset-to-coding-system): Add new argument
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 98462
diff changeset
624 (let ((defaults
da90832da238 * rfc2047.el (rfc2047-charset-to-coding-system): Add new argument
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 98462
diff changeset
625 (delq nil
da90832da238 * rfc2047.el (rfc2047-charset-to-coding-system): Add new argument
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 98462
diff changeset
626 (mapcar (lambda (pair)
100429
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
627 (if (mm-charset-to-coding-system (cdr pair)
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
628 nil nil t)
100315
da90832da238 * rfc2047.el (rfc2047-charset-to-coding-system): Add new argument
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 98462
diff changeset
629 pair))
da90832da238 * rfc2047.el (rfc2047-charset-to-coding-system): Add new argument
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 98462
diff changeset
630 '((gb2312 . gbk)
da90832da238 * rfc2047.el (rfc2047-charset-to-coding-system): Add new argument
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 98462
diff changeset
631 (iso-8859-1 . windows-1252)
da90832da238 * rfc2047.el (rfc2047-charset-to-coding-system): Add new argument
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 98462
diff changeset
632 (iso-8859-8 . windows-1255)
da90832da238 * rfc2047.el (rfc2047-charset-to-coding-system): Add new argument
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 98462
diff changeset
633 (iso-8859-9 . windows-1254)
da90832da238 * rfc2047.el (rfc2047-charset-to-coding-system): Add new argument
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 98462
diff changeset
634 (undecided . windows-1252)))))
da90832da238 * rfc2047.el (rfc2047-charset-to-coding-system): Add new argument
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 98462
diff changeset
635 (val (copy-sequence (default-value 'mm-charset-override-alist)))
da90832da238 * rfc2047.el (rfc2047-charset-to-coding-system): Add new argument
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 98462
diff changeset
636 pair rest)
da90832da238 * rfc2047.el (rfc2047-charset-to-coding-system): Add new argument
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 98462
diff changeset
637 (while val
da90832da238 * rfc2047.el (rfc2047-charset-to-coding-system): Add new argument
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 98462
diff changeset
638 (push (if (and (prog1
da90832da238 * rfc2047.el (rfc2047-charset-to-coding-system): Add new argument
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 98462
diff changeset
639 (setq pair (assq (caar val) defaults))
da90832da238 * rfc2047.el (rfc2047-charset-to-coding-system): Add new argument
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 98462
diff changeset
640 (setq defaults (delq pair defaults)))
da90832da238 * rfc2047.el (rfc2047-charset-to-coding-system): Add new argument
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 98462
diff changeset
641 (equal (car val) pair))
da90832da238 * rfc2047.el (rfc2047-charset-to-coding-system): Add new argument
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 98462
diff changeset
642 `(const ,pair)
da90832da238 * rfc2047.el (rfc2047-charset-to-coding-system): Add new argument
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 98462
diff changeset
643 `(cons :format "%v"
da90832da238 * rfc2047.el (rfc2047-charset-to-coding-system): Add new argument
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 98462
diff changeset
644 (const :format "(%v" ,(caar val))
da90832da238 * rfc2047.el (rfc2047-charset-to-coding-system): Add new argument
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 98462
diff changeset
645 (symbol :size 3 :format " . %v)\n" ,(cdar val))))
da90832da238 * rfc2047.el (rfc2047-charset-to-coding-system): Add new argument
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 98462
diff changeset
646 rest)
da90832da238 * rfc2047.el (rfc2047-charset-to-coding-system): Add new argument
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 98462
diff changeset
647 (setq val (cdr val)))
da90832da238 * rfc2047.el (rfc2047-charset-to-coding-system): Add new argument
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 98462
diff changeset
648 (while defaults
da90832da238 * rfc2047.el (rfc2047-charset-to-coding-system): Add new argument
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 98462
diff changeset
649 (push `(const ,(pop defaults)) rest))
da90832da238 * rfc2047.el (rfc2047-charset-to-coding-system): Add new argument
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 98462
diff changeset
650 (widget-convert
da90832da238 * rfc2047.el (rfc2047-charset-to-coding-system): Add new argument
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 98462
diff changeset
651 'list
da90832da238 * rfc2047.el (rfc2047-charset-to-coding-system): Add new argument
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 98462
diff changeset
652 `(set :inline t :format "%v" ,@(nreverse rest))
da90832da238 * rfc2047.el (rfc2047-charset-to-coding-system): Add new argument
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 98462
diff changeset
653 `(repeat :inline t :tag "Other options"
da90832da238 * rfc2047.el (rfc2047-charset-to-coding-system): Add new argument
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 98462
diff changeset
654 (cons :format "%v"
da90832da238 * rfc2047.el (rfc2047-charset-to-coding-system): Add new argument
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 98462
diff changeset
655 (symbol :size 3 :format "(%v")
da90832da238 * rfc2047.el (rfc2047-charset-to-coding-system): Add new argument
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 98462
diff changeset
656 (symbol :size 3 :format " . %v)\n")))))))
100429
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
657 ;; Remove pairs that cannot be used in the Emacs version currently
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
658 ;; running. Note that this section will be evaluated when loading
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
659 ;; mm-util.elc.
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
660 :set (lambda (symbol value)
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
661 (custom-set-default
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
662 symbol (delq nil
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
663 (mapcar (lambda (pair)
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
664 (if (mm-charset-to-coding-system (cdr pair)
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
665 nil nil t)
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
666 pair))
7255d1413d64 (mm-charset-eval-alist): Define it before mm-charset-to-coding-system.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100315
diff changeset
667 value))))
73224
36dcde72adad Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 71926
diff changeset
668 :version "22.1" ;; Gnus 5.10.9
70052
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
669 :group 'mime)
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
670
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
671 (defvar mm-binary-coding-system
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
672 (cond
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
673 ((mm-coding-system-p 'binary) 'binary)
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
674 ((mm-coding-system-p 'no-conversion) 'no-conversion)
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
675 (t nil))
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
676 "100% binary coding system.")
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
677
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
678 (defvar mm-text-coding-system
110039
459fd421257a gnus-group-completing-read: Add 'substring to completion-styles for group selection; imap.el, mailcap.el, message.el, mm-util.el, nnheader.el, nnmail.el, pop3.el: Remove references to outdated systems; References to win32 w32 mswindows ms-windows emx were probably cargo-culted, and are removed for clarity; By Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 108465
diff changeset
679 (or (if (memq system-type '(windows-nt ms-dos))
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
680 (and (mm-coding-system-p 'raw-text-dos) 'raw-text-dos)
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
681 (and (mm-coding-system-p 'raw-text) 'raw-text))
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
682 mm-binary-coding-system)
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
683 "Text-safe coding system (For removing ^M).")
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
684
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
685 (defvar mm-text-coding-system-for-write nil
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
686 "Text coding system for write.")
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
687
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
688 (defvar mm-auto-save-coding-system
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
689 (cond
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
690 ((mm-coding-system-p 'utf-8-emacs) ; Mule 7
110039
459fd421257a gnus-group-completing-read: Add 'substring to completion-styles for group selection; imap.el, mailcap.el, message.el, mm-util.el, nnheader.el, nnmail.el, pop3.el: Remove references to outdated systems; References to win32 w32 mswindows ms-windows emx were probably cargo-culted, and are removed for clarity; By Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 108465
diff changeset
691 (if (memq system-type '(windows-nt ms-dos))
47949
33e1238070a2 (mm-mime-mule-charset-alist): Require when compiling.
Dave Love <fx@gnu.org>
parents: 44075
diff changeset
692 (if (mm-coding-system-p 'utf-8-emacs-dos)
33e1238070a2 (mm-mime-mule-charset-alist): Require when compiling.
Dave Love <fx@gnu.org>
parents: 44075
diff changeset
693 'utf-8-emacs-dos mm-binary-coding-system)
33e1238070a2 (mm-mime-mule-charset-alist): Require when compiling.
Dave Love <fx@gnu.org>
parents: 44075
diff changeset
694 'utf-8-emacs))
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
695 ((mm-coding-system-p 'emacs-mule)
110039
459fd421257a gnus-group-completing-read: Add 'substring to completion-styles for group selection; imap.el, mailcap.el, message.el, mm-util.el, nnheader.el, nnmail.el, pop3.el: Remove references to outdated systems; References to win32 w32 mswindows ms-windows emx were probably cargo-culted, and are removed for clarity; By Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 108465
diff changeset
696 (if (memq system-type '(windows-nt ms-dos))
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
697 (if (mm-coding-system-p 'emacs-mule-dos)
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
698 'emacs-mule-dos mm-binary-coding-system)
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
699 'emacs-mule))
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
700 ((mm-coding-system-p 'escape-quoted) 'escape-quoted)
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
701 (t mm-binary-coding-system))
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
702 "Coding system of auto save file.")
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
703
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
704 (defvar mm-universal-coding-system mm-auto-save-coding-system
41494
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
705 "The universal coding system.")
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
706
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
707 ;; Fixme: some of the cars here aren't valid MIME charsets. That
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
708 ;; should only matter with XEmacs, though.
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
709 (defvar mm-mime-mule-charset-alist
35793
46d71cfa2272 (mm-mime-mule-charset-alist)
Dave Love <fx@gnu.org>
parents: 35618
diff changeset
710 `((us-ascii ascii)
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
711 (iso-8859-1 latin-iso8859-1)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
712 (iso-8859-2 latin-iso8859-2)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
713 (iso-8859-3 latin-iso8859-3)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
714 (iso-8859-4 latin-iso8859-4)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
715 (iso-8859-5 cyrillic-iso8859-5)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
716 ;; Non-mule (X)Emacs uses the last mule-charset for 8bit characters.
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
717 ;; The fake mule-charset, gnus-koi8-r, tells Gnus that the default
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
718 ;; charset is koi8-r, not iso-8859-5.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
719 (koi8-r cyrillic-iso8859-5 gnus-koi8-r)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
720 (iso-8859-6 arabic-iso8859-6)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
721 (iso-8859-7 greek-iso8859-7)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
722 (iso-8859-8 hebrew-iso8859-8)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
723 (iso-8859-9 latin-iso8859-9)
35148
a408e1d28e3d (mm-mime-mule-charset-alist): Add Latin-{8,9}.
Dave Love <fx@gnu.org>
parents: 34724
diff changeset
724 (iso-8859-14 latin-iso8859-14)
a408e1d28e3d (mm-mime-mule-charset-alist): Add Latin-{8,9}.
Dave Love <fx@gnu.org>
parents: 34724
diff changeset
725 (iso-8859-15 latin-iso8859-15)
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
726 (viscii vietnamese-viscii-lower)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
727 (iso-2022-jp latin-jisx0201 japanese-jisx0208 japanese-jisx0208-1978)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
728 (euc-kr korean-ksc5601)
35838
53eebdb81828 2001-02-01 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 35793
diff changeset
729 (gb2312 chinese-gb2312)
90683
70c40ef3afa5 (mm-mime-mule-charset-alist): Add gbk and GB18030.
Kenichi Handa <handa@m17n.org>
parents: 90645
diff changeset
730 (gbk chinese-gbk)
70c40ef3afa5 (mm-mime-mule-charset-alist): Add gbk and GB18030.
Kenichi Handa <handa@m17n.org>
parents: 90645
diff changeset
731 (gb18030 gb18030-2-byte
70c40ef3afa5 (mm-mime-mule-charset-alist): Add gbk and GB18030.
Kenichi Handa <handa@m17n.org>
parents: 90645
diff changeset
732 gb18030-4-byte-bmp gb18030-4-byte-smp
70c40ef3afa5 (mm-mime-mule-charset-alist): Add gbk and GB18030.
Kenichi Handa <handa@m17n.org>
parents: 90645
diff changeset
733 gb18030-4-byte-ext-1 gb18030-4-byte-ext-2)
35838
53eebdb81828 2001-02-01 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 35793
diff changeset
734 (big5 chinese-big5-1 chinese-big5-2)
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
735 (tibetan tibetan)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
736 (thai-tis620 thai-tis620)
57923
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
737 (windows-1251 cyrillic-iso8859-5)
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
738 (iso-2022-7bit ethiopic arabic-1-column arabic-2-column)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
739 (iso-2022-jp-2 latin-iso8859-1 greek-iso8859-7
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
740 latin-jisx0201 japanese-jisx0208-1978
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
741 chinese-gb2312 japanese-jisx0208
57923
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
742 korean-ksc5601 japanese-jisx0212)
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
743 (iso-2022-int-1 latin-iso8859-1 greek-iso8859-7
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
744 latin-jisx0201 japanese-jisx0208-1978
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
745 chinese-gb2312 japanese-jisx0208
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
746 korean-ksc5601 japanese-jisx0212
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
747 chinese-cns11643-1 chinese-cns11643-2)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
748 (iso-2022-int-1 latin-iso8859-1 latin-iso8859-2
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
749 cyrillic-iso8859-5 greek-iso8859-7
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
750 latin-jisx0201 japanese-jisx0208-1978
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
751 chinese-gb2312 japanese-jisx0208
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
752 korean-ksc5601 japanese-jisx0212
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
753 chinese-cns11643-1 chinese-cns11643-2
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
754 chinese-cns11643-3 chinese-cns11643-4
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
755 chinese-cns11643-5 chinese-cns11643-6
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
756 chinese-cns11643-7)
57923
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
757 (iso-2022-jp-3 latin-jisx0201 japanese-jisx0208-1978 japanese-jisx0208
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
758 japanese-jisx0213-1 japanese-jisx0213-2)
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
759 (shift_jis latin-jisx0201 katakana-jisx0201 japanese-jisx0208)
71262
70b055c73c8c Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 70052
diff changeset
760 ,(cond ((fboundp 'unicode-precedence-list)
70b055c73c8c Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 70052
diff changeset
761 (cons 'utf-8 (delq 'ascii (mapcar 'charset-name
70b055c73c8c Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 70052
diff changeset
762 (unicode-precedence-list)))))
70b055c73c8c Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 70052
diff changeset
763 ((or (not (fboundp 'charsetp)) ;; non-Mule case
70b055c73c8c Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 70052
diff changeset
764 (charsetp 'unicode-a)
70b055c73c8c Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 70052
diff changeset
765 (not (mm-coding-system-p 'mule-utf-8)))
70b055c73c8c Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 70052
diff changeset
766 '(utf-8 unicode-a unicode-b unicode-c unicode-d unicode-e))
70b055c73c8c Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 70052
diff changeset
767 (t ;; If we have utf-8 we're in Mule 5+.
70b055c73c8c Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 70052
diff changeset
768 (append '(utf-8)
70b055c73c8c Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 70052
diff changeset
769 (delete 'ascii
70b055c73c8c Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 70052
diff changeset
770 (coding-system-get 'mule-utf-8 'safe-charsets))))))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
771 "Alist of MIME-charset/MULE-charsets.")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
772
57923
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
773 (defun mm-enrich-utf-8-by-mule-ucs ()
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
774 "Make the `utf-8' MIME charset usable by the Mule-UCS package.
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
775 This function will run when the `un-define' module is loaded under
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
776 XEmacs, and fill the `utf-8' entry in `mm-mime-mule-charset-alist'
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
777 with Mule charsets. It is completely useless for Emacs."
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
778 (when (boundp 'unicode-basic-translation-charset-order-list)
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
779 (condition-case nil
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
780 (let ((val (delq
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
781 'ascii
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
782 (copy-sequence
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
783 (symbol-value
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
784 'unicode-basic-translation-charset-order-list))))
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
785 (elem (assq 'utf-8 mm-mime-mule-charset-alist)))
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
786 (if elem
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
787 (setcdr elem val)
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
788 (setq mm-mime-mule-charset-alist
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
789 (nconc mm-mime-mule-charset-alist
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
790 (list (cons 'utf-8 val))))))
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
791 (error))))
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
792
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
793 ;; Correct by construction, but should be unnecessary for Emacs:
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
794 (if (featurep 'xemacs)
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
795 (eval-after-load "un-define" '(mm-enrich-utf-8-by-mule-ucs))
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
796 (when (and (fboundp 'coding-system-list)
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
797 (fboundp 'sort-coding-systems))
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
798 (let ((css (sort-coding-systems (coding-system-list 'base-only)))
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
799 cs mime mule alist)
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
800 (while css
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
801 (setq cs (pop css)
90317
34c8b755296d Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-23
Miles Bader <miles@gnu.org>
parents: 90299 69135
diff changeset
802 mime (or (coding-system-get cs :mime-charset); Emacs 23 (unicode)
57923
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
803 (coding-system-get cs 'mime-charset)))
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
804 (when (and mime
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
805 (not (eq t (setq mule
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
806 (coding-system-get cs 'safe-charsets))))
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
807 (not (assq mime alist)))
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
808 (push (cons mime (delq 'ascii mule)) alist)))
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
809 (setq mm-mime-mule-charset-alist (nreverse alist)))))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
810
92153
37d6263f580b Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents: 91718
diff changeset
811 (defvar mm-hack-charsets '(iso-8859-15 iso-2022-jp-2)
37d6263f580b Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents: 91718
diff changeset
812 "A list of special charsets.
37d6263f580b Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents: 91718
diff changeset
813 Valid elements include:
37d6263f580b Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents: 91718
diff changeset
814 `iso-8859-15' convert ISO-8859-1, -9 to ISO-8859-15 if ISO-8859-15 exists.
37d6263f580b Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents: 91718
diff changeset
815 `iso-2022-jp-2' convert ISO-2022-jp to ISO-2022-jp-2 if ISO-2022-jp-2 exists."
37d6263f580b Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents: 91718
diff changeset
816 )
37d6263f580b Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents: 91718
diff changeset
817
37d6263f580b Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents: 91718
diff changeset
818 (defvar mm-iso-8859-15-compatible
37d6263f580b Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents: 91718
diff changeset
819 '((iso-8859-1 "\xA4\xA6\xA8\xB4\xB8\xBC\xBD\xBE")
37d6263f580b Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents: 91718
diff changeset
820 (iso-8859-9 "\xA4\xA6\xA8\xB4\xB8\xBC\xBD\xBE\xD0\xDD\xDE\xF0\xFD\xFE"))
37d6263f580b Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents: 91718
diff changeset
821 "ISO-8859-15 exchangeable coding systems and inconvertible characters.")
37d6263f580b Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents: 91718
diff changeset
822
37d6263f580b Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents: 91718
diff changeset
823 (defvar mm-iso-8859-x-to-15-table
37d6263f580b Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents: 91718
diff changeset
824 (and (fboundp 'coding-system-p)
37d6263f580b Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents: 91718
diff changeset
825 (mm-coding-system-p 'iso-8859-15)
37d6263f580b Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents: 91718
diff changeset
826 (mapcar
37d6263f580b Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents: 91718
diff changeset
827 (lambda (cs)
37d6263f580b Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents: 91718
diff changeset
828 (if (mm-coding-system-p (car cs))
37d6263f580b Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents: 91718
diff changeset
829 (let ((c (string-to-char
37d6263f580b Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents: 91718
diff changeset
830 (decode-coding-string "\341" (car cs)))))
37d6263f580b Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents: 91718
diff changeset
831 (cons (char-charset c)
37d6263f580b Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents: 91718
diff changeset
832 (cons
37d6263f580b Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents: 91718
diff changeset
833 (- (string-to-char
37d6263f580b Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents: 91718
diff changeset
834 (decode-coding-string "\341" 'iso-8859-15)) c)
37d6263f580b Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents: 91718
diff changeset
835 (string-to-list (decode-coding-string (car (cdr cs))
37d6263f580b Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents: 91718
diff changeset
836 (car cs))))))
37d6263f580b Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents: 91718
diff changeset
837 '(gnus-charset 0)))
37d6263f580b Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents: 91718
diff changeset
838 mm-iso-8859-15-compatible))
37d6263f580b Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents: 91718
diff changeset
839 "A table of the difference character between ISO-8859-X and ISO-8859-15.")
37d6263f580b Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents: 91718
diff changeset
840
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
841 (defcustom mm-coding-system-priorities
101165
a22ed49b5bef Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100993
diff changeset
842 (let ((lang (if (boundp 'current-language-environment)
a22ed49b5bef Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100993
diff changeset
843 (symbol-value 'current-language-environment))))
a22ed49b5bef Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100993
diff changeset
844 (cond (;; XEmacs without Mule but with `file-coding'.
a22ed49b5bef Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100993
diff changeset
845 (not lang) nil)
a22ed49b5bef Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100993
diff changeset
846 ;; In XEmacs 21.5 it may be the one like "Japanese (UTF-8)".
a22ed49b5bef Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100993
diff changeset
847 ((string-match "\\`Japanese" lang)
a22ed49b5bef Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100993
diff changeset
848 ;; Japanese users prefer iso-2022-jp to euc-japan or
a22ed49b5bef Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100993
diff changeset
849 ;; shift_jis, however iso-8859-1 should be used when
a22ed49b5bef Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100993
diff changeset
850 ;; there are only ASCII text and Latin-1 characters.
a22ed49b5bef Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 100993
diff changeset
851 '(iso-8859-1 iso-2022-jp iso-2022-jp-2 shift_jis utf-8))))
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
852 "Preferred coding systems for encoding outgoing messages.
41494
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
853
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
854 More than one suitable coding system may be found for some text.
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
855 By default, the coding system with the highest priority is used
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
856 to encode outgoing messages (see `sort-coding-systems'). If this
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
857 variable is set, it overrides the default priority."
57153
497f0d2ca551 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-558
Miles Bader <miles@gnu.org>
parents: 56927
diff changeset
858 :version "21.2"
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
859 :type '(repeat (symbol :tag "Coding system"))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
860 :group 'mime)
41494
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
861
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
862 ;; ??
42500
9b68dff3d385 * mm-util.el (mm-use-find-coding-systems-region): New variable.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 42493
diff changeset
863 (defvar mm-use-find-coding-systems-region
9b68dff3d385 * mm-util.el (mm-use-find-coding-systems-region): New variable.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 42493
diff changeset
864 (fboundp 'find-coding-systems-region)
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
865 "Use `find-coding-systems-region' to find proper coding systems.
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
866
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
867 Setting it to nil is useful on Emacsen supporting Unicode if sending
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
868 mail with multiple parts is preferred to sending a Unicode one.")
42500
9b68dff3d385 * mm-util.el (mm-use-find-coding-systems-region): New variable.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 42493
diff changeset
869
111842
265c545c8f48 Decode extra numeric entities.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
870 (defvar mm-extra-numeric-entities
265c545c8f48 Decode extra numeric entities.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
871 (mapcar
265c545c8f48 Decode extra numeric entities.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
872 (lambda (item)
265c545c8f48 Decode extra numeric entities.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
873 (cons (car item) (mm-ucs-to-char (cdr item))))
265c545c8f48 Decode extra numeric entities.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
874 '((#x80 . #x20AC) (#x82 . #x201A) (#x83 . #x0192) (#x84 . #x201E)
265c545c8f48 Decode extra numeric entities.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
875 (#x85 . #x2026) (#x86 . #x2020) (#x87 . #x2021) (#x88 . #x02C6)
265c545c8f48 Decode extra numeric entities.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
876 (#x89 . #x2030) (#x8A . #x0160) (#x8B . #x2039) (#x8C . #x0152)
265c545c8f48 Decode extra numeric entities.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
877 (#x8E . #x017D) (#x91 . #x2018) (#x92 . #x2019) (#x93 . #x201C)
265c545c8f48 Decode extra numeric entities.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
878 (#x94 . #x201D) (#x95 . #x2022) (#x96 . #x2013) (#x97 . #x2014)
265c545c8f48 Decode extra numeric entities.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
879 (#x98 . #x02DC) (#x99 . #x2122) (#x9A . #x0161) (#x9B . #x203A)
265c545c8f48 Decode extra numeric entities.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
880 (#x9C . #x0153) (#x9E . #x017E) (#x9F . #x0178)))
265c545c8f48 Decode extra numeric entities.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
881 "*Alist of extra numeric entities and characters other than ISO 10646.
265c545c8f48 Decode extra numeric entities.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
882 This table is used for decoding extra numeric entities to characters,
265c545c8f48 Decode extra numeric entities.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
883 like \"&#128;\" to the euro sign, mainly in html messages.")
265c545c8f48 Decode extra numeric entities.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
884
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
885 ;;; Internal variables:
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
886
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
887 ;;; Functions:
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
888
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
889 (defun mm-mule-charset-to-mime-charset (charset)
33378
ab964e52e0ba Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
890 "Return the MIME charset corresponding to the given Mule CHARSET."
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
891 (if (and (fboundp 'find-coding-systems-for-charsets)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
892 (fboundp 'sort-coding-systems))
57923
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
893 (let ((css (sort (sort-coding-systems
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
894 (find-coding-systems-for-charsets (list charset)))
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
895 'mm-sort-coding-systems-predicate))
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
896 cs mime)
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
897 (while (and (not mime)
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
898 css)
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
899 (when (setq cs (pop css))
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
900 (setq mime (or (coding-system-get cs :mime-charset)
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
901 (coding-system-get cs 'mime-charset)))))
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
902 mime)
57923
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
903 (let ((alist (mapcar (lambda (cs)
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
904 (assq cs mm-mime-mule-charset-alist))
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
905 (sort (mapcar 'car mm-mime-mule-charset-alist)
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
906 'mm-sort-coding-systems-predicate)))
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
907 out)
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
908 (while alist
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
909 (when (memq charset (cdar alist))
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
910 (setq out (caar alist)
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
911 alist nil))
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
912 (pop alist))
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
913 out)))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
914
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
915 (eval-and-compile
108287
c0d13767677a Synch with Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 108224
diff changeset
916 (if (featurep 'xemacs)
c0d13767677a Synch with Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 108224
diff changeset
917 (defalias 'mm-enable-multibyte 'ignore)
c0d13767677a Synch with Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 108224
diff changeset
918 (defun mm-enable-multibyte ()
c0d13767677a Synch with Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 108224
diff changeset
919 "Set the multibyte flag of the current buffer.
33378
ab964e52e0ba Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
920 Only do this if the default value of `enable-multibyte-characters' is
ab964e52e0ba Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
921 non-nil. This is a no-op in XEmacs."
111705
cad125981c0f Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111303
diff changeset
922 (set-buffer-multibyte 'to)))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
923
108287
c0d13767677a Synch with Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 108224
diff changeset
924 (if (featurep 'xemacs)
c0d13767677a Synch with Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 108224
diff changeset
925 (defalias 'mm-disable-multibyte 'ignore)
c0d13767677a Synch with Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 108224
diff changeset
926 (defun mm-disable-multibyte ()
c0d13767677a Synch with Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 108224
diff changeset
927 "Unset the multibyte flag of in the current buffer.
33378
ab964e52e0ba Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
928 This is a no-op in XEmacs."
108287
c0d13767677a Synch with Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 108224
diff changeset
929 (set-buffer-multibyte nil))))
32976
aa9dc4e7c5ac 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 32414
diff changeset
930
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
931 (defun mm-preferred-coding-system (charset)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
932 ;; A typo in some Emacs versions.
41494
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
933 (or (get-charset-property charset 'preferred-coding-system)
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
934 (get-charset-property charset 'prefered-coding-system)))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
935
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
936 ;; Mule charsets shouldn't be used.
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
937 (defsubst mm-guess-charset ()
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
938 "Guess Mule charset from the language environment."
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
939 (or
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
940 mail-parse-mule-charset ;; cached mule-charset
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
941 (progn
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
942 (setq mail-parse-mule-charset
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
943 (and (boundp 'current-language-environment)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
944 (car (last
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
945 (assq 'charset
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
946 (assoc current-language-environment
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
947 language-info-alist))))))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
948 (if (or (not mail-parse-mule-charset)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
949 (eq mail-parse-mule-charset 'ascii))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
950 (setq mail-parse-mule-charset
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
951 (or (car (last (assq mail-parse-charset
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
952 mm-mime-mule-charset-alist)))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
953 ;; default
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
954 'latin-iso8859-1)))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
955 mail-parse-mule-charset)))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
956
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
957 (defun mm-charset-after (&optional pos)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
958 "Return charset of a character in current buffer at position POS.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
959 If POS is nil, it defauls to the current point.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
960 If POS is out of range, the value is nil.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
961 If the charset is `composition', return the actual one."
32976
aa9dc4e7c5ac 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 32414
diff changeset
962 (let ((char (char-after pos)) charset)
aa9dc4e7c5ac 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 32414
diff changeset
963 (if (< (mm-char-int char) 128)
aa9dc4e7c5ac 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 32414
diff changeset
964 (setq charset 'ascii)
aa9dc4e7c5ac 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 32414
diff changeset
965 ;; charset-after is fake in some Emacsen.
aa9dc4e7c5ac 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 32414
diff changeset
966 (setq charset (and (fboundp 'char-charset) (char-charset char)))
47949
33e1238070a2 (mm-mime-mule-charset-alist): Require when compiling.
Dave Love <fx@gnu.org>
parents: 44075
diff changeset
967 (if (eq charset 'composition) ; Mule 4
32976
aa9dc4e7c5ac 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 32414
diff changeset
968 (let ((p (or pos (point))))
aa9dc4e7c5ac 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 32414
diff changeset
969 (cadr (find-charset-region p (1+ p))))
aa9dc4e7c5ac 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 32414
diff changeset
970 (if (and charset (not (memq charset '(ascii eight-bit-control
aa9dc4e7c5ac 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 32414
diff changeset
971 eight-bit-graphic))))
aa9dc4e7c5ac 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 32414
diff changeset
972 charset
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
973 (mm-guess-charset))))))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
974
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
975 (defun mm-mime-charset (charset)
33378
ab964e52e0ba Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
976 "Return the MIME charset corresponding to the given Mule CHARSET."
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
977 (if (eq charset 'unknown)
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
978 (error "The message contains non-printable characters, please use attachment"))
32976
aa9dc4e7c5ac 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 32414
diff changeset
979 (if (and (fboundp 'coding-system-get) (fboundp 'get-charset-property))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
980 (or
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
981 (and (mm-preferred-coding-system charset)
47949
33e1238070a2 (mm-mime-mule-charset-alist): Require when compiling.
Dave Love <fx@gnu.org>
parents: 44075
diff changeset
982 (or (coding-system-get
33e1238070a2 (mm-mime-mule-charset-alist): Require when compiling.
Dave Love <fx@gnu.org>
parents: 44075
diff changeset
983 (mm-preferred-coding-system charset) :mime-charset)
33e1238070a2 (mm-mime-mule-charset-alist): Require when compiling.
Dave Love <fx@gnu.org>
parents: 44075
diff changeset
984 (coding-system-get
33e1238070a2 (mm-mime-mule-charset-alist): Require when compiling.
Dave Love <fx@gnu.org>
parents: 44075
diff changeset
985 (mm-preferred-coding-system charset) 'mime-charset)))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
986 (and (eq charset 'ascii)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
987 'us-ascii)
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
988 (mm-preferred-coding-system charset)
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
989 (mm-mule-charset-to-mime-charset charset))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
990 ;; This is for XEmacs.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
991 (mm-mule-charset-to-mime-charset charset)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
992
111789
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111705
diff changeset
993 ;; `delete-dups' is not available in XEmacs 21.4.
65846
a4e8d78ae3fb Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-574
Miles Bader <miles@gnu.org>
parents: 64754
diff changeset
994 (if (fboundp 'delete-dups)
a4e8d78ae3fb Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-574
Miles Bader <miles@gnu.org>
parents: 64754
diff changeset
995 (defalias 'mm-delete-duplicates 'delete-dups)
a4e8d78ae3fb Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-574
Miles Bader <miles@gnu.org>
parents: 64754
diff changeset
996 (defun mm-delete-duplicates (list)
a4e8d78ae3fb Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-574
Miles Bader <miles@gnu.org>
parents: 64754
diff changeset
997 "Destructively remove `equal' duplicates from LIST.
a4e8d78ae3fb Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-574
Miles Bader <miles@gnu.org>
parents: 64754
diff changeset
998 Store the result in LIST and return it. LIST must be a proper list.
a4e8d78ae3fb Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-574
Miles Bader <miles@gnu.org>
parents: 64754
diff changeset
999 Of several `equal' occurrences of an element in LIST, the first
a4e8d78ae3fb Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-574
Miles Bader <miles@gnu.org>
parents: 64754
diff changeset
1000 one is kept.
a4e8d78ae3fb Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-574
Miles Bader <miles@gnu.org>
parents: 64754
diff changeset
1001
a4e8d78ae3fb Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-574
Miles Bader <miles@gnu.org>
parents: 64754
diff changeset
1002 This is a compatibility function for Emacsen without `delete-dups'."
a4e8d78ae3fb Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-574
Miles Bader <miles@gnu.org>
parents: 64754
diff changeset
1003 ;; Code from `subr.el' in Emacs 22:
a4e8d78ae3fb Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-574
Miles Bader <miles@gnu.org>
parents: 64754
diff changeset
1004 (let ((tail list))
a4e8d78ae3fb Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-574
Miles Bader <miles@gnu.org>
parents: 64754
diff changeset
1005 (while tail
a4e8d78ae3fb Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-574
Miles Bader <miles@gnu.org>
parents: 64754
diff changeset
1006 (setcdr tail (delete (car tail) (cdr tail)))
a4e8d78ae3fb Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-574
Miles Bader <miles@gnu.org>
parents: 64754
diff changeset
1007 (setq tail (cdr tail))))
a4e8d78ae3fb Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-574
Miles Bader <miles@gnu.org>
parents: 64754
diff changeset
1008 list))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1009
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1010 ;; Fixme: This is used in places when it should be testing the
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1011 ;; default multibyteness. See mm-default-multibyte-p.
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1012 (eval-and-compile
32976
aa9dc4e7c5ac 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 32414
diff changeset
1013 (if (and (not (featurep 'xemacs))
aa9dc4e7c5ac 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 32414
diff changeset
1014 (boundp 'enable-multibyte-characters))
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1015 (defun mm-multibyte-p ()
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1016 "Non-nil if multibyte is enabled in the current buffer."
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1017 enable-multibyte-characters)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1018 (defun mm-multibyte-p () (featurep 'mule))))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1019
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1020 (defun mm-default-multibyte-p ()
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1021 "Return non-nil if the session is multibyte.
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1022 This affects whether coding conversion should be attempted generally."
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1023 (if (featurep 'mule)
104830
79c2323377ac Use default-value rather than default-enable-multibyte-characters.
Glenn Morris <rgm@gnu.org>
parents: 104682
diff changeset
1024 (if (boundp 'enable-multibyte-characters)
79c2323377ac Use default-value rather than default-enable-multibyte-characters.
Glenn Morris <rgm@gnu.org>
parents: 104682
diff changeset
1025 (default-value 'enable-multibyte-characters)
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1026 t)))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1027
92153
37d6263f580b Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents: 91718
diff changeset
1028 (defun mm-iso-8859-x-to-15-region (&optional b e)
37d6263f580b Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents: 91718
diff changeset
1029 (if (fboundp 'char-charset)
37d6263f580b Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents: 91718
diff changeset
1030 (let (charset item c inconvertible)
37d6263f580b Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents: 91718
diff changeset
1031 (save-restriction
37d6263f580b Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents: 91718
diff changeset
1032 (if e (narrow-to-region b e))
37d6263f580b Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents: 91718
diff changeset
1033 (goto-char (point-min))
37d6263f580b Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents: 91718
diff changeset
1034 (skip-chars-forward "\0-\177")
37d6263f580b Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents: 91718
diff changeset
1035 (while (not (eobp))
37d6263f580b Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents: 91718
diff changeset
1036 (cond
37d6263f580b Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents: 91718
diff changeset
1037 ((not (setq item (assq (char-charset (setq c (char-after)))
37d6263f580b Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents: 91718
diff changeset
1038 mm-iso-8859-x-to-15-table)))
37d6263f580b Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents: 91718
diff changeset
1039 (forward-char))
37d6263f580b Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents: 91718
diff changeset
1040 ((memq c (cdr (cdr item)))
37d6263f580b Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents: 91718
diff changeset
1041 (setq inconvertible t)
37d6263f580b Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents: 91718
diff changeset
1042 (forward-char))
37d6263f580b Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents: 91718
diff changeset
1043 (t
37d6263f580b Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents: 91718
diff changeset
1044 (insert-before-markers (prog1 (+ c (car (cdr item)))
37d6263f580b Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents: 91718
diff changeset
1045 (delete-char 1)))))
37d6263f580b Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents: 91718
diff changeset
1046 (skip-chars-forward "\0-\177")))
37d6263f580b Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents: 91718
diff changeset
1047 (not inconvertible))))
37d6263f580b Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents: 91718
diff changeset
1048
41494
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
1049 (defun mm-sort-coding-systems-predicate (a b)
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1050 (let ((priorities
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1051 (mapcar (lambda (cs)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1052 ;; Note: invalid entries are dropped silently
57923
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
1053 (and (setq cs (mm-coding-system-p cs))
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1054 (coding-system-base cs)))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1055 mm-coding-system-priorities)))
57923
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
1056 (and (setq a (mm-coding-system-p a))
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
1057 (if (setq b (mm-coding-system-p b))
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
1058 (> (length (memq (coding-system-base a) priorities))
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
1059 (length (memq (coding-system-base b) priorities)))
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
1060 t))))
41494
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
1061
59089
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
1062 (eval-when-compile
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
1063 (autoload 'latin-unity-massage-name "latin-unity")
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
1064 (autoload 'latin-unity-maybe-remap "latin-unity")
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
1065 (autoload 'latin-unity-representations-feasible-region "latin-unity")
86154
1cdfc94602cb * smime.el (from):
Dan Nicolaescu <dann@ics.uci.edu>
parents: 85888
diff changeset
1066 (autoload 'latin-unity-representations-present-region "latin-unity"))
1cdfc94602cb * smime.el (from):
Dan Nicolaescu <dann@ics.uci.edu>
parents: 85888
diff changeset
1067
1cdfc94602cb * smime.el (from):
Dan Nicolaescu <dann@ics.uci.edu>
parents: 85888
diff changeset
1068 (defvar latin-unity-coding-systems)
1cdfc94602cb * smime.el (from):
Dan Nicolaescu <dann@ics.uci.edu>
parents: 85888
diff changeset
1069 (defvar latin-unity-ucs-list)
59089
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
1070
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
1071 (defun mm-xemacs-find-mime-charset-1 (begin end)
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
1072 "Determine which MIME charset to use to send region as message.
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
1073 This uses the XEmacs-specific latin-unity package to better handle the
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
1074 case where identical characters from diverse ISO-8859-? character sets
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
1075 can be encoded using a single one of the corresponding coding systems.
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
1076
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
1077 It treats `mm-coding-system-priorities' as the list of preferred
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
1078 coding systems; a useful example setting for this list in Western
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
1079 Europe would be '(iso-8859-1 iso-8859-15 utf-8), which would default
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
1080 to the very standard Latin 1 coding system, and only move to coding
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
1081 systems that are less supported as is necessary to encode the
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
1082 characters that exist in the buffer.
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
1083
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
1084 Latin Unity doesn't know about those non-ASCII Roman characters that
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
1085 are available in various East Asian character sets. As such, its
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
1086 behavior if you have a JIS 0212 LATIN SMALL LETTER A WITH ACUTE in a
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
1087 buffer and it can otherwise be encoded as Latin 1, won't be ideal.
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
1088 But this is very much a corner case, so don't worry about it."
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
1089 (let ((systems mm-coding-system-priorities) csets psets curset)
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
1090
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
1091 ;; Load the Latin Unity library, if available.
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
1092 (when (and (not (featurep 'latin-unity)) (locate-library "latin-unity"))
85712
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1093 (require 'latin-unity))
59089
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
1094
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
1095 ;; Now, can we use it?
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
1096 (if (featurep 'latin-unity)
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
1097 (progn
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
1098 (setq csets (latin-unity-representations-feasible-region begin end)
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
1099 psets (latin-unity-representations-present-region begin end))
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
1100
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
1101 (catch 'done
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
1102
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
1103 ;; Pass back the first coding system in the preferred list
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
1104 ;; that can encode the whole region.
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
1105 (dolist (curset systems)
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
1106 (setq curset (latin-unity-massage-name 'buffer-default curset))
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
1107
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
1108 ;; If the coding system is a universal coding system, then
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
1109 ;; it can certainly encode all the characters in the region.
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
1110 (if (memq curset latin-unity-ucs-list)
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
1111 (throw 'done (list curset)))
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
1112
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
1113 ;; If a coding system isn't universal, and isn't in
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
1114 ;; the list that latin unity knows about, we can't
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
1115 ;; decide whether to use it here. Leave that until later
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
1116 ;; in `mm-find-mime-charset-region' function, whence we
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
1117 ;; have been called.
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
1118 (unless (memq curset latin-unity-coding-systems)
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
1119 (throw 'done nil))
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
1120
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
1121 ;; Right, we know about this coding system, and it may
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
1122 ;; conceivably be able to encode all the characters in
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
1123 ;; the region.
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
1124 (if (latin-unity-maybe-remap begin end curset csets psets t)
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
1125 (throw 'done (list curset))))
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
1126
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
1127 ;; Can't encode using anything from the
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
1128 ;; `mm-coding-system-priorities' list.
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
1129 ;; Leave `mm-find-mime-charset' to do most of the work.
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
1130 nil))
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
1131
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
1132 ;; Right, latin unity isn't available; let `mm-find-charset-region'
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
1133 ;; take its default action, which equally applies to GNU Emacs.
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
1134 nil)))
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
1135
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
1136 (defmacro mm-xemacs-find-mime-charset (begin end)
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
1137 (when (featurep 'xemacs)
61126
c0aa521e0ca7 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-220
Miles Bader <miles@gnu.org>
parents: 60029
diff changeset
1138 `(and (featurep 'mule) (mm-xemacs-find-mime-charset-1 ,begin ,end))))
59089
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
1139
87241
4d24ed4358ae Add declare-function compatibility definition.
Glenn Morris <rgm@gnu.org>
parents: 86154
diff changeset
1140 (declare-function mm-delete-duplicates "mm-util" (list))
4d24ed4358ae Add declare-function compatibility definition.
Glenn Morris <rgm@gnu.org>
parents: 86154
diff changeset
1141
41494
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
1142 (defun mm-find-mime-charset-region (b e &optional hack-charsets)
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
1143 "Return the MIME charsets needed to encode the region between B and E.
42206
0f4506820432 Doc fix.
Pavel Janík <Pavel@Janik.cz>
parents: 41494
diff changeset
1144 nil means ASCII, a single-element list represents an appropriate MIME
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
1145 charset, and a longer list means no appropriate charset."
41494
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
1146 (let (charsets)
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
1147 ;; The return possibilities of this function are a mess...
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
1148 (or (and (mm-multibyte-p)
42500
9b68dff3d385 * mm-util.el (mm-use-find-coding-systems-region): New variable.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 42493
diff changeset
1149 mm-use-find-coding-systems-region
41494
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
1150 ;; Find the mime-charset of the most preferred coding
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
1151 ;; system that has one.
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
1152 (let ((systems (find-coding-systems-region b e)))
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
1153 (when mm-coding-system-priorities
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47949
diff changeset
1154 (setq systems
41494
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
1155 (sort systems 'mm-sort-coding-systems-predicate)))
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
1156 (setq systems (delq 'compound-text systems))
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
1157 (unless (equal systems '(undecided))
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
1158 (while systems
47949
33e1238070a2 (mm-mime-mule-charset-alist): Require when compiling.
Dave Love <fx@gnu.org>
parents: 44075
diff changeset
1159 (let* ((head (pop systems))
33e1238070a2 (mm-mime-mule-charset-alist): Require when compiling.
Dave Love <fx@gnu.org>
parents: 44075
diff changeset
1160 (cs (or (coding-system-get head :mime-charset)
33e1238070a2 (mm-mime-mule-charset-alist): Require when compiling.
Dave Love <fx@gnu.org>
parents: 44075
diff changeset
1161 (coding-system-get head 'mime-charset))))
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1162 ;; The mime-charset (`x-ctext') of
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1163 ;; `compound-text' is not in the IANA list. We
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1164 ;; shouldn't normally use anything here with a
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1165 ;; mime-charset having an `x-' prefix.
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1166 ;; Fixme: Allow this to be overridden, since
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1167 ;; there is existing use of x-ctext.
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1168 ;; Also people apparently need the coding system
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1169 ;; `iso-2022-jp-3' (which Mule-UCS defines with
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1170 ;; mime-charset, though it's not valid).
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1171 (if (and cs
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1172 (not (string-match "^[Xx]-" (symbol-name cs)))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1173 ;; UTF-16 of any variety is invalid for
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1174 ;; text parts and, unfortunately, has
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1175 ;; mime-charset defined both in Mule-UCS
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1176 ;; and versions of Emacs. (The name
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1177 ;; might be `mule-utf-16...' or
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1178 ;; `utf-16...'.)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1179 (not (string-match "utf-16" (symbol-name cs))))
41494
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
1180 (setq systems nil
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
1181 charsets (list cs))))))
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
1182 charsets))
59089
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
1183 ;; If we're XEmacs, and some coding system is appropriate,
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
1184 ;; mm-xemacs-find-mime-charset will return an appropriate list.
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
1185 ;; Otherwise, we'll get nil, and the next setq will get invoked.
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
1186 (setq charsets (mm-xemacs-find-mime-charset b e))
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
1187
90104
a01e7a9f1659 Revision: miles@gnu.org--gnu-2005/emacs--unicode--0--patch-14
Miles Bader <miles@gnu.org>
parents: 90070
diff changeset
1188 ;; Fixme: won't work for unibyte Emacs 23:
89076
17b36ecfa8a8 (mm-hack-charsets, mm-iso-8859-15-compatible)
Dave Love <fx@gnu.org>
parents: 88840
diff changeset
1189
59089
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
1190 ;; We're not multibyte, or a single coding system won't cover it.
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47949
diff changeset
1191 (setq charsets
41494
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
1192 (mm-delete-duplicates
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
1193 (mapcar 'mm-mime-charset
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
1194 (delq 'ascii
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
1195 (mm-find-charset-region b e))))))
92153
37d6263f580b Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents: 91718
diff changeset
1196 (if (and (> (length charsets) 1)
37d6263f580b Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents: 91718
diff changeset
1197 (memq 'iso-8859-15 charsets)
37d6263f580b Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents: 91718
diff changeset
1198 (memq 'iso-8859-15 hack-charsets)
37d6263f580b Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents: 91718
diff changeset
1199 (save-excursion (mm-iso-8859-x-to-15-region b e)))
37d6263f580b Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents: 91718
diff changeset
1200 (dolist (x mm-iso-8859-15-compatible)
37d6263f580b Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents: 91718
diff changeset
1201 (setq charsets (delq (car x) charsets))))
37d6263f580b Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents: 91718
diff changeset
1202 (if (and (memq 'iso-2022-jp-2 charsets)
37d6263f580b Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents: 91718
diff changeset
1203 (memq 'iso-2022-jp-2 hack-charsets))
37d6263f580b Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents: 91718
diff changeset
1204 (setq charsets (delq 'iso-2022-jp charsets)))
37d6263f580b Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents: 91718
diff changeset
1205 ;; Attempt to reduce the number of charsets if utf-8 is available.
37d6263f580b Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents: 91718
diff changeset
1206 (if (and (featurep 'xemacs)
37d6263f580b Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents: 91718
diff changeset
1207 (> (length charsets) 1)
37d6263f580b Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents: 91718
diff changeset
1208 (mm-coding-system-p 'utf-8))
37d6263f580b Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents: 91718
diff changeset
1209 (let ((mm-coding-system-priorities
37d6263f580b Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents: 91718
diff changeset
1210 (cons 'utf-8 mm-coding-system-priorities)))
37d6263f580b Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents: 91718
diff changeset
1211 (setq charsets
37d6263f580b Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents: 91718
diff changeset
1212 (mm-delete-duplicates
37d6263f580b Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents: 91718
diff changeset
1213 (mapcar 'mm-mime-charset
37d6263f580b Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents: 91718
diff changeset
1214 (delq 'ascii
37d6263f580b Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents: 91718
diff changeset
1215 (mm-find-charset-region b e)))))))
41494
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
1216 charsets))
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
1217
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1218 (defmacro mm-with-unibyte-buffer (&rest forms)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1219 "Create a temporary buffer, and evaluate FORMS there like `progn'.
33378
ab964e52e0ba Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
1220 Use unibyte mode for this."
93728
c963dc42db06 (mm-with-unibyte-buffer, mm-with-multibyte-buffer):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93106
diff changeset
1221 `(with-temp-buffer
c963dc42db06 (mm-with-unibyte-buffer, mm-with-multibyte-buffer):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93106
diff changeset
1222 (mm-disable-multibyte)
c963dc42db06 (mm-with-unibyte-buffer, mm-with-multibyte-buffer):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93106
diff changeset
1223 ,@forms))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1224 (put 'mm-with-unibyte-buffer 'lisp-indent-function 0)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1225 (put 'mm-with-unibyte-buffer 'edebug-form-spec '(body))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1226
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1227 (defmacro mm-with-multibyte-buffer (&rest forms)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1228 "Create a temporary buffer, and evaluate FORMS there like `progn'.
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1229 Use multibyte mode for this."
93728
c963dc42db06 (mm-with-unibyte-buffer, mm-with-multibyte-buffer):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93106
diff changeset
1230 `(with-temp-buffer
c963dc42db06 (mm-with-unibyte-buffer, mm-with-multibyte-buffer):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93106
diff changeset
1231 (mm-enable-multibyte)
c963dc42db06 (mm-with-unibyte-buffer, mm-with-multibyte-buffer):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93106
diff changeset
1232 ,@forms))
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1233 (put 'mm-with-multibyte-buffer 'lisp-indent-function 0)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1234 (put 'mm-with-multibyte-buffer 'edebug-form-spec '(body))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1235
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1236 (defmacro mm-with-unibyte-current-buffer (&rest forms)
47949
33e1238070a2 (mm-mime-mule-charset-alist): Require when compiling.
Dave Love <fx@gnu.org>
parents: 44075
diff changeset
1237 "Evaluate FORMS with current buffer temporarily made unibyte.
108391
5e0883e3a3b7 Synch with Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 108287
diff changeset
1238 Equivalent to `progn' in XEmacs.
69247
6580c61aced7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-134
Miles Bader <miles@gnu.org>
parents: 69135
diff changeset
1239
108391
5e0883e3a3b7 Synch with Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 108287
diff changeset
1240 Note: We recommend not using this macro any more; there should be
5e0883e3a3b7 Synch with Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 108287
diff changeset
1241 better ways to do a similar thing. The previous version of this macro
5e0883e3a3b7 Synch with Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 108287
diff changeset
1242 bound the default value of `enable-multibyte-characters' to nil while
5e0883e3a3b7 Synch with Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 108287
diff changeset
1243 evaluating FORMS but it is no longer done. So, some programs assuming
5e0883e3a3b7 Synch with Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 108287
diff changeset
1244 it if any may malfunction."
108287
c0d13767677a Synch with Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 108224
diff changeset
1245 (if (featurep 'xemacs)
c0d13767677a Synch with Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 108224
diff changeset
1246 `(progn ,@forms)
108391
5e0883e3a3b7 Synch with Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 108287
diff changeset
1247 (let ((multibyte (make-symbol "multibyte")))
5e0883e3a3b7 Synch with Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 108287
diff changeset
1248 `(let ((,multibyte enable-multibyte-characters))
5e0883e3a3b7 Synch with Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 108287
diff changeset
1249 (when ,multibyte
5e0883e3a3b7 Synch with Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 108287
diff changeset
1250 (set-buffer-multibyte nil))
5e0883e3a3b7 Synch with Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 108287
diff changeset
1251 (prog1
5e0883e3a3b7 Synch with Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 108287
diff changeset
1252 (progn ,@forms)
5e0883e3a3b7 Synch with Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 108287
diff changeset
1253 (when ,multibyte
5e0883e3a3b7 Synch with Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 108287
diff changeset
1254 (set-buffer-multibyte t)))))))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1255 (put 'mm-with-unibyte-current-buffer 'lisp-indent-function 0)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1256 (put 'mm-with-unibyte-current-buffer 'edebug-form-spec '(body))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1257
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1258 (defun mm-find-charset-region (b e)
33378
ab964e52e0ba Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
1259 "Return a list of Emacs charsets in the region B to E."
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1260 (cond
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1261 ((and (mm-multibyte-p)
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
1262 (fboundp 'find-charset-region))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1263 ;; Remove composition since the base charsets have been included.
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
1264 ;; Remove eight-bit-*, treat them as ascii.
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
1265 (let ((css (find-charset-region b e)))
85712
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1266 (dolist (cs
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1267 '(composition eight-bit-control eight-bit-graphic control-1)
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1268 css)
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1269 (setq css (delq cs css)))))
32976
aa9dc4e7c5ac 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 32414
diff changeset
1270 (t
aa9dc4e7c5ac 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 32414
diff changeset
1271 ;; We are in a unibyte buffer or XEmacs non-mule, so we futz around a bit.
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1272 (save-excursion
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1273 (save-restriction
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1274 (narrow-to-region b e)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1275 (goto-char (point-min))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1276 (skip-chars-forward "\0-\177")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1277 (if (eobp)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1278 '(ascii)
32976
aa9dc4e7c5ac 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 32414
diff changeset
1279 (let (charset)
aa9dc4e7c5ac 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 32414
diff changeset
1280 (setq charset
aa9dc4e7c5ac 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 32414
diff changeset
1281 (and (boundp 'current-language-environment)
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
1282 (car (last (assq 'charset
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
1283 (assoc current-language-environment
32976
aa9dc4e7c5ac 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 32414
diff changeset
1284 language-info-alist))))))
aa9dc4e7c5ac 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 32414
diff changeset
1285 (if (eq charset 'ascii) (setq charset nil))
aa9dc4e7c5ac 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 32414
diff changeset
1286 (or charset
aa9dc4e7c5ac 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 32414
diff changeset
1287 (setq charset
aa9dc4e7c5ac 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 32414
diff changeset
1288 (car (last (assq mail-parse-charset
aa9dc4e7c5ac 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 32414
diff changeset
1289 mm-mime-mule-charset-alist)))))
aa9dc4e7c5ac 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 32414
diff changeset
1290 (list 'ascii (or charset 'latin-iso8859-1)))))))))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1291
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1292 (defun mm-auto-mode-alist ()
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1293 "Return an `auto-mode-alist' with only the .gz (etc) thingies."
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1294 (let ((alist auto-mode-alist)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1295 out)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1296 (while alist
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1297 (when (listp (cdar alist))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1298 (push (car alist) out))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1299 (pop alist))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1300 (nreverse out)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1301
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1302 (defvar mm-inhibit-file-name-handlers
85712
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1303 '(jka-compr-handler image-file-handler epa-file-handler)
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1304 "A list of handlers doing (un)compression (etc) thingies.")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1305
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1306 (defun mm-insert-file-contents (filename &optional visit beg end replace
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1307 inhibit)
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1308 "Like `insert-file-contents', but only reads in the file.
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1309 A buffer may be modified in several ways after reading into the buffer due
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1310 to advanced Emacs features, such as file-name-handlers, format decoding,
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1311 `find-file-hooks', etc.
47949
33e1238070a2 (mm-mime-mule-charset-alist): Require when compiling.
Dave Love <fx@gnu.org>
parents: 44075
diff changeset
1312 If INHIBIT is non-nil, inhibit `mm-inhibit-file-name-handlers'.
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1313 This function ensures that none of these modifications will take place."
104682
73bff1db57b6 * gnus/nnheader.el (nnheader-find-file-noselect):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 101165
diff changeset
1314 (letf* ((format-alist nil)
73bff1db57b6 * gnus/nnheader.el (nnheader-find-file-noselect):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 101165
diff changeset
1315 (auto-mode-alist (if inhibit nil (mm-auto-mode-alist)))
73bff1db57b6 * gnus/nnheader.el (nnheader-find-file-noselect):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 101165
diff changeset
1316 ((default-value 'major-mode) 'fundamental-mode)
73bff1db57b6 * gnus/nnheader.el (nnheader-find-file-noselect):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 101165
diff changeset
1317 (enable-local-variables nil)
73bff1db57b6 * gnus/nnheader.el (nnheader-find-file-noselect):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 101165
diff changeset
1318 (after-insert-file-functions nil)
73bff1db57b6 * gnus/nnheader.el (nnheader-find-file-noselect):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 101165
diff changeset
1319 (enable-local-eval nil)
73bff1db57b6 * gnus/nnheader.el (nnheader-find-file-noselect):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 101165
diff changeset
1320 (inhibit-file-name-operation (if inhibit
73bff1db57b6 * gnus/nnheader.el (nnheader-find-file-noselect):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 101165
diff changeset
1321 'insert-file-contents
73bff1db57b6 * gnus/nnheader.el (nnheader-find-file-noselect):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 101165
diff changeset
1322 inhibit-file-name-operation))
73bff1db57b6 * gnus/nnheader.el (nnheader-find-file-noselect):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 101165
diff changeset
1323 (inhibit-file-name-handlers
73bff1db57b6 * gnus/nnheader.el (nnheader-find-file-noselect):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 101165
diff changeset
1324 (if inhibit
73bff1db57b6 * gnus/nnheader.el (nnheader-find-file-noselect):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 101165
diff changeset
1325 (append mm-inhibit-file-name-handlers
73bff1db57b6 * gnus/nnheader.el (nnheader-find-file-noselect):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 101165
diff changeset
1326 inhibit-file-name-handlers)
73bff1db57b6 * gnus/nnheader.el (nnheader-find-file-noselect):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 101165
diff changeset
1327 inhibit-file-name-handlers))
73bff1db57b6 * gnus/nnheader.el (nnheader-find-file-noselect):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 101165
diff changeset
1328 (ffh (if (boundp 'find-file-hook)
73bff1db57b6 * gnus/nnheader.el (nnheader-find-file-noselect):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 101165
diff changeset
1329 'find-file-hook
73bff1db57b6 * gnus/nnheader.el (nnheader-find-file-noselect):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 101165
diff changeset
1330 'find-file-hooks))
73bff1db57b6 * gnus/nnheader.el (nnheader-find-file-noselect):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 101165
diff changeset
1331 (val (symbol-value ffh)))
62943
11d53dd5abd9 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-345
Miles Bader <miles@gnu.org>
parents: 61519
diff changeset
1332 (set ffh nil)
11d53dd5abd9 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-345
Miles Bader <miles@gnu.org>
parents: 61519
diff changeset
1333 (unwind-protect
11d53dd5abd9 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-345
Miles Bader <miles@gnu.org>
parents: 61519
diff changeset
1334 (insert-file-contents filename visit beg end replace)
11d53dd5abd9 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-345
Miles Bader <miles@gnu.org>
parents: 61519
diff changeset
1335 (set ffh val))))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1336
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1337 (defun mm-append-to-file (start end filename &optional codesys inhibit)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1338 "Append the contents of the region to the end of file FILENAME.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1339 When called from a function, expects three arguments,
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1340 START, END and FILENAME. START and END are buffer positions
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1341 saying what text to write.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1342 Optional fourth argument specifies the coding system to use when
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1343 encoding the file.
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1344 If INHIBIT is non-nil, inhibit `mm-inhibit-file-name-handlers'."
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
1345 (let ((coding-system-for-write
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
1346 (or codesys mm-text-coding-system-for-write
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1347 mm-text-coding-system))
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
1348 (inhibit-file-name-operation (if inhibit
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1349 'append-to-file
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1350 inhibit-file-name-operation))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1351 (inhibit-file-name-handlers
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1352 (if inhibit
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
1353 (append mm-inhibit-file-name-handlers
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1354 inhibit-file-name-handlers)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1355 inhibit-file-name-handlers)))
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1356 (write-region start end filename t 'no-message)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1357 (message "Appended to %s" filename)))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1358
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
1359 (defun mm-write-region (start end filename &optional append visit lockname
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1360 coding-system inhibit)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1361
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1362 "Like `write-region'.
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1363 If INHIBIT is non-nil, inhibit `mm-inhibit-file-name-handlers'."
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
1364 (let ((coding-system-for-write
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
1365 (or coding-system mm-text-coding-system-for-write
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1366 mm-text-coding-system))
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
1367 (inhibit-file-name-operation (if inhibit
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1368 'write-region
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1369 inhibit-file-name-operation))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1370 (inhibit-file-name-handlers
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1371 (if inhibit
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
1372 (append mm-inhibit-file-name-handlers
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1373 inhibit-file-name-handlers)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1374 inhibit-file-name-handlers)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1375 (write-region start end filename append visit lockname)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1376
87241
4d24ed4358ae Add declare-function compatibility definition.
Glenn Morris <rgm@gnu.org>
parents: 86154
diff changeset
1377 (autoload 'gmm-write-region "gmm-utils")
4d24ed4358ae Add declare-function compatibility definition.
Glenn Morris <rgm@gnu.org>
parents: 86154
diff changeset
1378
68940
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1379 ;; It is not a MIME function, but some MIME functions use it.
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1380 (if (and (fboundp 'make-temp-file)
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1381 (ignore-errors
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1382 (let ((def (symbol-function 'make-temp-file)))
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1383 (and (byte-code-function-p def)
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1384 (setq def (if (fboundp 'compiled-function-arglist)
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1385 ;; XEmacs
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1386 (eval (list 'compiled-function-arglist def))
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1387 (aref def 0)))
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1388 (>= (length def) 4)
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1389 (eq (nth 3 def) 'suffix)))))
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1390 (defalias 'mm-make-temp-file 'make-temp-file)
85712
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1391 ;; Stolen (and modified for XEmacs) from Emacs 22.
68940
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1392 (defun mm-make-temp-file (prefix &optional dir-flag suffix)
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1393 "Create a temporary file.
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1394 The returned file name (created by appending some random characters at the end
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1395 of PREFIX, and expanding against `temporary-file-directory' if necessary),
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1396 is guaranteed to point to a newly created empty file.
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1397 You can then use `write-region' to write new data into the file.
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1398
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1399 If DIR-FLAG is non-nil, create a new empty directory instead of a file.
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1400
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1401 If SUFFIX is non-nil, add that at the end of the file name."
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1402 (let ((umask (default-file-modes))
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1403 file)
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1404 (unwind-protect
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1405 (progn
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1406 ;; Create temp files with strict access rights. It's easy to
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1407 ;; loosen them later, whereas it's impossible to close the
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1408 ;; time-window of loose permissions otherwise.
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1409 (set-default-file-modes 448)
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1410 (while (condition-case err
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1411 (progn
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1412 (setq file
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1413 (make-temp-name
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1414 (expand-file-name
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1415 prefix
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1416 (if (fboundp 'temp-directory)
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1417 ;; XEmacs
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1418 (temp-directory)
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1419 temporary-file-directory))))
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1420 (if suffix
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1421 (setq file (concat file suffix)))
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1422 (if dir-flag
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1423 (make-directory file)
73370
7d511b8dc9c6 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73224
diff changeset
1424 ;; NOTE: This is unsafe if Emacs 20
7d511b8dc9c6 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73224
diff changeset
1425 ;; users and XEmacs users don't use
7d511b8dc9c6 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73224
diff changeset
1426 ;; a secure temp directory.
7d511b8dc9c6 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73224
diff changeset
1427 (gmm-write-region "" nil file nil 'silent
7d511b8dc9c6 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73224
diff changeset
1428 nil 'excl))
68940
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1429 nil)
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1430 (file-already-exists t)
85712
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1431 ;; The XEmacs version of `make-directory' issues
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1432 ;; `file-error'.
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1433 (file-error (or (and (featurep 'xemacs)
68940
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1434 (file-exists-p file))
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1435 (signal (car err) (cdr err)))))
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1436 ;; the file was somehow created by someone else between
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1437 ;; `make-temp-name' and `write-region', let's try again.
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1438 nil)
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1439 file)
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1440 ;; Reset the umask.
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1441 (set-default-file-modes umask)))))
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1442
110171
a05bc4ad2d3f mm-util.el: Just return the image directories, not all directories in the path in addition to the image directories; Maintain a cache of the image directories. This means that the `g' command in Gnus doesn't have to stat dozens of directories each time; nnmh.el: Only recurse down into subdirectories if the link count is more than 2. This results in a 100x speed up on my nnmh spool, and that's from an SSD disk, and not over nfs.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110102
diff changeset
1443 (defvar mm-image-load-path-cache nil)
a05bc4ad2d3f mm-util.el: Just return the image directories, not all directories in the path in addition to the image directories; Maintain a cache of the image directories. This means that the `g' command in Gnus doesn't have to stat dozens of directories each time; nnmh.el: Only recurse down into subdirectories if the link count is more than 2. This results in a 100x speed up on my nnmh spool, and that's from an SSD disk, and not over nfs.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110102
diff changeset
1444
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
1445 (defun mm-image-load-path (&optional package)
110171
a05bc4ad2d3f mm-util.el: Just return the image directories, not all directories in the path in addition to the image directories; Maintain a cache of the image directories. This means that the `g' command in Gnus doesn't have to stat dozens of directories each time; nnmh.el: Only recurse down into subdirectories if the link count is more than 2. This results in a 100x speed up on my nnmh spool, and that's from an SSD disk, and not over nfs.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110102
diff changeset
1446 (if (and mm-image-load-path-cache
a05bc4ad2d3f mm-util.el: Just return the image directories, not all directories in the path in addition to the image directories; Maintain a cache of the image directories. This means that the `g' command in Gnus doesn't have to stat dozens of directories each time; nnmh.el: Only recurse down into subdirectories if the link count is more than 2. This results in a 100x speed up on my nnmh spool, and that's from an SSD disk, and not over nfs.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110102
diff changeset
1447 (equal load-path (car mm-image-load-path-cache)))
a05bc4ad2d3f mm-util.el: Just return the image directories, not all directories in the path in addition to the image directories; Maintain a cache of the image directories. This means that the `g' command in Gnus doesn't have to stat dozens of directories each time; nnmh.el: Only recurse down into subdirectories if the link count is more than 2. This results in a 100x speed up on my nnmh spool, and that's from an SSD disk, and not over nfs.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110102
diff changeset
1448 (cdr mm-image-load-path-cache)
a05bc4ad2d3f mm-util.el: Just return the image directories, not all directories in the path in addition to the image directories; Maintain a cache of the image directories. This means that the `g' command in Gnus doesn't have to stat dozens of directories each time; nnmh.el: Only recurse down into subdirectories if the link count is more than 2. This results in a 100x speed up on my nnmh spool, and that's from an SSD disk, and not over nfs.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110102
diff changeset
1449 (let (dir result)
a05bc4ad2d3f mm-util.el: Just return the image directories, not all directories in the path in addition to the image directories; Maintain a cache of the image directories. This means that the `g' command in Gnus doesn't have to stat dozens of directories each time; nnmh.el: Only recurse down into subdirectories if the link count is more than 2. This results in a 100x speed up on my nnmh spool, and that's from an SSD disk, and not over nfs.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110102
diff changeset
1450 (dolist (path load-path)
a05bc4ad2d3f mm-util.el: Just return the image directories, not all directories in the path in addition to the image directories; Maintain a cache of the image directories. This means that the `g' command in Gnus doesn't have to stat dozens of directories each time; nnmh.el: Only recurse down into subdirectories if the link count is more than 2. This results in a 100x speed up on my nnmh spool, and that's from an SSD disk, and not over nfs.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110102
diff changeset
1451 (when (and path
a05bc4ad2d3f mm-util.el: Just return the image directories, not all directories in the path in addition to the image directories; Maintain a cache of the image directories. This means that the `g' command in Gnus doesn't have to stat dozens of directories each time; nnmh.el: Only recurse down into subdirectories if the link count is more than 2. This results in a 100x speed up on my nnmh spool, and that's from an SSD disk, and not over nfs.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110102
diff changeset
1452 (file-directory-p
a05bc4ad2d3f mm-util.el: Just return the image directories, not all directories in the path in addition to the image directories; Maintain a cache of the image directories. This means that the `g' command in Gnus doesn't have to stat dozens of directories each time; nnmh.el: Only recurse down into subdirectories if the link count is more than 2. This results in a 100x speed up on my nnmh spool, and that's from an SSD disk, and not over nfs.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110102
diff changeset
1453 (setq dir (concat (file-name-directory
a05bc4ad2d3f mm-util.el: Just return the image directories, not all directories in the path in addition to the image directories; Maintain a cache of the image directories. This means that the `g' command in Gnus doesn't have to stat dozens of directories each time; nnmh.el: Only recurse down into subdirectories if the link count is more than 2. This results in a 100x speed up on my nnmh spool, and that's from an SSD disk, and not over nfs.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110102
diff changeset
1454 (directory-file-name path))
a05bc4ad2d3f mm-util.el: Just return the image directories, not all directories in the path in addition to the image directories; Maintain a cache of the image directories. This means that the `g' command in Gnus doesn't have to stat dozens of directories each time; nnmh.el: Only recurse down into subdirectories if the link count is more than 2. This results in a 100x speed up on my nnmh spool, and that's from an SSD disk, and not over nfs.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110102
diff changeset
1455 "etc/images/" (or package "gnus/")))))
a05bc4ad2d3f mm-util.el: Just return the image directories, not all directories in the path in addition to the image directories; Maintain a cache of the image directories. This means that the `g' command in Gnus doesn't have to stat dozens of directories each time; nnmh.el: Only recurse down into subdirectories if the link count is more than 2. This results in a 100x speed up on my nnmh spool, and that's from an SSD disk, and not over nfs.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110102
diff changeset
1456 (push dir result)))
a05bc4ad2d3f mm-util.el: Just return the image directories, not all directories in the path in addition to the image directories; Maintain a cache of the image directories. This means that the `g' command in Gnus doesn't have to stat dozens of directories each time; nnmh.el: Only recurse down into subdirectories if the link count is more than 2. This results in a 100x speed up on my nnmh spool, and that's from an SSD disk, and not over nfs.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110102
diff changeset
1457 (setq result (nreverse result)
a05bc4ad2d3f mm-util.el: Just return the image directories, not all directories in the path in addition to the image directories; Maintain a cache of the image directories. This means that the `g' command in Gnus doesn't have to stat dozens of directories each time; nnmh.el: Only recurse down into subdirectories if the link count is more than 2. This results in a 100x speed up on my nnmh spool, and that's from an SSD disk, and not over nfs.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110102
diff changeset
1458 mm-image-load-path-cache (cons load-path result))
a05bc4ad2d3f mm-util.el: Just return the image directories, not all directories in the path in addition to the image directories; Maintain a cache of the image directories. This means that the `g' command in Gnus doesn't have to stat dozens of directories each time; nnmh.el: Only recurse down into subdirectories if the link count is more than 2. This results in a 100x speed up on my nnmh spool, and that's from an SSD disk, and not over nfs.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110102
diff changeset
1459 result)))
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
1460
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1461 ;; Fixme: This doesn't look useful where it's used.
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1462 (if (fboundp 'detect-coding-region)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1463 (defun mm-detect-coding-region (start end)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1464 "Like `detect-coding-region' except returning the best one."
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1465 (let ((coding-systems
61434
6d07c19816b9 (mm-string-to-multibyte): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61424
diff changeset
1466 (detect-coding-region start end)))
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1467 (or (car-safe coding-systems)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1468 coding-systems)))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1469 (defun mm-detect-coding-region (start end)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1470 (let ((point (point)))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1471 (goto-char start)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1472 (skip-chars-forward "\0-\177" end)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1473 (prog1
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1474 (if (eq (point) end) 'ascii (mm-guess-charset))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1475 (goto-char point)))))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1476
87241
4d24ed4358ae Add declare-function compatibility definition.
Glenn Morris <rgm@gnu.org>
parents: 86154
diff changeset
1477 (declare-function mm-detect-coding-region "mm-util" (start end))
4d24ed4358ae Add declare-function compatibility definition.
Glenn Morris <rgm@gnu.org>
parents: 86154
diff changeset
1478
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1479 (if (fboundp 'coding-system-get)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1480 (defun mm-detect-mime-charset-region (start end)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1481 "Detect MIME charset of the text in the region between START and END."
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1482 (let ((cs (mm-detect-coding-region start end)))
70052
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
1483 (or (coding-system-get cs :mime-charset)
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
1484 (coding-system-get cs 'mime-charset))))
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1485 (defun mm-detect-mime-charset-region (start end)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1486 "Detect MIME charset of the text in the region between START and END."
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1487 (let ((cs (mm-detect-coding-region start end)))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1488 cs)))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1489
85712
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1490 (eval-when-compile
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1491 (unless (fboundp 'coding-system-to-mime-charset)
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1492 (defalias 'coding-system-to-mime-charset 'ignore)))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1493
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1494 (defun mm-coding-system-to-mime-charset (coding-system)
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1495 "Return the MIME charset corresponding to CODING-SYSTEM.
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1496 To make this function work with XEmacs, the APEL package is required."
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1497 (when coding-system
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1498 (or (and (fboundp 'coding-system-get)
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1499 (or (coding-system-get coding-system :mime-charset)
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1500 (coding-system-get coding-system 'mime-charset)))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1501 (and (featurep 'xemacs)
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1502 (or (and (fboundp 'coding-system-to-mime-charset)
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1503 (not (eq (symbol-function 'coding-system-to-mime-charset)
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1504 'ignore)))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1505 (and (condition-case nil
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1506 (require 'mcharset)
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1507 (error nil))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1508 (fboundp 'coding-system-to-mime-charset)))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1509 (coding-system-to-mime-charset coding-system)))))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1510
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1511 (eval-when-compile
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1512 (require 'jka-compr))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1513
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1514 (defun mm-decompress-buffer (filename &optional inplace force)
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1515 "Decompress buffer's contents, depending on jka-compr.
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1516 Only when FORCE is t or `auto-compression-mode' is enabled and FILENAME
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1517 agrees with `jka-compr-compression-info-list', decompression is done.
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1518 Signal an error if FORCE is neither nil nor t and compressed data are
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1519 not decompressed because `auto-compression-mode' is disabled.
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1520 If INPLACE is nil, return decompressed data or nil without modifying
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1521 the buffer. Otherwise, replace the buffer's contents with the
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1522 decompressed data. The buffer's multibyteness must be turned off."
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1523 (when (and filename
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1524 (if force
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1525 (prog1 t (require 'jka-compr))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1526 (and (fboundp 'jka-compr-installed-p)
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1527 (jka-compr-installed-p))))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1528 (let ((info (jka-compr-get-compression-info filename)))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1529 (when info
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1530 (unless (or (memq force (list nil t))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1531 (jka-compr-installed-p))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1532 (error ""))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1533 (let ((prog (jka-compr-info-uncompress-program info))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1534 (args (jka-compr-info-uncompress-args info))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1535 (msg (format "%s %s..."
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1536 (jka-compr-info-uncompress-message info)
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1537 filename))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1538 (err-file (jka-compr-make-temp-name))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1539 (cur (current-buffer))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1540 (coding-system-for-read mm-binary-coding-system)
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1541 (coding-system-for-write mm-binary-coding-system)
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1542 retval err-msg)
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1543 (message "%s" msg)
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1544 (mm-with-unibyte-buffer
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1545 (insert-buffer-substring cur)
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1546 (condition-case err
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1547 (progn
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1548 (unless (memq (apply 'call-process-region
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1549 (point-min) (point-max)
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1550 prog t (list t err-file) nil args)
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1551 jka-compr-acceptable-retval-list)
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1552 (erase-buffer)
110475
ab3a38ccb842 Remove Emacs 21 stuff.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110171
diff changeset
1553 (insert (mapconcat 'identity
ab3a38ccb842 Remove Emacs 21 stuff.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110171
diff changeset
1554 (split-string
ab3a38ccb842 Remove Emacs 21 stuff.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110171
diff changeset
1555 (prog2
ab3a38ccb842 Remove Emacs 21 stuff.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110171
diff changeset
1556 (insert-file-contents err-file)
ab3a38ccb842 Remove Emacs 21 stuff.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110171
diff changeset
1557 (buffer-string)
ab3a38ccb842 Remove Emacs 21 stuff.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110171
diff changeset
1558 (erase-buffer)) t)
ab3a38ccb842 Remove Emacs 21 stuff.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110171
diff changeset
1559 " ")
85712
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1560 "\n")
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1561 (setq err-msg
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1562 (format "Error while executing \"%s %s < %s\""
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1563 prog (mapconcat 'identity args " ")
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1564 filename)))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1565 (setq retval (buffer-string)))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1566 (error
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1567 (setq err-msg (error-message-string err)))))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1568 (when (file-exists-p err-file)
108224
8251ba69ff20 * mm-util.el (mm-decompress-buffer): Use `delete-file'.
Juanma Barranquero <lekktu@gmail.com>
parents: 108084
diff changeset
1569 (ignore-errors (delete-file err-file)))
85712
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1570 (when inplace
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1571 (unless err-msg
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1572 (delete-region (point-min) (point-max))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1573 (insert retval))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1574 (setq retval nil))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1575 (message "%s" (or err-msg (concat msg "done")))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1576 retval)))))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1577
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1578 (eval-when-compile
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1579 (unless (fboundp 'coding-system-name)
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1580 (defalias 'coding-system-name 'ignore))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1581 (unless (fboundp 'find-file-coding-system-for-read-from-filename)
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1582 (defalias 'find-file-coding-system-for-read-from-filename 'ignore))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1583 (unless (fboundp 'find-operation-coding-system)
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1584 (defalias 'find-operation-coding-system 'ignore)))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1585
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1586 (defun mm-find-buffer-file-coding-system (&optional filename)
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1587 "Find coding system used to decode the contents of the current buffer.
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1588 This function looks for the coding system magic cookie or examines the
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1589 coding system specified by `file-coding-system-alist' being associated
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1590 with FILENAME which defaults to `buffer-file-name'. Data compressed by
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1591 gzip, bzip2, etc. are allowed."
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1592 (unless filename
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1593 (setq filename buffer-file-name))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1594 (save-excursion
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1595 (let ((decomp (unless ;; No worth to examine charset of tar files.
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1596 (and filename
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1597 (string-match
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1598 "\\.\\(?:tar\\.[^.]+\\|tbz\\|tgz\\)\\'"
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1599 filename))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1600 (mm-decompress-buffer filename nil t))))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1601 (when decomp
108084
7ffbe3a6a8f2 * mm-util.el (mm-find-buffer-file-coding-system):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107393
diff changeset
1602 (set-buffer (generate-new-buffer " *temp*"))
7ffbe3a6a8f2 * mm-util.el (mm-find-buffer-file-coding-system):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107393
diff changeset
1603 (mm-disable-multibyte)
85712
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1604 (insert decomp)
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1605 (setq filename (file-name-sans-extension filename)))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1606 (goto-char (point-min))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1607 (prog1
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1608 (cond
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1609 ((boundp 'set-auto-coding-function) ;; Emacs
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1610 (if filename
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1611 (or (funcall (symbol-value 'set-auto-coding-function)
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1612 filename (- (point-max) (point-min)))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1613 (car (find-operation-coding-system 'insert-file-contents
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1614 filename)))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1615 (let (auto-coding-alist)
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1616 (condition-case nil
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1617 (funcall (symbol-value 'set-auto-coding-function)
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1618 nil (- (point-max) (point-min)))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1619 (error nil)))))
86154
1cdfc94602cb * smime.el (from):
Dan Nicolaescu <dann@ics.uci.edu>
parents: 85888
diff changeset
1620 ((and (featurep 'xemacs) (featurep 'file-coding)) ;; XEmacs
85712
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1621 (let ((case-fold-search t)
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1622 (end (point-at-eol))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1623 codesys start)
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1624 (or
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1625 (and (re-search-forward "-\\*-+[\t ]*" end t)
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1626 (progn
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1627 (setq start (match-end 0))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1628 (re-search-forward "[\t ]*-+\\*-" end t))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1629 (progn
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1630 (setq end (match-beginning 0))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1631 (goto-char start)
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1632 (or (looking-at "coding:[\t ]*\\([^\t ;]+\\)")
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1633 (re-search-forward
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1634 "[\t ;]+coding:[\t ]*\\([^\t ;]+\\)"
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1635 end t)))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1636 (find-coding-system (setq codesys
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1637 (intern (match-string 1))))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1638 codesys)
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1639 (and (re-search-forward "^[\t ]*;+[\t ]*Local[\t ]+Variables:"
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1640 nil t)
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1641 (progn
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1642 (setq start (match-end 0))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1643 (re-search-forward "^[\t ]*;+[\t ]*End:" nil t))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1644 (progn
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1645 (setq end (match-beginning 0))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1646 (goto-char start)
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1647 (re-search-forward
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1648 "^[\t ]*;+[\t ]*coding:[\t ]*\\([^\t\n\r ]+\\)"
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1649 end t))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1650 (find-coding-system (setq codesys
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1651 (intern (match-string 1))))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1652 codesys)
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1653 (and (progn
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1654 (goto-char (point-min))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1655 (setq case-fold-search nil)
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1656 (re-search-forward "^;;;coding system: "
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1657 ;;(+ (point-min) 3000) t))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1658 nil t))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1659 (looking-at "[^\t\n\r ]+")
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1660 (find-coding-system
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1661 (setq codesys (intern (match-string 0))))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1662 codesys)
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1663 (and filename
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1664 (setq codesys
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1665 (find-file-coding-system-for-read-from-filename
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1666 filename))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1667 (coding-system-name (coding-system-base codesys)))))))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1668 (when decomp
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 79022
diff changeset
1669 (kill-buffer (current-buffer)))))))
44075
7782e54757bb * mail-source.el (make-source-make-complex-temp-name): Use
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 42500
diff changeset
1670
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1671 (provide 'mm-util)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1672
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1673 ;;; mm-util.el ends here