1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
|
--- apel-10.8-orig/ChangeLog 2013-10-03 18:17:05.176741628 +1000
+++ apel-10.8/ChangeLog 2013-10-03 18:16:54.442741731 +1000
@@ -1,3 +1,56 @@
+2013-07-05 Tatsuya Kinoshita <tats@vega.ocn.ne.jp>
+
+ * mcs-20.el: Really check whether the mule-vesion variable is defined.
+
+2013-07-04 Kazuhiro Ito <kzhr@d1.dion.ne.jp>
+
+ * mcs-20.el: Check whether the mule-vesion variable is defined.
+ Cf. https://github.com/ikazuhiro/apel/commit/328c02e022340b36dd7e5f9250c7f86d2bafd793
+
+2013-03-24 Kazuhiro Ito <kzhr@d1.dion.ne.jp>
+
+ * mcs-20.el (mime-charset-to-coding-system): Display the message
+ and use charset name as coding system when
+ `mime-charset-coding-system-alist' indicates invalid coding
+ system.
+
+2012-09-07 Kazuhiro Ito <kzhr@d1.dion.ne.jp>
+
+ * mcs-e20.el (coding-system-to-mime-charset): Coding system's
+ setting is preferred to mime-charset-coding-system-alist's value.
+ Detect MIME name from mime-charset-coding-system-alist's value
+ more permissively.
+
+2012-08-08 Kazuhiro Ito <kzhr@d1.dion.ne.jp>
+
+ * poe.el (next-command-event): Fix that Emacs 21 and later were
+ treated as 'Emacs 19, 20.1 and 20.2'.
+
+2012-07-28 Kazuhiro Ito <kzhr@d1.dion.ne.jp>
+
+ * mcs-e20.el (charsets-mime-charset-alist): Do not use
+ `iso-2022-jp-2'.
+
+2012-07-28 Kazuhiro Ito <kzhr@d1.dion.ne.jp>
+
+ * mcs-20.el (detect-mime-charset-string): (Emacs23 and later) New
+ function.
+ (detect-mime-charset-region): Use it.
+
+2011-06-17 Kazuhiro Ito <kzhr@d1.dion.ne.jp>
+
+ * mcs-20.el (detect-mime-charset-region): (Emacs23 and later) Do
+ not check whether `charsets-mime-charset-alist' contains non
+ charset symbol.
+
+ * mcs-e20.el (charsets-mime-charset-alist): Remove non charset
+ symbol for Emacs 23 and later.
+
+2010-03-19 Kazuhiro Ito <kzhr@d1.dion.ne.jp>
+
+ * mcs-20.el (detect-mime-charset-region): Do not care priority of
+ charsets on Emacs 23 and later.
+
2011-07-17 David Maus <dmaus@ictsoc.de>
* tinycustom.el (defcustom): Use new style backquotes.
--- apel-10.8-orig/mcs-20.el 2005-07-06 12:08:52.000000000 +1000
+++ apel-10.8/mcs-20.el 2013-10-03 17:44:42.936760151 +1000
@@ -84,11 +84,13 @@
(if (stringp charset)
(setq charset (intern (downcase charset)))
)
- (let ((cs (assq charset mime-charset-coding-system-alist)))
- (setq cs
- (if cs
- (cdr cs)
- charset))
+ (let ((cs (cdr (assq charset mime-charset-coding-system-alist))))
+ (unless (or (null cs) (find-coding-system cs))
+ (message
+ "Invalid coding system: %s. Confirm mime-charset-coding-system-alist."
+ cs)
+ (setq cs nil))
+ (unless cs (setq cs charset))
(if lbt
(setq cs (intern (format "%s-%s" cs
(cond ((eq lbt 'CRLF) 'dos)
@@ -96,12 +98,11 @@
((eq lbt 'CR) 'mac)
(t lbt)))))
)
- (if (find-coding-system cs)
- cs
- (if mime-charset-to-coding-system-default-method
- (funcall mime-charset-to-coding-system-default-method
- charset lbt cs)
- ))))
+ (or (find-coding-system cs)
+ (if mime-charset-to-coding-system-default-method
+ (funcall mime-charset-to-coding-system-default-method
+ charset lbt cs)
+ ))))
(defalias 'mime-charset-p 'mime-charset-to-coding-system)
@@ -209,6 +210,34 @@
(setq rest (cdr rest)))
default-mime-charset-for-write)))
)
+
+((eval-when-compile (and (boundp 'mule-version)
+ (null (string< mule-version "6.0"))))
+;; for Emacs 23 and later
+(defun detect-mime-charset-string (string)
+ "Return MIME charset for STRING."
+ (let ((src (string-to-list string))
+ tmp)
+ (setq tmp src)
+ ;; Uniquify the list of characters.
+ (while tmp
+ (setq tmp (setcdr tmp (delq (car tmp) (cdr tmp)))))
+ ;; Detect charset from the list of characters.
+ (catch 'found
+ (mapc (lambda (cons)
+ (catch 'next
+ (mapc (lambda (ch) (unless (char-charset ch (car cons))
+ (throw 'next nil)))
+ src)
+ (throw 'found (cdr cons))))
+ charsets-mime-charset-alist)
+ default-mime-charset-for-write)))
+
+(defsubst detect-mime-charset-region (start end)
+ "Return MIME charset for region between START and END."
+ (detect-mime-charset-string
+ (buffer-substring-no-properties start end))))
+
(t
;; for legacy Mule
(defun detect-mime-charset-region (start end)
--- apel-10.8-orig/mcs-e20.el 2005-07-06 12:08:52.000000000 +1000
+++ apel-10.8/mcs-e20.el 2013-10-03 17:44:42.936760151 +1000
@@ -90,11 +90,15 @@
((ascii korean-ksc5601) . euc-kr)
((ascii chinese-gb2312) . gb2312)
((ascii chinese-big5-1 chinese-big5-2) . big5)
- ((ascii thai-tis620 composition) . tis-620)
- ((ascii latin-iso8859-1 greek-iso8859-7
- latin-jisx0201 japanese-jisx0208-1978
- chinese-gb2312 japanese-jisx0208
- korean-ksc5601 japanese-jisx0212) . iso-2022-jp-2)
+ ,(static-cond
+ ((null (string< mule-version "6.0"))
+ '((ascii thai-tis620) . tis-620))
+ (t
+ '((ascii thai-tis620 composition) . tis-620)))
+ ;; ((ascii latin-iso8859-1 greek-iso8859-7
+ ;; latin-jisx0201 japanese-jisx0208-1978
+ ;; chinese-gb2312 japanese-jisx0208
+ ;; korean-ksc5601 japanese-jisx0212) . iso-2022-jp-2)
;;((ascii latin-iso8859-1 greek-iso8859-7
;; latin-jisx0201 japanese-jisx0208-1978
;; chinese-gb2312 japanese-jisx0208
@@ -119,8 +123,16 @@
(defun coding-system-to-mime-charset (coding-system)
"Convert CODING-SYSTEM to a MIME-charset.
Return nil if corresponding MIME-charset is not found."
- (or (car (rassq coding-system mime-charset-coding-system-alist))
- (coding-system-get coding-system 'mime-charset)
+ (or (coding-system-get coding-system 'mime-charset)
+ (let ((coding (coding-system-base coding-system))
+ (alist mime-charset-coding-system-alist)
+ result)
+ (while alist
+ (if (eq (coding-system-base (cdar alist)) coding)
+ (setq result (caar alist)
+ alist nil)
+ (setq alist (cdr alist))))
+ result)
))
(defun-maybe-cond mime-charset-list ()
--- apel-10.8-orig/poe.el 2013-10-03 17:43:11.327761025 +1000
+++ apel-10.8/poe.el 2013-10-03 17:44:42.937760151 +1000
@@ -1996,8 +1996,9 @@
returned.
If PROMPT is non-nil, it should be a string and will be displayed in
the echo area while this function is waiting for an event."
- ((and (>= emacs-major-version 20)
- (>= emacs-minor-version 4))
+ ((or (>= emacs-major-version 21)
+ (and (>= emacs-major-version 20)
+ (>= emacs-minor-version 4)))
;; Emacs 20.4 and later.
(read-event prompt)) ; should specify 2nd arg?
((and (= emacs-major-version 20)
|