comparison lisp/international/mule-util.el @ 20113:00ca5f419c16

(coding-system-base): Moved to mule.el. (coding-system-post-read-conversion): Use the new function coding-system-get. (coding-system-pre-write-conversion): Likewise. (coding-system-unification-table-for-decode): Likewise. (coding-system-unification-table-for-encode): Likewise. (coding-system-list): Adjusted for the change in mule.el. (coding-system-plist): Deleted. (coding-system-equal): Do not use coding-system-plist.
author Kenichi Handa <handa@m17n.org>
date Tue, 21 Oct 1997 10:47:35 +0000
parents 2dce5db7cf82
children dc6f12ef4d47
comparison
equal deleted inserted replaced
20112:6e6838a12511 20113:00ca5f419c16
209 209
210 210
211 ;; Coding system related functions. 211 ;; Coding system related functions.
212 212
213 ;;;###autoload 213 ;;;###autoload
214 (defun coding-system-base (coding-system)
215 "Return a base of CODING-SYSTEM.
216 The base is a coding system of which coding-system property is a
217 coding-spec (see the function `make-coding-system')."
218 (let ((coding-spec (get coding-system 'coding-system)))
219 (if (vectorp coding-spec)
220 coding-system
221 (coding-system-base coding-spec))))
222
223 ;;;###autoload
224 (defun coding-system-eol-type-mnemonic (coding-system) 214 (defun coding-system-eol-type-mnemonic (coding-system)
225 "Return mnemonic letter of eol-type of CODING-SYSTEM." 215 "Return mnemonic letter of eol-type of CODING-SYSTEM."
226 (let ((eol-type (coding-system-eol-type coding-system))) 216 (let ((eol-type (coding-system-eol-type coding-system)))
227 (cond ((vectorp eol-type) eol-mnemonic-undecided) 217 (cond ((vectorp eol-type) eol-mnemonic-undecided)
228 ((eq eol-type 0) eol-mnemonic-unix) 218 ((eq eol-type 0) eol-mnemonic-unix)
230 ((eq eol-type 2) eol-mnemonic-unix) 220 ((eq eol-type 2) eol-mnemonic-unix)
231 (t ?-)))) 221 (t ?-))))
232 222
233 ;;;###autoload 223 ;;;###autoload
234 (defun coding-system-post-read-conversion (coding-system) 224 (defun coding-system-post-read-conversion (coding-system)
235 "Return post-read-conversion property of CODING-SYSTEM." 225 "Return the value of CODING-SYSTEM's post-read-conversion property."
236 (and coding-system 226 (coding-system-get coding-system 'post-read-conversion))
237 (symbolp coding-system)
238 (or (get coding-system 'post-read-conversion)
239 (coding-system-post-read-conversion
240 (get coding-system 'coding-system)))))
241 227
242 ;;;###autoload 228 ;;;###autoload
243 (defun coding-system-pre-write-conversion (coding-system) 229 (defun coding-system-pre-write-conversion (coding-system)
244 "Return pre-write-conversion property of CODING-SYSTEM." 230 "Return the value of CODING-SYSTEM's pre-write-conversion property."
245 (and coding-system 231 (coding-system-get coding-system 'pre-write-conversion))
246 (symbolp coding-system)
247 (or (get coding-system 'pre-write-conversion)
248 (coding-system-pre-write-conversion
249 (get coding-system 'coding-system)))))
250 232
251 ;;;###autoload 233 ;;;###autoload
252 (defun coding-system-unification-table-for-decode (coding-system) 234 (defun coding-system-unification-table-for-decode (coding-system)
253 "Return unification-table-for-decode property of CODING-SYSTEM." 235 "Return the value of CODING-SYSTEM's unification-table-for-decode property."
254 (and coding-system 236 (coding-system-get coding-system 'character-unification-table-for-decode))
255 (symbolp coding-system)
256 (or (get coding-system 'unification-table-for-decode)
257 (coding-system-unification-table-for-decode
258 (get coding-system 'coding-system)))))
259 237
260 ;;;###autoload 238 ;;;###autoload
261 (defun coding-system-unification-table-for-encode (coding-system) 239 (defun coding-system-unification-table-for-encode (coding-system)
262 "Return unification-table-for-encode property of CODING-SYSTEM." 240 "Return the value of CODING-SYSTEM's unification-table-for-encode property."
263 (and coding-system 241 (coding-system-get coding-system 'character-unification-table-for-encode))
264 (symbolp coding-system)
265 (or (get coding-system 'unification-table-for-encode)
266 (coding-system-unification-table-for-encode
267 (get coding-system 'coding-system)))))
268 242
269 (defun coding-system-lessp (x y) 243 (defun coding-system-lessp (x y)
270 (cond ((eq x 'no-conversion) t) 244 (cond ((eq x 'no-conversion) t)
271 ((eq y 'no-conversion) nil) 245 ((eq y 'no-conversion) nil)
272 ((eq x 'emacs-mule) t) 246 ((eq x 'emacs-mule) t)
281 255
282 ;;;###autoload 256 ;;;###autoload
283 (defun coding-system-list (&optional base-only) 257 (defun coding-system-list (&optional base-only)
284 "Return a list of all existing coding systems. 258 "Return a list of all existing coding systems.
285 If optional arg BASE-ONLY is non-nil, only base coding systems are listed." 259 If optional arg BASE-ONLY is non-nil, only base coding systems are listed."
286 (let (l) 260 (let* ((codings (sort (copy-sequence coding-system-list)
287 (mapatoms (lambda (x) (if (get x 'coding-system) (setq l (cons x l))))) 261 'coding-system-lessp))
288 (let* ((codings (sort l 'coding-system-lessp)) 262 (tail (cons nil codings)))
289 (tail (cons nil codings)) 263 ;; Remove subsidiary coding systems (eol variants) and alias
290 coding) 264 ;; coding systems (if necessary).
291 ;; At first, remove subsidiary coding systems (eol variants) and 265 (while (cdr tail)
292 ;; alias coding systems (if necessary). 266 (let* ((coding (car (cdr tail)))
293 (while (cdr tail) 267 (aliases (coding-system-get coding 'alias-coding-systems)))
294 (setq coding (car (cdr tail))) 268 (if (or
295 (if (or (get coding 'eol-variant) 269 ;; CODING is an eol varinant if not in ALIASES.
296 (and base-only (coding-system-parent coding))) 270 (not (memq coding aliases))
271 ;; CODING is an alias if it is not car of ALISES.
272 (and base-only (not (eq coding (car aliases)))))
297 (setcdr tail (cdr (cdr tail))) 273 (setcdr tail (cdr (cdr tail)))
298 (setq tail (cdr tail)))) 274 (setq tail (cdr tail)))))
299 codings))) 275 codings))
300
301 ;;;###autoload
302 (defun coding-system-plist (coding-system)
303 "Return property list of CODING-SYSTEM."
304 (let ((found nil)
305 coding-spec eol-type
306 post-read-conversion pre-write-conversion
307 unification-table)
308 (while (not found)
309 (or eol-type
310 (setq eol-type (get coding-system 'eol-type)))
311 (or post-read-conversion
312 (setq post-read-conversion
313 (get coding-system 'post-read-conversion)))
314 (or pre-write-conversion
315 (setq pre-write-conversion
316 (get coding-system 'pre-write-conversion)))
317 (or unification-table
318 (setq unification-table
319 (get coding-system 'unification-table)))
320 (setq coding-spec (get coding-system 'coding-system))
321 (if (and coding-spec (symbolp coding-spec))
322 (setq coding-system coding-spec)
323 (setq found t)))
324 (if (not coding-spec)
325 (error "Invalid coding system: %s" coding-system))
326 (list 'coding-spec coding-spec
327 'eol-type eol-type
328 'post-read-conversion post-read-conversion
329 'pre-write-conversion pre-write-conversion
330 'unification-table unification-table)))
331 276
332 ;;;###autoload 277 ;;;###autoload
333 (defun coding-system-equal (coding-system-1 coding-system-2) 278 (defun coding-system-equal (coding-system-1 coding-system-2)
334 "Return t if and only if CODING-SYSTEM-1 and CODING-SYSTEM-2 are identical. 279 "Return t if and only if CODING-SYSTEM-1 and CODING-SYSTEM-2 are identical.
335 Two coding systems are identical if two symbols are equal 280 Two coding systems are identical if two symbols are equal
336 or one is an alias of the other." 281 or one is an alias of the other."
337 (or (eq coding-system-1 coding-system-2) 282 (or (eq coding-system-1 coding-system-2)
338 (equal (coding-system-plist coding-system-1) 283 (and (equal (coding-system-spec coding-system-1)
339 (coding-system-plist coding-system-2)))) 284 (coding-system-spec coding-system-2))
285 (let ((eol-type-1 (coding-system-eol-type coding-system-1))
286 (eol-type-2 (coding-system-eol-type coding-system-2)))
287 (or (eq eol-type-1 eol-type-2)
288 (and (vectorp eol-type-1) (vectorp eol-type-2)))))))
340 289
341 290
342 ;;; Composite charcater manipulations. 291 ;;; Composite charcater manipulations.
343 292
344 ;;;###autoload 293 ;;;###autoload