Mercurial > emacs
annotate lisp/gnus/mm-util.el @ 99187:f552fe2942ff
*** empty log message ***
author | Martin Rudalics <rudalics@gmx.at> |
---|---|
date | Tue, 28 Oct 2008 17:36:34 +0000 |
parents | 512497325cb3 |
children | da90832da238 |
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 |
fafd692d1e40
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64736
diff
changeset
|
3 ;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, |
79708 | 4 ;; 2005, 2006, 2007, 2008 Free Software Foundation, Inc. |
31717 | 5 |
6 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org> | |
7 ;; MORIOKA Tomohiko <morioka@jaist.ac.jp> | |
8 ;; This file is part of GNU Emacs. | |
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 | 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 | 14 |
15 ;; GNU Emacs is distributed in the hope that it will be useful, | |
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 | 18 ;; GNU General Public License for more details. |
19 | |
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 | 22 |
23 ;;; Commentary: | |
24 | |
25 ;;; Code: | |
26 | |
87241
4d24ed4358ae
Add declare-function compatibility definition.
Glenn Morris <rgm@gnu.org>
parents:
86154
diff
changeset
|
27 ;; For Emacs < 22.2. |
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 | 32 (require 'mail-prsvr) |
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 | 41 (defvar mm-mime-mule-charset-alist ) |
42 | |
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
43 (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
|
44 (mapc |
40542
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
45 (lambda (elem) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
46 (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
|
47 (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
|
48 (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
|
49 (defalias nfunc (cdr elem))))) |
78125 | 50 '((coding-system-list . ignore) |
40542
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
51 (char-int . identity) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
52 (coding-system-equal . equal) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
53 (annotationp . ignore) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
54 (set-buffer-file-coding-system . ignore) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
55 (read-charset |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
56 . (lambda (prompt) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
57 "Return a charset." |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
58 (intern |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
59 (completing-read |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
60 prompt |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
61 (mapcar (lambda (e) (list (symbol-name (car e)))) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
62 mm-mime-mule-charset-alist) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
63 nil t)))) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
64 (subst-char-in-string |
61424
ad05d91d3598
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-243
Miles Bader <miles@gnu.org>
parents:
61126
diff
changeset
|
65 . (lambda (from to string &optional inplace) |
ad05d91d3598
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-243
Miles Bader <miles@gnu.org>
parents:
61126
diff
changeset
|
66 ;; stolen (and renamed) from nnheader.el |
ad05d91d3598
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-243
Miles Bader <miles@gnu.org>
parents:
61126
diff
changeset
|
67 "Replace characters in STRING from FROM to TO. |
ad05d91d3598
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-243
Miles Bader <miles@gnu.org>
parents:
61126
diff
changeset
|
68 Unless optional argument INPLACE is non-nil, return a new string." |
ad05d91d3598
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-243
Miles Bader <miles@gnu.org>
parents:
61126
diff
changeset
|
69 (let ((string (if inplace string (copy-sequence string))) |
40542
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
70 (len (length string)) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
71 (idx 0)) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
72 ;; Replace all occurrences of FROM with TO. |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
73 (while (< idx len) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
74 (when (= (aref string idx) from) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
75 (aset string idx to)) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
76 (setq idx (1+ idx))) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
77 string))) |
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
78 (replace-in-string |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
79 . (lambda (string regexp rep &optional literal) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
80 "See `replace-regexp-in-string', only the order of args differs." |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
81 (replace-regexp-in-string regexp rep string nil literal))) |
40542
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
82 (string-as-unibyte . identity) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
53617
diff
changeset
|
83 (string-make-unibyte . identity) |
61434
6d07c19816b9
(mm-string-to-multibyte): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
61424
diff
changeset
|
84 ;; 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
|
85 ;; Example: |
6d07c19816b9
(mm-string-to-multibyte): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
61424
diff
changeset
|
86 ;; (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
|
87 ;; (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
|
88 ;; (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
|
89 ;; (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
|
90 ;; but |
6d07c19816b9
(mm-string-to-multibyte): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
61424
diff
changeset
|
91 ;; (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
|
92 ;; (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
|
93 ;; 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
|
94 ;; 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
|
95 ;; 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
|
96 ;; 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
|
97 ;; generally a problem in itself. |
6d07c19816b9
(mm-string-to-multibyte): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
61424
diff
changeset
|
98 ;; 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
|
99 ;; (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
|
100 ;; (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
|
101 ;; (string-make-multibyte s) ~= (decode-coding-string s locale-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
|
102 (string-as-multibyte . identity) |
47949
33e1238070a2
(mm-mime-mule-charset-alist): Require when compiling.
Dave Love <fx@gnu.org>
parents:
44075
diff
changeset
|
103 (multibyte-string-p . ignore) |
33e1238070a2
(mm-mime-mule-charset-alist): Require when compiling.
Dave Love <fx@gnu.org>
parents:
44075
diff
changeset
|
104 (insert-byte . insert-char) |
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
105 (multibyte-char-to-unibyte . identity) |
93106
e931cb410f95
(mm-set-buffer-multibyte): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92153
diff
changeset
|
106 (set-buffer-multibyte . ignore) |
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
107 (special-display-p |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
108 . (lambda (buffer-name) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
109 "Returns non-nil if a buffer named BUFFER-NAME gets a special frame." |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
110 (and special-display-function |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
111 (or (and (member buffer-name special-display-buffer-names) t) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
112 (cdr (assoc buffer-name special-display-buffer-names)) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
113 (catch 'return |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
114 (dolist (elem special-display-regexps) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
115 (and (stringp elem) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
116 (string-match elem buffer-name) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
117 (throw 'return t)) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
118 (and (consp elem) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
119 (stringp (car elem)) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
120 (string-match (car elem) buffer-name) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
121 (throw 'return (cdr elem)))))))))))) |
40542
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
122 |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
123 (eval-and-compile |
78125 | 124 (if (featurep 'xemacs) |
125 (if (featurep 'file-coding) | |
126 ;; Don't modify string if CODING-SYSTEM is nil. | |
127 (progn | |
128 (defun mm-decode-coding-string (str coding-system) | |
129 (if coding-system | |
130 (decode-coding-string str coding-system) | |
131 str)) | |
132 (defun mm-encode-coding-string (str coding-system) | |
133 (if coding-system | |
134 (encode-coding-string str coding-system) | |
135 str)) | |
136 (defun mm-decode-coding-region (start end coding-system) | |
137 (if coding-system | |
138 (decode-coding-region start end coding-system))) | |
139 (defun mm-encode-coding-region (start end coding-system) | |
140 (if coding-system | |
141 (encode-coding-region start end coding-system)))) | |
142 (defun mm-decode-coding-string (str coding-system) str) | |
143 (defun mm-encode-coding-string (str coding-system) str) | |
144 (defalias 'mm-decode-coding-region 'ignore) | |
145 (defalias 'mm-encode-coding-region 'ignore)) | |
146 (defalias 'mm-decode-coding-string 'decode-coding-string) | |
147 (defalias 'mm-encode-coding-string 'encode-coding-string) | |
148 (defalias 'mm-decode-coding-region 'decode-coding-region) | |
149 (defalias 'mm-encode-coding-region 'encode-coding-region))) | |
150 | |
74214 | 151 (defalias 'mm-string-to-multibyte |
152 (cond | |
153 ((featurep 'xemacs) | |
154 'identity) | |
155 ((fboundp 'string-to-multibyte) | |
156 'string-to-multibyte) | |
157 (t | |
158 (lambda (string) | |
159 "Return a multibyte string with the same individual chars as string." | |
160 (mapconcat | |
161 (lambda (ch) (mm-string-as-multibyte (char-to-string ch))) | |
162 string ""))))) | |
163 | |
61126
c0aa521e0ca7
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-220
Miles Bader <miles@gnu.org>
parents:
60029
diff
changeset
|
164 (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
|
165 (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
|
166 (cond |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
167 ((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
|
168 ((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
|
169 (t 'identity)))) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
170 |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
53617
diff
changeset
|
171 ;; 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
|
172 ;; 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
|
173 ;; 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
|
174 ;; 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
|
175 ;; test with |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
53617
diff
changeset
|
176 ;; `(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
|
177 ;; (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
|
178 ;; 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
|
179 (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
|
180 (defalias 'mm-read-coding-system |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
181 (cond |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
182 ((fboundp 'read-coding-system) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
183 (if (and (featurep 'xemacs) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
184 (<= (string-to-number emacs-version) 21.1)) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
185 (lambda (prompt &optional default-coding-system) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
186 (read-coding-system prompt)) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
187 'read-coding-system)) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
188 (t (lambda (prompt &optional default-coding-system) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
189 "Prompt the user for a coding system." |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
190 (completing-read |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
191 prompt (mapcar (lambda (s) (list (symbol-name (car s)))) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
192 mm-mime-mule-charset-alist))))))) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
193 |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
194 (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
|
195 (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
|
196 "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
|
197 (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
|
198 (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
|
199 |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
53617
diff
changeset
|
200 (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
|
201 "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
|
202 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
|
203 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
|
204 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
|
205 (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
|
206 (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
|
207 (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
|
208 (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
|
209 cs) |
69135
12d289b6e5de
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-118
Miles Bader <miles@gnu.org>
parents:
68940
diff
changeset
|
210 ;; 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
|
211 (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
|
212 |
70052
261c2dbe91d2
* mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
69304
diff
changeset
|
213 (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
|
214 "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
|
215 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
|
216 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
|
217 `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
|
218 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
|
219 (interactive |
261c2dbe91d2
* mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
69304
diff
changeset
|
220 (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
|
221 (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
|
222 (cp-supported-codepages) |
98462
512497325cb3
(mm-codepage-setup): Tweak codepage error. Silence compiler warning.
Glenn Morris <rgm@gnu.org>
parents:
96275
diff
changeset
|
223 ;; Removed in Emacs 23 (unicode), so signal an error: |
512497325cb3
(mm-codepage-setup): Tweak codepage error. Silence compiler warning.
Glenn Morris <rgm@gnu.org>
parents:
96275
diff
changeset
|
224 (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
|
225 (list (completing-read "Setup DOS Codepage: (default 437) " candidates |
261c2dbe91d2
* mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
69304
diff
changeset
|
226 nil t nil nil "437")))) |
261c2dbe91d2
* mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
69304
diff
changeset
|
227 (when alias |
261c2dbe91d2
* mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
69304
diff
changeset
|
228 (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
|
229 (intern alias) |
261c2dbe91d2
* mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
69304
diff
changeset
|
230 (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
|
231 (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
|
232 (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
|
233 (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
|
234 (codepage-setup number) |
512497325cb3
(mm-codepage-setup): Tweak codepage error. Silence compiler warning.
Glenn Morris <rgm@gnu.org>
parents:
96275
diff
changeset
|
235 (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
|
236 (when (and alias |
261c2dbe91d2
* mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
69304
diff
changeset
|
237 ;; 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
|
238 (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
|
239 (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
|
240 |
40542
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
241 (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
|
242 `( |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
243 ;; 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
|
244 ,@(unless (mm-coding-system-p 'x-ctext) |
71926 | 245 '((x-ctext . ctext))) |
73546 | 246 ;; ISO-8859-15 is very similar to ISO-8859-1. But it's _different_ in 8 |
247 ;; positions! | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
53617
diff
changeset
|
248 ,@(unless (mm-coding-system-p 'iso-8859-15) |
71926 | 249 '((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
|
250 ;; 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
|
251 ,@(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
|
252 '((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
|
253 ;; A Microsoft misunderstanding. |
73546 | 254 ,@(when (and (not (mm-coding-system-p 'unicode)) |
255 (mm-coding-system-p 'utf-16-le)) | |
256 '((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
|
257 ;; A Microsoft misunderstanding. |
261c2dbe91d2
* mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
69304
diff
changeset
|
258 ,@(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
|
259 (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
|
260 '((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
|
261 '((ks_c_5601-1987 . euc-kr)))) |
71926 | 262 ;; Windows-31J is Windows Codepage 932. |
73546 | 263 ,@(when (and (not (mm-coding-system-p 'windows-31j)) |
264 (mm-coding-system-p 'cp932)) | |
265 '((windows-31j . cp932))) | |
79022 | 266 ;; Charset name: GBK, Charset aliases: CP936, MS936, windows-936 |
267 ;; http://www.iana.org/assignments/charset-reg/GBK | |
268 ;; Emacs 22.1 has cp936, but not gbk, so we alias it: | |
269 ,@(when (and (not (mm-coding-system-p 'gbk)) | |
270 (mm-coding-system-p 'cp936)) | |
271 '((gbk . cp936))) | |
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
272 ;; 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
|
273 ,@(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
|
274 (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
|
275 '((iso8859-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
|
276 ) |
73546 | 277 "A mapping from unknown or invalid charset names to the real charset names. |
278 | |
279 See `mm-codepage-iso-8859-list' and `mm-codepage-ibm-list'.") | |
280 | |
281 (defcustom mm-codepage-iso-8859-list | |
282 (list 1250 ;; Windows-1250 is a variant of Latin-2 heavily used by Microsoft | |
283 ;; Outlook users in Czech republic. Use this to allow reading of | |
284 ;; their e-mails. cp1250 should be defined by M-x codepage-setup | |
285 ;; (Emacs 21). | |
286 '(1252 . 1) ;; Windows-1252 is a superset of iso-8859-1 (West | |
287 ;; Europe). See also `gnus-article-dumbquotes-map'. | |
288 '(1254 . 9) ;; Windows-1254 is a superset of iso-8859-9 (Turkish). | |
289 '(1255 . 8));; Windows-1255 is a superset of iso-8859-8 (Hebrew). | |
290 "A list of Windows codepage numbers and iso-8859 charset numbers. | |
291 | |
292 If an element is a number corresponding to a supported windows | |
293 codepage, appropriate entries to `mm-charset-synonym-alist' are | |
294 added by `mm-setup-codepage-iso-8859'. An element may also be a | |
295 cons cell where the car is a codepage number and the cdr is the | |
296 corresponding number of an iso-8859 charset." | |
297 :type '(list (set :inline t | |
298 (const 1250 :tag "Central and East European") | |
299 (const (1252 . 1) :tag "West European") | |
300 (const (1254 . 9) :tag "Turkish") | |
301 (const (1255 . 8) :tag "Hebrew")) | |
302 (repeat :inline t | |
303 :tag "Other options" | |
304 (choice | |
305 (integer :tag "Windows codepage number") | |
306 (cons (integer :tag "Windows codepage number") | |
307 (integer :tag "iso-8859 charset number"))))) | |
308 :version "22.1" ;; Gnus 5.10.9 | |
309 :group 'mime) | |
310 | |
311 (defcustom mm-codepage-ibm-list | |
312 (list 437 ;; (US etc.) | |
313 860 ;; (Portugal) | |
314 861 ;; (Iceland) | |
315 862 ;; (Israel) | |
316 863 ;; (Canadian French) | |
317 865 ;; (Nordic) | |
318 852 ;; | |
319 850 ;; (Latin 1) | |
320 855 ;; (Cyrillic) | |
321 866 ;; (Cyrillic - Russian) | |
322 857 ;; (Turkish) | |
323 864 ;; (Arabic) | |
324 869 ;; (Greek) | |
325 874);; (Thai) | |
326 ;; In Emacs 23 (unicode), cp... and ibm... are aliases. | |
327 ;; Cf. http://thread.gmane.org/v9lkng5nwy.fsf@marauder.physik.uni-ulm.de | |
328 "List of IBM codepage numbers. | |
329 | |
330 The codepage mappings slighly differ between IBM and other vendors. | |
331 See \"ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/IBM/README.TXT\". | |
332 | |
333 If an element is a number corresponding to a supported windows | |
334 codepage, appropriate entries to `mm-charset-synonym-alist' are | |
335 added by `mm-setup-codepage-ibm'." | |
336 :type '(list (set :inline t | |
337 (const 437 :tag "US etc.") | |
338 (const 860 :tag "Portugal") | |
339 (const 861 :tag "Iceland") | |
340 (const 862 :tag "Israel") | |
341 (const 863 :tag "Canadian French") | |
342 (const 865 :tag "Nordic") | |
343 (const 852) | |
344 (const 850 :tag "Latin 1") | |
345 (const 855 :tag "Cyrillic") | |
346 (const 866 :tag "Cyrillic - Russian") | |
347 (const 857 :tag "Turkish") | |
348 (const 864 :tag "Arabic") | |
349 (const 869 :tag "Greek") | |
350 (const 874 :tag "Thai")) | |
351 (repeat :inline t | |
352 :tag "Other options" | |
353 (integer :tag "Codepage number"))) | |
354 :version "22.1" ;; Gnus 5.10.9 | |
355 :group 'mime) | |
356 | |
357 (defun mm-setup-codepage-iso-8859 (&optional list) | |
358 "Add appropriate entries to `mm-charset-synonym-alist'. | |
359 Unless LIST is given, `mm-codepage-iso-8859-list' is used." | |
360 (unless list | |
361 (setq list mm-codepage-iso-8859-list)) | |
362 (dolist (i list) | |
363 (let (cp windows iso) | |
364 (if (consp i) | |
365 (setq cp (intern (format "cp%d" (car i))) | |
366 windows (intern (format "windows-%d" (car i))) | |
367 iso (intern (format "iso-8859-%d" (cdr i)))) | |
368 (setq cp (intern (format "cp%d" i)) | |
369 windows (intern (format "windows-%d" i)))) | |
370 (unless (mm-coding-system-p windows) | |
371 (if (mm-coding-system-p cp) | |
372 (add-to-list 'mm-charset-synonym-alist (cons windows cp)) | |
373 (add-to-list 'mm-charset-synonym-alist (cons windows iso))))))) | |
374 | |
375 (defun mm-setup-codepage-ibm (&optional list) | |
376 "Add appropriate entries to `mm-charset-synonym-alist'. | |
377 Unless LIST is given, `mm-codepage-ibm-list' is used." | |
378 (unless list | |
379 (setq list mm-codepage-ibm-list)) | |
380 (dolist (number list) | |
381 (let ((ibm (intern (format "ibm%d" number))) | |
382 (cp (intern (format "cp%d" number)))) | |
383 (when (and (not (mm-coding-system-p ibm)) | |
384 (mm-coding-system-p cp)) | |
385 (add-to-list 'mm-charset-synonym-alist (cons ibm cp)))))) | |
386 | |
387 ;; Initialize: | |
388 (mm-setup-codepage-iso-8859) | |
389 (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
|
390 |
261c2dbe91d2
* mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
69304
diff
changeset
|
391 (defcustom mm-charset-override-alist |
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
392 '((iso-8859-1 . windows-1252) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
393 (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
|
394 (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
|
395 "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
|
396 |
261c2dbe91d2
* mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
69304
diff
changeset
|
397 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
|
398 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
|
399 superset of iso-8859-1." |
261c2dbe91d2
* mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
69304
diff
changeset
|
400 :type '(list (set :inline t |
261c2dbe91d2
* mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
69304
diff
changeset
|
401 (const (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
|
402 (const (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
|
403 (const (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
|
404 (const (undecided . windows-1252))) |
261c2dbe91d2
* mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
69304
diff
changeset
|
405 (repeat :inline t |
261c2dbe91d2
* mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
69304
diff
changeset
|
406 :tag "Other options" |
261c2dbe91d2
* mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
69304
diff
changeset
|
407 (cons (symbol :tag "From charset") |
261c2dbe91d2
* mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
69304
diff
changeset
|
408 (symbol :tag "To charset")))) |
73224 | 409 :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
|
410 :group 'mime) |
261c2dbe91d2
* mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
69304
diff
changeset
|
411 |
261c2dbe91d2
* mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
69304
diff
changeset
|
412 (defcustom mm-charset-eval-alist |
261c2dbe91d2
* mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
69304
diff
changeset
|
413 (if (featurep 'xemacs) |
261c2dbe91d2
* mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
69304
diff
changeset
|
414 nil ;; I don't know what would be useful for XEmacs. |
261c2dbe91d2
* mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
69304
diff
changeset
|
415 '(;; Emacs 21 offers 1250 1251 1253 1257. Emacs 22 provides autoloads for |
261c2dbe91d2
* mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
69304
diff
changeset
|
416 ;; 1250-1258 (i.e. `mm-codepage-setup' does nothing). |
261c2dbe91d2
* mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
69304
diff
changeset
|
417 (windows-1250 . (mm-codepage-setup 1250 t)) |
261c2dbe91d2
* mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
69304
diff
changeset
|
418 (windows-1251 . (mm-codepage-setup 1251 t)) |
261c2dbe91d2
* mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
69304
diff
changeset
|
419 (windows-1253 . (mm-codepage-setup 1253 t)) |
261c2dbe91d2
* mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
69304
diff
changeset
|
420 (windows-1257 . (mm-codepage-setup 1257 t)))) |
261c2dbe91d2
* mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
69304
diff
changeset
|
421 "An alist of (CHARSET . FORM) pairs. |
261c2dbe91d2
* mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
69304
diff
changeset
|
422 If an article is encoded in an unknown CHARSET, FORM is |
261c2dbe91d2
* mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
69304
diff
changeset
|
423 evaluated. This allows to load additional libraries providing |
261c2dbe91d2
* mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
69304
diff
changeset
|
424 charsets on demand. If supported by your Emacs version, you |
261c2dbe91d2
* mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
69304
diff
changeset
|
425 could use `autoload-coding-system' here." |
73224 | 426 :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
|
427 :type '(list (set :inline t |
261c2dbe91d2
* mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
69304
diff
changeset
|
428 (const (windows-1250 . (mm-codepage-setup 1250 t))) |
261c2dbe91d2
* mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
69304
diff
changeset
|
429 (const (windows-1251 . (mm-codepage-setup 1251 t))) |
261c2dbe91d2
* mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
69304
diff
changeset
|
430 (const (windows-1253 . (mm-codepage-setup 1253 t))) |
261c2dbe91d2
* mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
69304
diff
changeset
|
431 (const (windows-1257 . (mm-codepage-setup 1257 t))) |
261c2dbe91d2
* mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
69304
diff
changeset
|
432 (const (cp850 . (mm-codepage-setup 850 nil)))) |
261c2dbe91d2
* mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
69304
diff
changeset
|
433 (repeat :inline t |
261c2dbe91d2
* mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
69304
diff
changeset
|
434 :tag "Other options" |
261c2dbe91d2
* mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
69304
diff
changeset
|
435 (cons (symbol :tag "charset") |
261c2dbe91d2
* mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
69304
diff
changeset
|
436 (symbol :tag "form")))) |
261c2dbe91d2
* mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
69304
diff
changeset
|
437 :group 'mime) |
79313 | 438 (put 'mm-charset-eval-alist 'risky-local-variable t) |
40542
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
439 |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
440 (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
|
441 (cond |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
442 ((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
|
443 ((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
|
444 (t nil)) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
445 "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
|
446 |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
447 (defvar mm-text-coding-system |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
448 (or (if (memq system-type '(windows-nt ms-dos ms-windows)) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
449 (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
|
450 (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
|
451 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
|
452 "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
|
453 |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
454 (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
|
455 "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
|
456 |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
457 (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
|
458 (cond |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
53617
diff
changeset
|
459 ((mm-coding-system-p 'utf-8-emacs) ; Mule 7 |
47949
33e1238070a2
(mm-mime-mule-charset-alist): Require when compiling.
Dave Love <fx@gnu.org>
parents:
44075
diff
changeset
|
460 (if (memq system-type '(windows-nt ms-dos ms-windows)) |
33e1238070a2
(mm-mime-mule-charset-alist): Require when compiling.
Dave Love <fx@gnu.org>
parents:
44075
diff
changeset
|
461 (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
|
462 '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
|
463 '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
|
464 ((mm-coding-system-p 'emacs-mule) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
465 (if (memq system-type '(windows-nt ms-dos ms-windows)) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
466 (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
|
467 '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
|
468 'emacs-mule)) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
469 ((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
|
470 (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
|
471 "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
|
472 |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
473 (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
|
474 "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
|
475 |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
476 ;; 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
|
477 ;; should only matter with XEmacs, though. |
31717 | 478 (defvar mm-mime-mule-charset-alist |
35793 | 479 `((us-ascii ascii) |
31717 | 480 (iso-8859-1 latin-iso8859-1) |
481 (iso-8859-2 latin-iso8859-2) | |
482 (iso-8859-3 latin-iso8859-3) | |
483 (iso-8859-4 latin-iso8859-4) | |
484 (iso-8859-5 cyrillic-iso8859-5) | |
485 ;; 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
|
486 ;; The fake mule-charset, gnus-koi8-r, tells Gnus that the default |
31717 | 487 ;; charset is koi8-r, not iso-8859-5. |
488 (koi8-r cyrillic-iso8859-5 gnus-koi8-r) | |
489 (iso-8859-6 arabic-iso8859-6) | |
490 (iso-8859-7 greek-iso8859-7) | |
491 (iso-8859-8 hebrew-iso8859-8) | |
492 (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
|
493 (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
|
494 (iso-8859-15 latin-iso8859-15) |
31717 | 495 (viscii vietnamese-viscii-lower) |
496 (iso-2022-jp latin-jisx0201 japanese-jisx0208 japanese-jisx0208-1978) | |
497 (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
|
498 (gb2312 chinese-gb2312) |
90683
70c40ef3afa5
(mm-mime-mule-charset-alist): Add gbk and GB18030.
Kenichi Handa <handa@m17n.org>
parents:
90645
diff
changeset
|
499 (gbk chinese-gbk) |
70c40ef3afa5
(mm-mime-mule-charset-alist): Add gbk and GB18030.
Kenichi Handa <handa@m17n.org>
parents:
90645
diff
changeset
|
500 (gb18030 gb18030-2-byte |
70c40ef3afa5
(mm-mime-mule-charset-alist): Add gbk and GB18030.
Kenichi Handa <handa@m17n.org>
parents:
90645
diff
changeset
|
501 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
|
502 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
|
503 (big5 chinese-big5-1 chinese-big5-2) |
31717 | 504 (tibetan tibetan) |
505 (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
|
506 (windows-1251 cyrillic-iso8859-5) |
31717 | 507 (iso-2022-7bit ethiopic arabic-1-column arabic-2-column) |
508 (iso-2022-jp-2 latin-iso8859-1 greek-iso8859-7 | |
509 latin-jisx0201 japanese-jisx0208-1978 | |
510 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
|
511 korean-ksc5601 japanese-jisx0212) |
31717 | 512 (iso-2022-int-1 latin-iso8859-1 greek-iso8859-7 |
513 latin-jisx0201 japanese-jisx0208-1978 | |
514 chinese-gb2312 japanese-jisx0208 | |
515 korean-ksc5601 japanese-jisx0212 | |
516 chinese-cns11643-1 chinese-cns11643-2) | |
517 (iso-2022-int-1 latin-iso8859-1 latin-iso8859-2 | |
518 cyrillic-iso8859-5 greek-iso8859-7 | |
519 latin-jisx0201 japanese-jisx0208-1978 | |
520 chinese-gb2312 japanese-jisx0208 | |
521 korean-ksc5601 japanese-jisx0212 | |
522 chinese-cns11643-1 chinese-cns11643-2 | |
523 chinese-cns11643-3 chinese-cns11643-4 | |
524 chinese-cns11643-5 chinese-cns11643-6 | |
525 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
|
526 (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
|
527 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
|
528 (shift_jis latin-jisx0201 katakana-jisx0201 japanese-jisx0208) |
71262 | 529 ,(cond ((fboundp 'unicode-precedence-list) |
530 (cons 'utf-8 (delq 'ascii (mapcar 'charset-name | |
531 (unicode-precedence-list))))) | |
532 ((or (not (fboundp 'charsetp)) ;; non-Mule case | |
533 (charsetp 'unicode-a) | |
534 (not (mm-coding-system-p 'mule-utf-8))) | |
535 '(utf-8 unicode-a unicode-b unicode-c unicode-d unicode-e)) | |
536 (t ;; If we have utf-8 we're in Mule 5+. | |
537 (append '(utf-8) | |
538 (delete 'ascii | |
539 (coding-system-get 'mule-utf-8 'safe-charsets)))))) | |
31717 | 540 "Alist of MIME-charset/MULE-charsets.") |
541 | |
57923
d7def5572cf3
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents:
57784
diff
changeset
|
542 (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
|
543 "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
|
544 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
|
545 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
|
546 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
|
547 (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
|
548 (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
|
549 (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
|
550 'ascii |
d7def5572cf3
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents:
57784
diff
changeset
|
551 (copy-sequence |
d7def5572cf3
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents:
57784
diff
changeset
|
552 (symbol-value |
d7def5572cf3
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents:
57784
diff
changeset
|
553 '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
|
554 (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
|
555 (if elem |
d7def5572cf3
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents:
57784
diff
changeset
|
556 (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
|
557 (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
|
558 (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
|
559 (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
|
560 (error)))) |
d7def5572cf3
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents:
57784
diff
changeset
|
561 |
d7def5572cf3
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents:
57784
diff
changeset
|
562 ;; 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
|
563 (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
|
564 (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
|
565 (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
|
566 (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
|
567 (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
|
568 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
|
569 (while css |
d7def5572cf3
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents:
57784
diff
changeset
|
570 (setq cs (pop css) |
90317
34c8b755296d
Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-23
Miles Bader <miles@gnu.org>
diff
changeset
|
571 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
|
572 (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
|
573 (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
|
574 (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
|
575 (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
|
576 (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
|
577 (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
|
578 (setq mm-mime-mule-charset-alist (nreverse alist))))) |
31717 | 579 |
92153
37d6263f580b
Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents:
91718
diff
changeset
|
580 (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
|
581 "A list of special charsets. |
37d6263f580b
Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents:
91718
diff
changeset
|
582 Valid elements include: |
37d6263f580b
Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents:
91718
diff
changeset
|
583 `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
|
584 `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
|
585 ) |
37d6263f580b
Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents:
91718
diff
changeset
|
586 |
37d6263f580b
Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents:
91718
diff
changeset
|
587 (defvar mm-iso-8859-15-compatible |
37d6263f580b
Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents:
91718
diff
changeset
|
588 '((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
|
589 (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
|
590 "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
|
591 |
37d6263f580b
Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents:
91718
diff
changeset
|
592 (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
|
593 (and (fboundp 'coding-system-p) |
37d6263f580b
Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents:
91718
diff
changeset
|
594 (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
|
595 (mapcar |
37d6263f580b
Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents:
91718
diff
changeset
|
596 (lambda (cs) |
37d6263f580b
Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents:
91718
diff
changeset
|
597 (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
|
598 (let ((c (string-to-char |
37d6263f580b
Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents:
91718
diff
changeset
|
599 (decode-coding-string "\341" (car cs))))) |
37d6263f580b
Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents:
91718
diff
changeset
|
600 (cons (char-charset c) |
37d6263f580b
Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents:
91718
diff
changeset
|
601 (cons |
37d6263f580b
Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents:
91718
diff
changeset
|
602 (- (string-to-char |
37d6263f580b
Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents:
91718
diff
changeset
|
603 (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
|
604 (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
|
605 (car cs)))))) |
37d6263f580b
Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents:
91718
diff
changeset
|
606 '(gnus-charset 0))) |
37d6263f580b
Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents:
91718
diff
changeset
|
607 mm-iso-8859-15-compatible)) |
37d6263f580b
Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents:
91718
diff
changeset
|
608 "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
|
609 |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
53617
diff
changeset
|
610 (defcustom mm-coding-system-priorities |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
53617
diff
changeset
|
611 (if (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
|
612 (let ((lang (symbol-value '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
|
613 (cond ((string= lang "Japanese") |
57784
55829134ac17
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-650
Miles Bader <miles@gnu.org>
parents:
57243
diff
changeset
|
614 ;; Japanese users prefer iso-2022-jp to euc-japan or |
55829134ac17
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-650
Miles Bader <miles@gnu.org>
parents:
57243
diff
changeset
|
615 ;; shift_jis, however iso-8859-1 should be used when |
55829134ac17
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-650
Miles Bader <miles@gnu.org>
parents:
57243
diff
changeset
|
616 ;; there are only ASCII text and Latin-1 characters. |
55829134ac17
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-650
Miles Bader <miles@gnu.org>
parents:
57243
diff
changeset
|
617 '(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
|
618 "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
|
619 |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
53617
diff
changeset
|
620 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
|
621 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
|
622 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
|
623 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
|
624 :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
|
625 :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
|
626 :group 'mime) |
41494
933ab100fb4a
2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
40621
diff
changeset
|
627 |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
53617
diff
changeset
|
628 ;; ?? |
42500
9b68dff3d385
* mm-util.el (mm-use-find-coding-systems-region): New variable.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
42493
diff
changeset
|
629 (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
|
630 (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
|
631 "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
|
632 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
53617
diff
changeset
|
633 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
|
634 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
|
635 |
31717 | 636 ;;; Internal variables: |
637 | |
638 ;;; Functions: | |
639 | |
640 (defun mm-mule-charset-to-mime-charset (charset) | |
33378 | 641 "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
|
642 (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
|
643 (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
|
644 (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
|
645 (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
|
646 '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
|
647 cs mime) |
d7def5572cf3
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents:
57784
diff
changeset
|
648 (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
|
649 css) |
d7def5572cf3
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents:
57784
diff
changeset
|
650 (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
|
651 (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
|
652 (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
|
653 mime) |
57923
d7def5572cf3
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents:
57784
diff
changeset
|
654 (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
|
655 (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
|
656 (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
|
657 '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
|
658 out) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
659 (while alist |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
660 (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
|
661 (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
|
662 alist nil)) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
663 (pop alist)) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
664 out))) |
31717 | 665 |
70052
261c2dbe91d2
* mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
69304
diff
changeset
|
666 (defun mm-charset-to-coding-system (charset &optional lbt |
261c2dbe91d2
* mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
69304
diff
changeset
|
667 allow-override) |
31717 | 668 "Return coding-system corresponding to CHARSET. |
669 CHARSET is a symbol naming a MIME charset. | |
670 If optional argument LBT (`unix', `dos' or `mac') is specified, it is | |
70052
261c2dbe91d2
* mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
69304
diff
changeset
|
671 used as the line break code type of the coding system. |
261c2dbe91d2
* mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
69304
diff
changeset
|
672 |
261c2dbe91d2
* mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
69304
diff
changeset
|
673 If ALLOW-OVERRIDE is given, use `mm-charset-override-alist' to |
261c2dbe91d2
* mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
69304
diff
changeset
|
674 map undesired charset names to their replacement. This should |
261c2dbe91d2
* mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
69304
diff
changeset
|
675 only be used for decoding, not for encoding." |
261c2dbe91d2
* mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
69304
diff
changeset
|
676 ;; OVERRIDE is used (only) in `mm-decode-body' and `mm-decode-string'. |
31717 | 677 (when (stringp charset) |
678 (setq charset (intern (downcase charset)))) | |
679 (when lbt | |
680 (setq charset (intern (format "%s-%s" charset lbt)))) | |
681 (cond | |
41494
933ab100fb4a
2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
40621
diff
changeset
|
682 ((null charset) |
933ab100fb4a
2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
40621
diff
changeset
|
683 charset) |
31717 | 684 ;; Running in a non-MULE environment. |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
53617
diff
changeset
|
685 ((or (null (mm-get-coding-system-list)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
53617
diff
changeset
|
686 (not (fboundp 'coding-system-get))) |
31717 | 687 charset) |
70052
261c2dbe91d2
* mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
69304
diff
changeset
|
688 ;; Check override list quite early. Should only used for decoding, not for |
261c2dbe91d2
* mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
69304
diff
changeset
|
689 ;; encoding! |
261c2dbe91d2
* mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
69304
diff
changeset
|
690 ((and allow-override |
261c2dbe91d2
* mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
69304
diff
changeset
|
691 (let ((cs (cdr (assq charset mm-charset-override-alist)))) |
261c2dbe91d2
* mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
69304
diff
changeset
|
692 (and cs (mm-coding-system-p cs) cs)))) |
31717 | 693 ;; ascii |
694 ((eq charset 'us-ascii) | |
695 'ascii) | |
33378 | 696 ;; Check to see whether we can handle this charset. (This depends |
697 ;; on there being some coding system matching each `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
|
698 ;; property defined, as there should be.) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
699 ((and (mm-coding-system-p charset) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
700 ;;; Doing this would potentially weed out incorrect charsets. |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
701 ;;; charset |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
702 ;;; (eq charset (coding-system-get charset 'mime-charset)) |
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 charset) |
70052
261c2dbe91d2
* mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
69304
diff
changeset
|
705 ;; Eval expressions from `mm-charset-eval-alist' |
261c2dbe91d2
* mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
69304
diff
changeset
|
706 ((let* ((el (assq charset mm-charset-eval-alist)) |
261c2dbe91d2
* mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
69304
diff
changeset
|
707 (cs (car el)) |
261c2dbe91d2
* mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
69304
diff
changeset
|
708 (form (cdr el))) |
261c2dbe91d2
* mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
69304
diff
changeset
|
709 (and cs |
261c2dbe91d2
* mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
69304
diff
changeset
|
710 form |
261c2dbe91d2
* mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
69304
diff
changeset
|
711 (prog2 |
261c2dbe91d2
* mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
69304
diff
changeset
|
712 ;; Avoid errors... |
261c2dbe91d2
* mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
69304
diff
changeset
|
713 (condition-case nil (eval form) (error nil)) |
261c2dbe91d2
* mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
69304
diff
changeset
|
714 ;; (message "Failed to eval `%s'" form)) |
261c2dbe91d2
* mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
69304
diff
changeset
|
715 (mm-coding-system-p cs) |
261c2dbe91d2
* mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
69304
diff
changeset
|
716 (message "Added charset `%s' via `mm-charset-eval-alist'" cs)) |
261c2dbe91d2
* mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
69304
diff
changeset
|
717 cs))) |
40542
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
718 ;; Translate invalid charsets. |
42493
84a510bb7ff6
2002-01-03 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
42206
diff
changeset
|
719 ((let ((cs (cdr (assq charset mm-charset-synonym-alist)))) |
70052
261c2dbe91d2
* mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
69304
diff
changeset
|
720 (and cs |
261c2dbe91d2
* mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
69304
diff
changeset
|
721 (mm-coding-system-p cs) |
261c2dbe91d2
* mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
69304
diff
changeset
|
722 ;; (message |
261c2dbe91d2
* mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
69304
diff
changeset
|
723 ;; "Using synonym `%s' from `mm-charset-synonym-alist' for `%s'" |
261c2dbe91d2
* mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
69304
diff
changeset
|
724 ;; cs charset) |
261c2dbe91d2
* mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
69304
diff
changeset
|
725 cs))) |
40542
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
726 ;; Last resort: search the coding system list for entries which |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
727 ;; have the right mime-charset in case the canonical name isn't |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
728 ;; defined (though it should be). |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
729 ((let (cs) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
730 ;; mm-get-coding-system-list returns a list of cs without lbt. |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
731 ;; Do we need -lbt? |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
732 (dolist (c (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
|
733 (if (and (null cs) |
47949
33e1238070a2
(mm-mime-mule-charset-alist): Require when compiling.
Dave Love <fx@gnu.org>
parents:
44075
diff
changeset
|
734 (eq charset (or (coding-system-get c :mime-charset) |
33e1238070a2
(mm-mime-mule-charset-alist): Require when compiling.
Dave Love <fx@gnu.org>
parents:
44075
diff
changeset
|
735 (coding-system-get c '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
|
736 (setq cs c))) |
70052
261c2dbe91d2
* mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
69304
diff
changeset
|
737 (unless cs |
261c2dbe91d2
* mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
69304
diff
changeset
|
738 ;; Warn the user about unknown charset: |
261c2dbe91d2
* mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
69304
diff
changeset
|
739 (if (fboundp 'gnus-message) |
261c2dbe91d2
* mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
69304
diff
changeset
|
740 (gnus-message 7 "Unknown charset: %s" charset) |
261c2dbe91d2
* mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
69304
diff
changeset
|
741 (message "Unknown charset: %s" charset))) |
40542
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
742 cs)))) |
31717 | 743 |
40542
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
744 (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
|
745 (defvar mm-emacs-mule (and (not (featurep 'xemacs)) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
746 (boundp 'default-enable-multibyte-characters) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
747 default-enable-multibyte-characters |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
748 (fboundp 'set-buffer-multibyte)) |
47949
33e1238070a2
(mm-mime-mule-charset-alist): Require when compiling.
Dave Love <fx@gnu.org>
parents:
44075
diff
changeset
|
749 "True in Emacs with Mule.") |
40542
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
750 |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
751 (if mm-emacs-mule |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
752 (defun mm-enable-multibyte () |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
753 "Set the multibyte flag of the current buffer. |
33378 | 754 Only do this if the default value of `enable-multibyte-characters' is |
755 non-nil. This is a no-op 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
|
756 (set-buffer-multibyte 'to)) |
40542
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
757 (defalias 'mm-enable-multibyte 'ignore)) |
31717 | 758 |
40542
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
759 (if mm-emacs-mule |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
760 (defun mm-disable-multibyte () |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
761 "Unset the multibyte flag of in the current buffer. |
33378 | 762 This is a no-op 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
|
763 (set-buffer-multibyte nil)) |
47949
33e1238070a2
(mm-mime-mule-charset-alist): Require when compiling.
Dave Love <fx@gnu.org>
parents:
44075
diff
changeset
|
764 (defalias 'mm-disable-multibyte 'ignore))) |
32976
aa9dc4e7c5ac
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
32414
diff
changeset
|
765 |
31717 | 766 (defun mm-preferred-coding-system (charset) |
767 ;; 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
|
768 (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
|
769 (get-charset-property charset 'prefered-coding-system))) |
31717 | 770 |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
53617
diff
changeset
|
771 ;; 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
|
772 (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
|
773 "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
|
774 (or |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
53617
diff
changeset
|
775 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
|
776 (progn |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
53617
diff
changeset
|
777 (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
|
778 (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
|
779 (car (last |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
53617
diff
changeset
|
780 (assq 'charset |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
53617
diff
changeset
|
781 (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
|
782 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
|
783 (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
|
784 (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
|
785 (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
|
786 (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
|
787 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
|
788 ;; default |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
53617
diff
changeset
|
789 '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
|
790 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
|
791 |
31717 | 792 (defun mm-charset-after (&optional pos) |
793 "Return charset of a character in current buffer at position POS. | |
794 If POS is nil, it defauls to the current point. | |
795 If POS is out of range, the value is nil. | |
796 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
|
797 (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
|
798 (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
|
799 (setq charset 'ascii) |
aa9dc4e7c5ac
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
32414
diff
changeset
|
800 ;; 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
|
801 (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
|
802 (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
|
803 (let ((p (or pos (point)))) |
aa9dc4e7c5ac
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
32414
diff
changeset
|
804 (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
|
805 (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
|
806 eight-bit-graphic)))) |
aa9dc4e7c5ac
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
32414
diff
changeset
|
807 charset |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
53617
diff
changeset
|
808 (mm-guess-charset)))))) |
31717 | 809 |
810 (defun mm-mime-charset (charset) | |
33378 | 811 "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
|
812 (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
|
813 (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
|
814 (if (and (fboundp 'coding-system-get) (fboundp 'get-charset-property)) |
31717 | 815 ;; This exists in Emacs 20. |
816 (or | |
817 (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
|
818 (or (coding-system-get |
33e1238070a2
(mm-mime-mule-charset-alist): Require when compiling.
Dave Love <fx@gnu.org>
parents:
44075
diff
changeset
|
819 (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
|
820 (coding-system-get |
33e1238070a2
(mm-mime-mule-charset-alist): Require when compiling.
Dave Love <fx@gnu.org>
parents:
44075
diff
changeset
|
821 (mm-preferred-coding-system charset) 'mime-charset))) |
31717 | 822 (and (eq charset 'ascii) |
823 '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
|
824 (mm-preferred-coding-system charset) |
31717 | 825 (mm-mule-charset-to-mime-charset charset)) |
826 ;; This is for XEmacs. | |
827 (mm-mule-charset-to-mime-charset charset))) | |
828 | |
65846
a4e8d78ae3fb
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-574
Miles Bader <miles@gnu.org>
parents:
64754
diff
changeset
|
829 (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
|
830 (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
|
831 (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
|
832 "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
|
833 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
|
834 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
|
835 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
|
836 |
a4e8d78ae3fb
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-574
Miles Bader <miles@gnu.org>
parents:
64754
diff
changeset
|
837 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
|
838 ;; 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
|
839 (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
|
840 (while tail |
a4e8d78ae3fb
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-574
Miles Bader <miles@gnu.org>
parents:
64754
diff
changeset
|
841 (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
|
842 (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
|
843 list)) |
31717 | 844 |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
53617
diff
changeset
|
845 ;; 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
|
846 ;; 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
|
847 (eval-and-compile |
32976
aa9dc4e7c5ac
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
32414
diff
changeset
|
848 (if (and (not (featurep 'xemacs)) |
aa9dc4e7c5ac
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
32414
diff
changeset
|
849 (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
|
850 (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
|
851 "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
|
852 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
|
853 (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
|
854 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
53617
diff
changeset
|
855 (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
|
856 "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
|
857 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
|
858 (if (featurep 'mule) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
53617
diff
changeset
|
859 (if (boundp 'default-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
|
860 default-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
|
861 t))) |
31717 | 862 |
92153
37d6263f580b
Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents:
91718
diff
changeset
|
863 (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
|
864 (if (fboundp 'char-charset) |
37d6263f580b
Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents:
91718
diff
changeset
|
865 (let (charset item c inconvertible) |
37d6263f580b
Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents:
91718
diff
changeset
|
866 (save-restriction |
37d6263f580b
Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents:
91718
diff
changeset
|
867 (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
|
868 (goto-char (point-min)) |
37d6263f580b
Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents:
91718
diff
changeset
|
869 (skip-chars-forward "\0-\177") |
37d6263f580b
Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents:
91718
diff
changeset
|
870 (while (not (eobp)) |
37d6263f580b
Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents:
91718
diff
changeset
|
871 (cond |
37d6263f580b
Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents:
91718
diff
changeset
|
872 ((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
|
873 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
|
874 (forward-char)) |
37d6263f580b
Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents:
91718
diff
changeset
|
875 ((memq c (cdr (cdr item))) |
37d6263f580b
Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents:
91718
diff
changeset
|
876 (setq inconvertible t) |
37d6263f580b
Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents:
91718
diff
changeset
|
877 (forward-char)) |
37d6263f580b
Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents:
91718
diff
changeset
|
878 (t |
37d6263f580b
Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents:
91718
diff
changeset
|
879 (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
|
880 (delete-char 1))))) |
37d6263f580b
Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents:
91718
diff
changeset
|
881 (skip-chars-forward "\0-\177"))) |
37d6263f580b
Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents:
91718
diff
changeset
|
882 (not inconvertible)))) |
37d6263f580b
Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents:
91718
diff
changeset
|
883 |
41494
933ab100fb4a
2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
40621
diff
changeset
|
884 (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
|
885 (let ((priorities |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
53617
diff
changeset
|
886 (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
|
887 ;; 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
|
888 (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
|
889 (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
|
890 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
|
891 (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
|
892 (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
|
893 (> (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
|
894 (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
|
895 t)))) |
41494
933ab100fb4a
2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
40621
diff
changeset
|
896 |
59089
22da0004ae3c
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents:
57923
diff
changeset
|
897 (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
|
898 (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
|
899 (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
|
900 (autoload 'latin-unity-representations-feasible-region "latin-unity") |
86154 | 901 (autoload 'latin-unity-representations-present-region "latin-unity")) |
902 | |
903 (defvar latin-unity-coding-systems) | |
904 (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
|
905 |
22da0004ae3c
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents:
57923
diff
changeset
|
906 (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
|
907 "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
|
908 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
|
909 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
|
910 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
|
911 |
22da0004ae3c
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents:
57923
diff
changeset
|
912 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
|
913 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
|
914 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
|
915 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
|
916 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
|
917 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
|
918 |
22da0004ae3c
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents:
57923
diff
changeset
|
919 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
|
920 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
|
921 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
|
922 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
|
923 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
|
924 (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
|
925 |
22da0004ae3c
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents:
57923
diff
changeset
|
926 ;; 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
|
927 (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
|
928 (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
|
929 |
22da0004ae3c
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents:
57923
diff
changeset
|
930 ;; 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
|
931 (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
|
932 (progn |
22da0004ae3c
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents:
57923
diff
changeset
|
933 (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
|
934 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
|
935 |
22da0004ae3c
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents:
57923
diff
changeset
|
936 (catch 'done |
22da0004ae3c
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents:
57923
diff
changeset
|
937 |
22da0004ae3c
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents:
57923
diff
changeset
|
938 ;; 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
|
939 ;; 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
|
940 (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
|
941 (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
|
942 |
22da0004ae3c
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents:
57923
diff
changeset
|
943 ;; 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
|
944 ;; 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
|
945 (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
|
946 (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
|
947 |
22da0004ae3c
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents:
57923
diff
changeset
|
948 ;; 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
|
949 ;; 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
|
950 ;; 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
|
951 ;; 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
|
952 ;; 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
|
953 (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
|
954 (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
|
955 |
22da0004ae3c
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents:
57923
diff
changeset
|
956 ;; 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
|
957 ;; 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
|
958 ;; the region. |
22da0004ae3c
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents:
57923
diff
changeset
|
959 (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
|
960 (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
|
961 |
22da0004ae3c
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents:
57923
diff
changeset
|
962 ;; 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
|
963 ;; `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
|
964 ;; 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
|
965 nil)) |
22da0004ae3c
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents:
57923
diff
changeset
|
966 |
22da0004ae3c
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents:
57923
diff
changeset
|
967 ;; 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
|
968 ;; 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
|
969 nil))) |
22da0004ae3c
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents:
57923
diff
changeset
|
970 |
22da0004ae3c
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents:
57923
diff
changeset
|
971 (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
|
972 (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
|
973 `(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
|
974 |
87241
4d24ed4358ae
Add declare-function compatibility definition.
Glenn Morris <rgm@gnu.org>
parents:
86154
diff
changeset
|
975 (declare-function mm-delete-duplicates "mm-util" (list)) |
4d24ed4358ae
Add declare-function compatibility definition.
Glenn Morris <rgm@gnu.org>
parents:
86154
diff
changeset
|
976 |
41494
933ab100fb4a
2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
40621
diff
changeset
|
977 (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
|
978 "Return the MIME charsets needed to encode the region between B and E. |
42206 | 979 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
|
980 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
|
981 (let (charsets) |
933ab100fb4a
2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
40621
diff
changeset
|
982 ;; 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
|
983 (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
|
984 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
|
985 ;; 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
|
986 ;; system that has one. |
933ab100fb4a
2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
40621
diff
changeset
|
987 (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
|
988 (when mm-coding-system-priorities |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47949
diff
changeset
|
989 (setq systems |
41494
933ab100fb4a
2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
40621
diff
changeset
|
990 (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
|
991 (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
|
992 (unless (equal systems '(undecided)) |
933ab100fb4a
2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
40621
diff
changeset
|
993 (while systems |
47949
33e1238070a2
(mm-mime-mule-charset-alist): Require when compiling.
Dave Love <fx@gnu.org>
parents:
44075
diff
changeset
|
994 (let* ((head (pop systems)) |
33e1238070a2
(mm-mime-mule-charset-alist): Require when compiling.
Dave Love <fx@gnu.org>
parents:
44075
diff
changeset
|
995 (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
|
996 (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
|
997 ;; 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
|
998 ;; `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
|
999 ;; 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
|
1000 ;; 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
|
1001 ;; 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
|
1002 ;; 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
|
1003 ;; 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
|
1004 ;; `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
|
1005 ;; 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
|
1006 (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
|
1007 (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
|
1008 ;; 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
|
1009 ;; 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
|
1010 ;; 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
|
1011 ;; 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
|
1012 ;; 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
|
1013 ;; `utf-16...'.) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
53617
diff
changeset
|
1014 (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
|
1015 (setq systems nil |
933ab100fb4a
2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
40621
diff
changeset
|
1016 charsets (list cs)))))) |
933ab100fb4a
2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
40621
diff
changeset
|
1017 charsets)) |
59089
22da0004ae3c
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents:
57923
diff
changeset
|
1018 ;; 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
|
1019 ;; 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
|
1020 ;; 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
|
1021 (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
|
1022 |
90104
a01e7a9f1659
Revision: miles@gnu.org--gnu-2005/emacs--unicode--0--patch-14
Miles Bader <miles@gnu.org>
parents:
90070
diff
changeset
|
1023 ;; 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
|
1024 |
59089
22da0004ae3c
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents:
57923
diff
changeset
|
1025 ;; 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
|
1026 (setq charsets |
41494
933ab100fb4a
2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
40621
diff
changeset
|
1027 (mm-delete-duplicates |
933ab100fb4a
2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
40621
diff
changeset
|
1028 (mapcar 'mm-mime-charset |
933ab100fb4a
2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
40621
diff
changeset
|
1029 (delq 'ascii |
933ab100fb4a
2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
40621
diff
changeset
|
1030 (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
|
1031 (if (and (> (length charsets) 1) |
37d6263f580b
Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents:
91718
diff
changeset
|
1032 (memq 'iso-8859-15 charsets) |
37d6263f580b
Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents:
91718
diff
changeset
|
1033 (memq 'iso-8859-15 hack-charsets) |
37d6263f580b
Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents:
91718
diff
changeset
|
1034 (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
|
1035 (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
|
1036 (setq charsets (delq (car x) charsets)))) |
37d6263f580b
Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents:
91718
diff
changeset
|
1037 (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
|
1038 (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
|
1039 (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
|
1040 ;; 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
|
1041 (if (and (featurep 'xemacs) |
37d6263f580b
Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents:
91718
diff
changeset
|
1042 (> (length charsets) 1) |
37d6263f580b
Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents:
91718
diff
changeset
|
1043 (mm-coding-system-p 'utf-8)) |
37d6263f580b
Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents:
91718
diff
changeset
|
1044 (let ((mm-coding-system-priorities |
37d6263f580b
Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents:
91718
diff
changeset
|
1045 (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
|
1046 (setq charsets |
37d6263f580b
Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents:
91718
diff
changeset
|
1047 (mm-delete-duplicates |
37d6263f580b
Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents:
91718
diff
changeset
|
1048 (mapcar 'mm-mime-charset |
37d6263f580b
Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents:
91718
diff
changeset
|
1049 (delq 'ascii |
37d6263f580b
Revert removal of `mm-hack-charsets' in Gnus
Miles Bader <miles@gnu.org>
parents:
91718
diff
changeset
|
1050 (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
|
1051 charsets)) |
40542
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
1052 |
31717 | 1053 (defmacro mm-with-unibyte-buffer (&rest forms) |
1054 "Create a temporary buffer, and evaluate FORMS there like `progn'. | |
33378 | 1055 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
|
1056 `(with-temp-buffer |
c963dc42db06
(mm-with-unibyte-buffer, mm-with-multibyte-buffer):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93106
diff
changeset
|
1057 (mm-disable-multibyte) |
c963dc42db06
(mm-with-unibyte-buffer, mm-with-multibyte-buffer):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93106
diff
changeset
|
1058 ,@forms)) |
31717 | 1059 (put 'mm-with-unibyte-buffer 'lisp-indent-function 0) |
1060 (put 'mm-with-unibyte-buffer 'edebug-form-spec '(body)) | |
1061 | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
53617
diff
changeset
|
1062 (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
|
1063 "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
|
1064 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
|
1065 `(with-temp-buffer |
c963dc42db06
(mm-with-unibyte-buffer, mm-with-multibyte-buffer):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93106
diff
changeset
|
1066 (mm-enable-multibyte) |
c963dc42db06
(mm-with-unibyte-buffer, mm-with-multibyte-buffer):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93106
diff
changeset
|
1067 ,@forms)) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
53617
diff
changeset
|
1068 (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
|
1069 (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
|
1070 |
31717 | 1071 (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
|
1072 "Evaluate FORMS with current buffer temporarily made unibyte. |
33378 | 1073 Also bind `default-enable-multibyte-characters' to nil. |
69247
6580c61aced7
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-134
Miles Bader <miles@gnu.org>
parents:
69135
diff
changeset
|
1074 Equivalent to `progn' in XEmacs |
6580c61aced7
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-134
Miles Bader <miles@gnu.org>
parents:
69135
diff
changeset
|
1075 |
6580c61aced7
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-134
Miles Bader <miles@gnu.org>
parents:
69135
diff
changeset
|
1076 NOTE: Use this macro with caution in multibyte buffers (it is not |
6580c61aced7
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-134
Miles Bader <miles@gnu.org>
parents:
69135
diff
changeset
|
1077 worth using this macro in unibyte buffers of course). Use of |
6580c61aced7
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-134
Miles Bader <miles@gnu.org>
parents:
69135
diff
changeset
|
1078 `(set-buffer-multibyte t)', which is run finally, is generally |
6580c61aced7
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-134
Miles Bader <miles@gnu.org>
parents:
69135
diff
changeset
|
1079 harmful since it is likely to modify existing data in the buffer. |
69304
55d8c694b9cf
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-139
Miles Bader <miles@gnu.org>
parents:
69247
diff
changeset
|
1080 For instance, it converts \"\\300\\255\" into \"\\255\" in |
55d8c694b9cf
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-139
Miles Bader <miles@gnu.org>
parents:
69247
diff
changeset
|
1081 Emacs 23 (unicode)." |
40542
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
1082 (let ((multibyte (make-symbol "multibyte")) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
1083 (buffer (make-symbol "buffer"))) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47949
diff
changeset
|
1084 `(if mm-emacs-mule |
69247
6580c61aced7
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-134
Miles Bader <miles@gnu.org>
parents:
69135
diff
changeset
|
1085 (let ((,multibyte enable-multibyte-characters) |
40542
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
1086 (,buffer (current-buffer))) |
33378 | 1087 (unwind-protect |
1088 (let (default-enable-multibyte-characters) | |
1089 (set-buffer-multibyte nil) | |
1090 ,@forms) | |
40542
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
1091 (set-buffer ,buffer) |
33378 | 1092 (set-buffer-multibyte ,multibyte))) |
40542
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
1093 (let (default-enable-multibyte-characters) |
33378 | 1094 ,@forms)))) |
31717 | 1095 (put 'mm-with-unibyte-current-buffer 'lisp-indent-function 0) |
1096 (put 'mm-with-unibyte-current-buffer 'edebug-form-spec '(body)) | |
1097 | |
1098 (defun mm-find-charset-region (b e) | |
33378 | 1099 "Return a list of Emacs charsets in the region B to E." |
31717 | 1100 (cond |
1101 ((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
|
1102 (fboundp 'find-charset-region)) |
31717 | 1103 ;; 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
|
1104 ;; 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
|
1105 (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
|
1106 (dolist (cs |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
1107 '(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
|
1108 css) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
1109 (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
|
1110 (t |
aa9dc4e7c5ac
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
32414
diff
changeset
|
1111 ;; We are in a unibyte buffer or XEmacs non-mule, so we futz around a bit. |
31717 | 1112 (save-excursion |
1113 (save-restriction | |
1114 (narrow-to-region b e) | |
1115 (goto-char (point-min)) | |
1116 (skip-chars-forward "\0-\177") | |
1117 (if (eobp) | |
1118 '(ascii) | |
32976
aa9dc4e7c5ac
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
32414
diff
changeset
|
1119 (let (charset) |
aa9dc4e7c5ac
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
32414
diff
changeset
|
1120 (setq charset |
aa9dc4e7c5ac
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
32414
diff
changeset
|
1121 (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
|
1122 (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
|
1123 (assoc current-language-environment |
32976
aa9dc4e7c5ac
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
32414
diff
changeset
|
1124 language-info-alist)))))) |
aa9dc4e7c5ac
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
32414
diff
changeset
|
1125 (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
|
1126 (or charset |
aa9dc4e7c5ac
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
32414
diff
changeset
|
1127 (setq charset |
aa9dc4e7c5ac
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
32414
diff
changeset
|
1128 (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
|
1129 mm-mime-mule-charset-alist))))) |
aa9dc4e7c5ac
2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
32414
diff
changeset
|
1130 (list 'ascii (or charset 'latin-iso8859-1))))))))) |
31717 | 1131 |
1132 (defun mm-auto-mode-alist () | |
1133 "Return an `auto-mode-alist' with only the .gz (etc) thingies." | |
1134 (let ((alist auto-mode-alist) | |
1135 out) | |
1136 (while alist | |
1137 (when (listp (cdar alist)) | |
1138 (push (car alist) out)) | |
1139 (pop alist)) | |
1140 (nreverse out))) | |
1141 | |
1142 (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
|
1143 '(jka-compr-handler image-file-handler epa-file-handler) |
31717 | 1144 "A list of handlers doing (un)compression (etc) thingies.") |
1145 | |
1146 (defun mm-insert-file-contents (filename &optional visit beg end replace | |
1147 inhibit) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
53617
diff
changeset
|
1148 "Like `insert-file-contents', but only reads in the file. |
31717 | 1149 A buffer may be modified in several ways after reading into the buffer due |
1150 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
|
1151 `find-file-hooks', etc. |
47949
33e1238070a2
(mm-mime-mule-charset-alist): Require when compiling.
Dave Love <fx@gnu.org>
parents:
44075
diff
changeset
|
1152 If INHIBIT is non-nil, inhibit `mm-inhibit-file-name-handlers'. |
31717 | 1153 This function ensures that none of these modifications will take place." |
62943
11d53dd5abd9
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-345
Miles Bader <miles@gnu.org>
parents:
61519
diff
changeset
|
1154 (let* ((format-alist nil) |
11d53dd5abd9
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-345
Miles Bader <miles@gnu.org>
parents:
61519
diff
changeset
|
1155 (auto-mode-alist (if inhibit nil (mm-auto-mode-alist))) |
11d53dd5abd9
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-345
Miles Bader <miles@gnu.org>
parents:
61519
diff
changeset
|
1156 (default-major-mode 'fundamental-mode) |
11d53dd5abd9
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-345
Miles Bader <miles@gnu.org>
parents:
61519
diff
changeset
|
1157 (enable-local-variables nil) |
11d53dd5abd9
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-345
Miles Bader <miles@gnu.org>
parents:
61519
diff
changeset
|
1158 (after-insert-file-functions nil) |
11d53dd5abd9
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-345
Miles Bader <miles@gnu.org>
parents:
61519
diff
changeset
|
1159 (enable-local-eval nil) |
11d53dd5abd9
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-345
Miles Bader <miles@gnu.org>
parents:
61519
diff
changeset
|
1160 (inhibit-file-name-operation (if inhibit |
11d53dd5abd9
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-345
Miles Bader <miles@gnu.org>
parents:
61519
diff
changeset
|
1161 'insert-file-contents |
11d53dd5abd9
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-345
Miles Bader <miles@gnu.org>
parents:
61519
diff
changeset
|
1162 inhibit-file-name-operation)) |
11d53dd5abd9
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-345
Miles Bader <miles@gnu.org>
parents:
61519
diff
changeset
|
1163 (inhibit-file-name-handlers |
11d53dd5abd9
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-345
Miles Bader <miles@gnu.org>
parents:
61519
diff
changeset
|
1164 (if inhibit |
11d53dd5abd9
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-345
Miles Bader <miles@gnu.org>
parents:
61519
diff
changeset
|
1165 (append mm-inhibit-file-name-handlers |
11d53dd5abd9
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-345
Miles Bader <miles@gnu.org>
parents:
61519
diff
changeset
|
1166 inhibit-file-name-handlers) |
11d53dd5abd9
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-345
Miles Bader <miles@gnu.org>
parents:
61519
diff
changeset
|
1167 inhibit-file-name-handlers)) |
11d53dd5abd9
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-345
Miles Bader <miles@gnu.org>
parents:
61519
diff
changeset
|
1168 (ffh (if (boundp 'find-file-hook) |
11d53dd5abd9
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-345
Miles Bader <miles@gnu.org>
parents:
61519
diff
changeset
|
1169 'find-file-hook |
11d53dd5abd9
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-345
Miles Bader <miles@gnu.org>
parents:
61519
diff
changeset
|
1170 'find-file-hooks)) |
11d53dd5abd9
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-345
Miles Bader <miles@gnu.org>
parents:
61519
diff
changeset
|
1171 (val (symbol-value ffh))) |
11d53dd5abd9
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-345
Miles Bader <miles@gnu.org>
parents:
61519
diff
changeset
|
1172 (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
|
1173 (unwind-protect |
11d53dd5abd9
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-345
Miles Bader <miles@gnu.org>
parents:
61519
diff
changeset
|
1174 (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
|
1175 (set ffh val)))) |
31717 | 1176 |
1177 (defun mm-append-to-file (start end filename &optional codesys inhibit) | |
1178 "Append the contents of the region to the end of file FILENAME. | |
1179 When called from a function, expects three arguments, | |
1180 START, END and FILENAME. START and END are buffer positions | |
1181 saying what text to write. | |
1182 Optional fourth argument specifies the coding system to use when | |
1183 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
|
1184 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
|
1185 (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
|
1186 (or codesys mm-text-coding-system-for-write |
31717 | 1187 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
|
1188 (inhibit-file-name-operation (if inhibit |
31717 | 1189 'append-to-file |
1190 inhibit-file-name-operation)) | |
1191 (inhibit-file-name-handlers | |
1192 (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
|
1193 (append mm-inhibit-file-name-handlers |
31717 | 1194 inhibit-file-name-handlers) |
1195 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
|
1196 (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
|
1197 (message "Appended to %s" filename))) |
31717 | 1198 |
40542
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
1199 (defun mm-write-region (start end filename &optional append visit lockname |
31717 | 1200 coding-system inhibit) |
1201 | |
1202 "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
|
1203 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
|
1204 (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
|
1205 (or coding-system mm-text-coding-system-for-write |
31717 | 1206 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
|
1207 (inhibit-file-name-operation (if inhibit |
31717 | 1208 'write-region |
1209 inhibit-file-name-operation)) | |
1210 (inhibit-file-name-handlers | |
1211 (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
|
1212 (append mm-inhibit-file-name-handlers |
31717 | 1213 inhibit-file-name-handlers) |
1214 inhibit-file-name-handlers))) | |
1215 (write-region start end filename append visit lockname))) | |
1216 | |
87241
4d24ed4358ae
Add declare-function compatibility definition.
Glenn Morris <rgm@gnu.org>
parents:
86154
diff
changeset
|
1217 (autoload 'gmm-write-region "gmm-utils") |
4d24ed4358ae
Add declare-function compatibility definition.
Glenn Morris <rgm@gnu.org>
parents:
86154
diff
changeset
|
1218 |
68940
808f636eb13e
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents:
68633
diff
changeset
|
1219 ;; 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
|
1220 (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
|
1221 (ignore-errors |
808f636eb13e
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents:
68633
diff
changeset
|
1222 (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
|
1223 (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
|
1224 (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
|
1225 ;; XEmacs |
808f636eb13e
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents:
68633
diff
changeset
|
1226 (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
|
1227 (aref def 0))) |
808f636eb13e
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents:
68633
diff
changeset
|
1228 (>= (length def) 4) |
808f636eb13e
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents:
68633
diff
changeset
|
1229 (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
|
1230 (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
|
1231 ;; 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
|
1232 (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
|
1233 "Create a temporary file. |
808f636eb13e
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents:
68633
diff
changeset
|
1234 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
|
1235 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
|
1236 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
|
1237 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
|
1238 |
808f636eb13e
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents:
68633
diff
changeset
|
1239 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
|
1240 |
808f636eb13e
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents:
68633
diff
changeset
|
1241 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
|
1242 (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
|
1243 file) |
808f636eb13e
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents:
68633
diff
changeset
|
1244 (unwind-protect |
808f636eb13e
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents:
68633
diff
changeset
|
1245 (progn |
808f636eb13e
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents:
68633
diff
changeset
|
1246 ;; 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
|
1247 ;; 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
|
1248 ;; 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
|
1249 (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
|
1250 (while (condition-case err |
808f636eb13e
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents:
68633
diff
changeset
|
1251 (progn |
808f636eb13e
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents:
68633
diff
changeset
|
1252 (setq file |
808f636eb13e
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents:
68633
diff
changeset
|
1253 (make-temp-name |
808f636eb13e
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents:
68633
diff
changeset
|
1254 (expand-file-name |
808f636eb13e
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents:
68633
diff
changeset
|
1255 prefix |
808f636eb13e
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents:
68633
diff
changeset
|
1256 (if (fboundp 'temp-directory) |
808f636eb13e
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents:
68633
diff
changeset
|
1257 ;; XEmacs |
808f636eb13e
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents:
68633
diff
changeset
|
1258 (temp-directory) |
808f636eb13e
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents:
68633
diff
changeset
|
1259 temporary-file-directory)))) |
808f636eb13e
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents:
68633
diff
changeset
|
1260 (if suffix |
808f636eb13e
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents:
68633
diff
changeset
|
1261 (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
|
1262 (if dir-flag |
808f636eb13e
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents:
68633
diff
changeset
|
1263 (make-directory file) |
73370 | 1264 ;; NOTE: This is unsafe if Emacs 20 |
1265 ;; users and XEmacs users don't use | |
1266 ;; a secure temp directory. | |
1267 (gmm-write-region "" nil file nil 'silent | |
1268 nil 'excl)) | |
68940
808f636eb13e
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents:
68633
diff
changeset
|
1269 nil) |
808f636eb13e
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents:
68633
diff
changeset
|
1270 (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
|
1271 ;; 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
|
1272 ;; `file-error'. |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
1273 (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
|
1274 (file-exists-p file)) |
808f636eb13e
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents:
68633
diff
changeset
|
1275 (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
|
1276 ;; 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
|
1277 ;; `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
|
1278 nil) |
808f636eb13e
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents:
68633
diff
changeset
|
1279 file) |
808f636eb13e
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents:
68633
diff
changeset
|
1280 ;; Reset the umask. |
808f636eb13e
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents:
68633
diff
changeset
|
1281 (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
|
1282 |
40542
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
1283 (defun mm-image-load-path (&optional package) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
1284 (let (dir result) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
1285 (dolist (path load-path (nreverse result)) |
57243
c5e16264557d
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-575
Miles Bader <miles@gnu.org>
parents:
57153
diff
changeset
|
1286 (when (and path |
c5e16264557d
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-575
Miles Bader <miles@gnu.org>
parents:
57153
diff
changeset
|
1287 (file-directory-p |
c5e16264557d
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-575
Miles Bader <miles@gnu.org>
parents:
57153
diff
changeset
|
1288 (setq dir (concat (file-name-directory |
c5e16264557d
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-575
Miles Bader <miles@gnu.org>
parents:
57153
diff
changeset
|
1289 (directory-file-name path)) |
60029
210af0ad3d35
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-96
Miles Bader <miles@gnu.org>
parents:
59089
diff
changeset
|
1290 "etc/images/" (or package "gnus/"))))) |
57243
c5e16264557d
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-575
Miles Bader <miles@gnu.org>
parents:
57153
diff
changeset
|
1291 (push dir result)) |
40542
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
1292 (push path result)))) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
39339
diff
changeset
|
1293 |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
53617
diff
changeset
|
1294 ;; 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
|
1295 (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
|
1296 (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
|
1297 "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
|
1298 (let ((coding-systems |
61434
6d07c19816b9
(mm-string-to-multibyte): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
61424
diff
changeset
|
1299 (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
|
1300 (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
|
1301 coding-systems))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
53617
diff
changeset
|
1302 (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
|
1303 (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
|
1304 (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
|
1305 (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
|
1306 (prog1 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
53617
diff
changeset
|
1307 (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
|
1308 (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
|
1309 |
87241
4d24ed4358ae
Add declare-function compatibility definition.
Glenn Morris <rgm@gnu.org>
parents:
86154
diff
changeset
|
1310 (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
|
1311 |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
53617
diff
changeset
|
1312 (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
|
1313 (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
|
1314 "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
|
1315 (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
|
1316 (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
|
1317 (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
|
1318 (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
|
1319 "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
|
1320 (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
|
1321 cs))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
53617
diff
changeset
|
1322 |
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
1323 (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
|
1324 (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
|
1325 (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
|
1326 |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
1327 (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
|
1328 "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
|
1329 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
|
1330 (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
|
1331 (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
|
1332 (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
|
1333 (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
|
1334 (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
|
1335 (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
|
1336 (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
|
1337 'ignore))) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
1338 (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
|
1339 (require 'mcharset) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
1340 (error nil)) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
1341 (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
|
1342 (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
|
1343 |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
1344 (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
|
1345 (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
|
1346 |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
1347 (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
|
1348 "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
|
1349 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
|
1350 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
|
1351 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
|
1352 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
|
1353 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
|
1354 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
|
1355 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
|
1356 (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
|
1357 (if force |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
1358 (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
|
1359 (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
|
1360 (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
|
1361 (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
|
1362 (when info |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
1363 (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
|
1364 (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
|
1365 (error "")) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
1366 (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
|
1367 (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
|
1368 (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
|
1369 (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
|
1370 filename)) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
1371 (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
|
1372 (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
|
1373 (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
|
1374 (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
|
1375 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
|
1376 (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
|
1377 (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
|
1378 (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
|
1379 (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
|
1380 (progn |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
1381 (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
|
1382 (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
|
1383 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
|
1384 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
|
1385 (erase-buffer) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
1386 (insert (mapconcat |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
1387 'identity |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
1388 (delete "" (split-string |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
1389 (prog2 |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
1390 (insert-file-contents err-file) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
1391 (buffer-string) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
1392 (erase-buffer)))) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
1393 " ") |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
1394 "\n") |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
1395 (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
|
1396 (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
|
1397 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
|
1398 filename))) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
1399 (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
|
1400 (error |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
1401 (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
|
1402 (when (file-exists-p err-file) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
1403 (ignore-errors (jka-compr-delete-temp-file err-file))) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
1404 (when inplace |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
1405 (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
|
1406 (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
|
1407 (insert retval)) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
1408 (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
|
1409 (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
|
1410 retval))))) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
1411 |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
1412 (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
|
1413 (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
|
1414 (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
|
1415 (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
|
1416 (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
|
1417 (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
|
1418 (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
|
1419 |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
1420 (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
|
1421 "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
|
1422 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
|
1423 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
|
1424 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
|
1425 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
|
1426 (unless filename |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
1427 (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
|
1428 (save-excursion |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
1429 (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
|
1430 (and filename |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
1431 (string-match |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
1432 "\\.\\(?: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
|
1433 filename)) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
1434 (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
|
1435 (when decomp |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
1436 (set-buffer (let (default-enable-multibyte-characters) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
1437 (generate-new-buffer " *temp*"))) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
1438 (insert decomp) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
1439 (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
|
1440 (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
|
1441 (prog1 |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
1442 (cond |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
1443 ((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
|
1444 (if filename |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
1445 (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
|
1446 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
|
1447 (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
|
1448 filename))) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
1449 (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
|
1450 (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
|
1451 (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
|
1452 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
|
1453 (error nil))))) |
86154 | 1454 ((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
|
1455 (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
|
1456 (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
|
1457 codesys start) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
1458 (or |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
1459 (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
|
1460 (progn |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
1461 (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
|
1462 (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
|
1463 (progn |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
1464 (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
|
1465 (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
|
1466 (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
|
1467 (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
|
1468 "[\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
|
1469 end t))) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
1470 (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
|
1471 (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
|
1472 codesys) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
1473 (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
|
1474 nil t) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
1475 (progn |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
1476 (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
|
1477 (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
|
1478 (progn |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
1479 (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
|
1480 (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
|
1481 (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
|
1482 "^[\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
|
1483 end t)) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
1484 (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
|
1485 (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
|
1486 codesys) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
1487 (and (progn |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
1488 (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
|
1489 (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
|
1490 (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
|
1491 ;;(+ (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
|
1492 nil t)) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
1493 (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
|
1494 (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
|
1495 (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
|
1496 codesys) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
1497 (and filename |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
1498 (setq codesys |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
1499 (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
|
1500 filename)) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
1501 (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
|
1502 (when decomp |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
79022
diff
changeset
|
1503 (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
|
1504 |
31717 | 1505 (provide 'mm-util) |
1506 | |
61434
6d07c19816b9
(mm-string-to-multibyte): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
61424
diff
changeset
|
1507 ;; arch-tag: 94dc5388-825d-4fd1-bfa5-2100aa351238 |
31717 | 1508 ;;; mm-util.el ends here |