comparison lisp/coding.el @ 771:943eaba38521

[xemacs-hg @ 2002-03-13 08:51:24 by ben] The big ben-mule-21-5 check-in! Various files were added and deleted. See CHANGES-ben-mule. There are still some test suite failures. No crashes, though. Many of the failures have to do with problems in the test suite itself rather than in the actual code. I'll be addressing these in the next day or so -- none of the test suite failures are at all critical. Meanwhile I'll be trying to address the biggest issues -- i.e. build or run failures, which will almost certainly happen on various platforms. All comments should be sent to ben@xemacs.org -- use a Cc: if necessary when sending to mailing lists. There will be pre- and post- tags, something like pre-ben-mule-21-5-merge-in, and post-ben-mule-21-5-merge-in.
author ben
date Wed, 13 Mar 2002 08:54:06 +0000
parents 4d00488244c1
children 7f62a956b825
comparison
equal deleted inserted replaced
770:336a418893b5 771:943eaba38521
3 ;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN. 3 ;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN.
4 ;; Licensed to the Free Software Foundation. 4 ;; Licensed to the Free Software Foundation.
5 ;; Copyright (C) 1995 Amdahl Corporation. 5 ;; Copyright (C) 1995 Amdahl Corporation.
6 ;; Copyright (C) 1995 Sun Microsystems. 6 ;; Copyright (C) 1995 Sun Microsystems.
7 ;; Copyright (C) 1997 MORIOKA Tomohiko 7 ;; Copyright (C) 1997 MORIOKA Tomohiko
8 ;; Copyright (C) 2000, 2001, 2002 Ben Wing.
8 9
9 ;; This file is part of XEmacs. 10 ;; This file is part of XEmacs.
10
11 ;; This file is very similar to mule-coding.el
12 11
13 ;; XEmacs is free software; you can redistribute it and/or modify it 12 ;; XEmacs is free software; you can redistribute it and/or modify it
14 ;; under the terms of the GNU General Public License as published by 13 ;; under the terms of the GNU General Public License as published by
15 ;; the Free Software Foundation; either version 2, or (at your option) 14 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; any later version. 15 ;; any later version.
34 (globally-declare-fboundp 33 (globally-declare-fboundp
35 '(coding-system-lock-shift 34 '(coding-system-lock-shift
36 coding-system-seven coding-system-charset charset-dimension)) 35 coding-system-seven coding-system-charset charset-dimension))
37 36
38 (defalias 'check-coding-system 'get-coding-system) 37 (defalias 'check-coding-system 'get-coding-system)
39
40 (defconst modeline-multibyte-status '("%C")
41 "Modeline control for showing multibyte extension status.")
42
43 ;; override the default value defined in loaddefs.el.
44 (setq-default modeline-format
45 (cons ""
46 (cons 'modeline-multibyte-status
47 (cdr modeline-format))))
48 38
49 (defun modify-coding-system-alist (target-type regexp coding-system) 39 (defun modify-coding-system-alist (target-type regexp coding-system)
50 "Modify one of look up tables for finding a coding system on I/O operation. 40 "Modify one of look up tables for finding a coding system on I/O operation.
51 There are three of such tables, `file-coding-system-alist', 41 There are three of such tables, `file-coding-system-alist',
52 `process-coding-system-alist', and `network-coding-system-alist'. 42 `process-coding-system-alist', and `network-coding-system-alist'.
126 (if (eq (device-type) 'tty) 116 (if (eq (device-type) 'tty)
127 (declare-fboundp (set-console-tty-output-coding-system 117 (declare-fboundp (set-console-tty-output-coding-system
128 (device-console) terminal-coding-system))) 118 (device-console) terminal-coding-system)))
129 (redraw-modeline t)) 119 (redraw-modeline t))
130 120
131 (defun set-pathname-coding-system (coding-system)
132 "Set the coding system used for file system path names."
133 (interactive "zPathname-coding-system: ")
134 (get-coding-system coding-system) ; correctness check
135 (setq file-name-coding-system coding-system))
136
137 (defun what-coding-system (start end &optional arg) 121 (defun what-coding-system (start end &optional arg)
138 "Show the encoding of text in the region. 122 "Show the encoding of text in the region.
139 This function is meant to be called interactively; 123 This function is meant to be called interactively;
140 from a Lisp program, use `detect-coding-region' instead." 124 from a Lisp program, use `detect-coding-region' instead."
141 (interactive "r\nP") 125 (interactive "r\nP")
158 142
159 (defun coding-system-mnemonic (coding-system) 143 (defun coding-system-mnemonic (coding-system)
160 "Return the 'mnemonic property of CODING-SYSTEM." 144 "Return the 'mnemonic property of CODING-SYSTEM."
161 (coding-system-property coding-system 'mnemonic)) 145 (coding-system-property coding-system 'mnemonic))
162 146
163 (defalias 'coding-system-docstring 'coding-system-doc-string) 147 (defun coding-system-documentation (coding-system)
148 "Return the 'documentation property of CODING-SYSTEM."
149 (coding-system-property coding-system 'documentation))
150
151 (define-obsolete-function-alias 'coding-system-doc-string
152 'coding-system-description)
164 153
165 (defun coding-system-eol-type (coding-system) 154 (defun coding-system-eol-type (coding-system)
166 "Return the 'eol-type property of CODING-SYSTEM." 155 "Return the 'eol-type property of CODING-SYSTEM."
167 (coding-system-property coding-system 'eol-type)) 156 (coding-system-property coding-system 'eol-type))
168 157
183 (coding-system-property coding-system 'post-read-conversion)) 172 (coding-system-property coding-system 'post-read-conversion))
184 173
185 (defun coding-system-pre-write-conversion (coding-system) 174 (defun coding-system-pre-write-conversion (coding-system)
186 "Return the 'pre-write-conversion property of CODING-SYSTEM." 175 "Return the 'pre-write-conversion property of CODING-SYSTEM."
187 (coding-system-property coding-system 'pre-write-conversion)) 176 (coding-system-property coding-system 'pre-write-conversion))
188
189 (defun coding-system-base (coding-system)
190 "Return the base coding system of CODING-SYSTEM."
191 (if (not (coding-system-eol-type coding-system))
192 coding-system
193 (find-coding-system
194 (intern
195 (substring
196 (symbol-name (coding-system-name coding-system))
197 0
198 (string-match "-unix$\\|-dos$\\|-mac$"
199 (symbol-name (coding-system-name coding-system))))))))
200
201 177
202 ;;; #### bleagh!!!!!!! 178 ;;; #### bleagh!!!!!!!
203 179
204 (defun coding-system-get (coding-system prop) 180 (defun coding-system-get (coding-system prop)
205 "Extract a value from CODING-SYSTEM's property list for property PROP." 181 "Extract a value from CODING-SYSTEM's property list for property PROP."
219 prop value))) 195 prop value)))
220 196
221 (defun coding-system-category (coding-system) 197 (defun coding-system-category (coding-system)
222 "Return the coding category of CODING-SYSTEM." 198 "Return the coding category of CODING-SYSTEM."
223 (or (coding-system-get coding-system 'category) 199 (or (coding-system-get coding-system 'category)
224 (let ((type (coding-system-type coding-system))) 200 (case (coding-system-type coding-system)
225 (cond ((eq type 'no-conversion) 201 (no-conversion 'no-conversion)
226 'no-conversion) 202 (shift-jis 'shift-jis)
227 ((eq type 'shift-jis) 203 (unicode (case (coding-system-property coding-system 'type)
228 'shift-jis) 204 (utf-8 'utf-8)
229 ((eq type 'ucs-4) 205 (ucs-4 'ucs-4)
230 'ucs-4) 206 (utf-16 (let ((bom (coding-system-property coding-system
231 ((eq type 'utf-8) 207 'need-bom))
232 'utf-8) 208 (le (coding-system-property coding-system
233 ((eq type 'big5) 209 'little-endian)))
234 'big5) 210 (cond ((and bom le) 'utf-16-little-endian-bom)
235 ((eq type 'iso2022) 211 ((and bom (not le) 'utf-16-bom))
236 (cond ((coding-system-lock-shift coding-system) 212 ((and (not bom) le) 'utf-16-little-endian)
237 'iso-lock-shift) 213 ((and (not bom) (not le) 'utf-16)))))))
238 ((coding-system-seven coding-system) 214 (big5 'big5)
239 'iso-7) 215 (iso2022 (cond ((coding-system-lock-shift coding-system)
240 (t 216 'iso-lock-shift)
241 (let ((dim 0) 217 ((coding-system-seven coding-system)
242 ccs 218 'iso-7)
243 (i 0)) 219 (t
244 (while (< i 4) 220 (let ((dim 0)
245 (setq ccs (coding-system-charset coding-system i)) 221 ccs
246 (if (and ccs 222 (i 0))
247 (> (charset-dimension ccs) dim)) 223 (while (< i 4)
248 (setq dim (charset-dimension ccs)) 224 (setq ccs (declare-fboundp
249 ) 225 (coding-system-iso2022-charset
250 (setq i (1+ i))) 226 coding-system i)))
251 (cond ((= dim 1) 'iso-8-1) 227 (if (and ccs
252 ((= dim 2) 'iso-8-2) 228 (> (charset-dimension ccs) dim))
253 (t 'iso-8-designate)) 229 (setq dim (charset-dimension ccs))
254 )))))))) 230 )
231 (setq i (1+ i)))
232 (cond ((= dim 1) 'iso-8-1)
233 ((= dim 2) 'iso-8-2)
234 (t 'iso-8-designate))))))
235 )))
255 236
256 237
257 ;;;; Definitions of predefined coding systems
258
259 (make-coding-system
260 'undecided 'undecided
261 "Automatic conversion."
262 '(mnemonic "Auto"))
263
264 ;;; Make certain variables equivalent to coding-system aliases 238 ;;; Make certain variables equivalent to coding-system aliases
265 (defun dontusethis-set-value-file-name-coding-system-handler (sym args fun harg handlers) 239 (defun dontusethis-set-value-file-name-coding-system-handler (sym args fun harg handlers)
266 (define-coding-system-alias 'file-name (or (car args) 'binary))) 240 (define-coding-system-alias 'file-name (or (car args) 'binary)))
267 241
268 (dontusethis-set-symbol-value-handler 242 (dontusethis-set-symbol-value-handler
284 (dontusethis-set-symbol-value-handler 258 (dontusethis-set-symbol-value-handler
285 'keyboard-coding-system 259 'keyboard-coding-system
286 'set-value 260 'set-value
287 'dontusethis-set-value-keyboard-coding-system-handler) 261 'dontusethis-set-value-keyboard-coding-system-handler)
288 262
289 (unless (boundp 'file-name-coding-system)
290 (setq file-name-coding-system nil))
291
292 (when (not (featurep 'mule)) 263 (when (not (featurep 'mule))
264 (define-coding-system-alias 'escape-quoted 'binary)
293 ;; these are so that gnus and friends work when not mule 265 ;; these are so that gnus and friends work when not mule
294 (copy-coding-system 'undecided 'iso-8859-1) 266 (define-coding-system-alias 'iso-8859-1 'undecided)
295 (copy-coding-system 'undecided 'iso-8859-2) 267 (define-coding-system-alias 'iso-8859-2 'undecided)
296
297 (define-coding-system-alias 'ctext 'binary)) 268 (define-coding-system-alias 'ctext 'binary))
298 269
299 270
300 ;; compatibility for old XEmacsen (don't use it) 271 ;; compatibility for old XEmacsen (don't use it)
301 (copy-coding-system 'undecided 'automatic-conversion) 272 (define-coding-system-alias 'automatic-conversion 'undecided)
302 273
303 (make-compatible-variable 'enable-multibyte-characters "Unimplemented") 274 (make-compatible-variable 'enable-multibyte-characters "Unimplemented")
304 275
305 (define-obsolete-variable-alias
306 'pathname-coding-system 'file-name-coding-system)
307
308 ;;; coding.el ends here 276 ;;; coding.el ends here