]> code.delx.au - gnu-emacs/blob - lisp/international/mule-diag.el
Merge from emacs--devo--0
[gnu-emacs] / lisp / international / mule-diag.el
1 ;;; mule-diag.el --- show diagnosis of multilingual environment (Mule)
2
3 ;; Copyright (C) 1997, 1998, 2000, 2001, 2002, 2003, 2004,
4 ;; 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
5 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
6 ;; 2005, 2006, 2007, 2008
7 ;; National Institute of Advanced Industrial Science and Technology (AIST)
8 ;; Registration Number H14PRO021
9 ;; Copyright (C) 2003
10 ;; National Institute of Advanced Industrial Science and Technology (AIST)
11 ;; Registration Number H13PRO009
12
13 ;; Keywords: multilingual, charset, coding system, fontset, diagnosis, i18n
14
15 ;; This file is part of GNU Emacs.
16
17 ;; GNU Emacs is free software; you can redistribute it and/or modify
18 ;; it under the terms of the GNU General Public License as published by
19 ;; the Free Software Foundation; either version 3, or (at your option)
20 ;; any later version.
21
22 ;; GNU Emacs is distributed in the hope that it will be useful,
23 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
24 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 ;; GNU General Public License for more details.
26
27 ;; You should have received a copy of the GNU General Public License
28 ;; along with GNU Emacs; see the file COPYING. If not, write to the
29 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
30 ;; Boston, MA 02110-1301, USA.
31
32 ;;; Commentary:
33
34 ;;; Code:
35
36 ;; Make sure the help-xref button type is defined.
37 (require 'help-fns)
38
39 ;;; General utility function
40
41 (defun print-list (&rest args)
42 "Print all arguments with single space separator in one line."
43 (while (cdr args)
44 (when (car args)
45 (princ (car args))
46 (princ " "))
47 (setq args (cdr args)))
48 (princ (car args))
49 (princ "\n"))
50
51 ;;; CHARSET
52
53 (define-button-type 'sort-listed-character-sets
54 'help-echo (purecopy "mouse-2, RET: sort on this column")
55 'face 'bold
56 'action #'(lambda (button)
57 (sort-listed-character-sets (button-get button 'sort-key))))
58
59 (define-button-type 'list-charset-chars
60 :supertype 'help-xref
61 'help-function #'list-charset-chars
62 'help-echo "mouse-2, RET: show table of characters for this character set")
63
64 ;;;###autoload
65 (defun list-character-sets (arg)
66 "Display a list of all character sets.
67
68 The D column contains the dimension of this character set. The CH
69 column contains the number of characters in a block of this character
70 set. The FINAL-CHAR column contains an ISO-2022 <final-char> to use
71 for designating this character set in ISO-2022-based coding systems.
72
73 With prefix arg, the output format gets more cryptic,
74 but still shows the full information."
75 (interactive "P")
76 (help-setup-xref (list #'list-character-sets arg) (interactive-p))
77 (with-output-to-temp-buffer "*Character Set List*"
78 (with-current-buffer standard-output
79 (if arg
80 (list-character-sets-2)
81 ;; Insert header.
82 (insert "Supplementary character sets are shown below.\n")
83 (insert
84 (substitute-command-keys
85 (concat "Use "
86 (if (display-mouse-p) "\\[help-follow-mouse] or ")
87 "\\[help-follow]:\n")))
88 (insert " on a column title to sort by that title,")
89 (indent-to 48)
90 (insert "+----DIMENSION\n")
91 (insert " on a charset name to list characters.")
92 (indent-to 48)
93 (insert "| +--CHARS\n")
94 (let ((columns '(("CHARSET-NAME" . name) "\t\t\t\t\t"
95 ("D CH FINAL-CHAR" . iso-spec)))
96 pos)
97 (while columns
98 (if (stringp (car columns))
99 (insert (car columns))
100 (insert-text-button (car (car columns))
101 :type 'sort-listed-character-sets
102 'sort-key (cdr (car columns)))
103 (goto-char (point-max)))
104 (setq columns (cdr columns)))
105 (insert "\n"))
106 (insert "------------\t\t\t\t\t- --- ----------\n")
107
108 ;; Insert body sorted by charset IDs.
109 (list-character-sets-1 'name)))))
110
111 (defun sort-listed-character-sets (sort-key)
112 (if sort-key
113 (save-excursion
114 (let ((buffer-read-only nil))
115 (goto-char (point-min))
116 (search-forward "\n-")
117 (forward-line 1)
118 (delete-region (point) (point-max))
119 (list-character-sets-1 sort-key)))))
120
121 (defun list-character-sets-1 (sort-key)
122 "Insert a list of character sets sorted by SORT-KEY.
123 SORT-KEY should be `name' or `iso-spec' (default `name')."
124 (or sort-key
125 (setq sort-key 'name))
126 (let ((tail charset-list)
127 charset-info-list supplementary-list charset sort-func)
128 (dolist (charset charset-list)
129 ;; Generate a list that contains all information to display.
130 (let ((elt (list charset
131 (charset-dimension charset)
132 (charset-chars charset)
133 (charset-iso-final-char charset))))
134 (if (plist-get (charset-plist charset) :supplementary-p)
135 (push elt supplementary-list)
136 (push elt charset-info-list))))
137
138 ;; Determine a predicate for `sort' by SORT-KEY.
139 (setq sort-func
140 (cond ((eq sort-key 'name)
141 (lambda (x y) (string< (car x) (car y))))
142
143 ((eq sort-key 'iso-spec)
144 ;; Sort by DIMENSION CHARS FINAL-CHAR
145 (function
146 (lambda (x y)
147 (or (< (nth 1 x) (nth 1 y))
148 (and (= (nth 1 x) (nth 1 y))
149 (or (< (nth 2 x) (nth 2 y))
150 (and (= (nth 2 x) (nth 2 y))
151 (< (nth 3 x) (nth 3 y)))))))))
152 (t
153 (error "Invalid charset sort key: %s" sort-key))))
154
155 (setq charset-info-list (sort charset-info-list sort-func))
156 (setq supplementary-list (sort supplementary-list sort-func))
157
158 ;; Insert information of character sets.
159 (dolist (elt (append charset-info-list (list t) supplementary-list))
160 (if (eq elt t)
161 (insert "-------------- Supplementary Character Sets --------------")
162 (insert-text-button (symbol-name (car elt)) ; NAME
163 :type 'list-charset-chars
164 'help-args (list (car elt)))
165 (goto-char (point-max))
166 (insert "\t")
167 (indent-to 48)
168 (insert (format "%d %3d "
169 (nth 1 elt) (nth 2 elt)) ; DIMENSION and CHARS
170 (if (< (nth 3 elt) 0)
171 "none"
172 (nth 3 elt)))) ; FINAL-CHAR
173 (insert "\n"))))
174
175
176 ;; List all character sets in a form that a program can easily parse.
177
178 (defun list-character-sets-2 ()
179 (insert "#########################
180 ## LIST OF CHARSETS
181 ## Each line corresponds to one charset.
182 ## The following attributes are listed in this order
183 ## separated by a colon `:' in one line.
184 ## CHARSET-SYMBOL-NAME,
185 ## DIMENSION (1 or 2)
186 ## CHARS (94 or 96)
187 ## ISO-FINAL-CHAR (character code of ISO-2022's final character)
188 ## -1 means that no final character is assigned.
189 ## DESCRIPTION (describing string of the charset)
190 ")
191 (let ((l charset-list)
192 charset)
193 (while l
194 (setq charset (car l) l (cdr l))
195 (princ (format "%s:%d:%d:%d:%s\n"
196 charset
197 (charset-dimension charset)
198 (charset-chars charset)
199 ;;; (char-width (make-char charset))
200 ;;; (charset-direction charset)
201 (charset-iso-final-char charset)
202 ;;; (charset-iso-graphic-plane charset)
203 (charset-description charset))))))
204
205 (defvar non-iso-charset-alist nil
206 "Obsolete.")
207 (make-obsolete-variable 'non-iso-charset-alist "no longer relevant" "23.1")
208
209 (defun decode-codepage-char (codepage code)
210 "Decode a character that has code CODE in CODEPAGE.
211 Return a decoded character string. Each CODEPAGE corresponds to a
212 coding system cpCODEPAGE. This function is obsolete."
213 (decode-char (intern (format "cp%d" codepage)) code))
214 (make-obsolete 'decode-codepage-char 'decode-char "23.1")
215
216 ;; A variable to hold charset input history.
217 (defvar charset-history nil)
218
219
220 ;;;###autoload
221 (defun read-charset (prompt &optional default-value initial-input)
222 "Read a character set from the minibuffer, prompting with string PROMPT.
223 It must be an Emacs character set listed in the variable `charset-list'.
224
225 Optional arguments are DEFAULT-VALUE and INITIAL-INPUT.
226 DEFAULT-VALUE, if non-nil, is the default value.
227 INITIAL-INPUT, if non-nil, is a string inserted in the minibuffer initially.
228 See the documentation of the function `completing-read' for the
229 detailed meanings of these arguments."
230 (let* ((table (mapcar (lambda (x) (list (symbol-name x))) charset-list))
231 (charset (completing-read prompt table
232 nil t initial-input 'charset-history
233 default-value)))
234 (if (> (length charset) 0)
235 (intern charset))))
236
237 ;; List characters of the range MIN and MAX of CHARSET. If dimension
238 ;; of CHARSET is two (i.e. 2-byte charset), ROW is the first byte
239 ;; (block index) of the characters, and MIN and MAX are the second
240 ;; bytes of the characters. If the dimension is one, ROW should be 0.
241
242 (defun list-block-of-chars (charset row min max)
243 (let (i ch)
244 (insert-char ?- (+ 7 (* 4 16)))
245 (insert "\n ")
246 (setq i 0)
247 (while (< i 16)
248 (insert (format "%4X" i))
249 (setq i (1+ i)))
250 (setq i (* (/ min 16) 16))
251 (while (<= i max)
252 (if (= (% i 16) 0)
253 (insert (format "\n%6Xx" (/ (+ (* row 256) i) 16))))
254 (setq ch (if (< i min)
255 32
256 (or (decode-char charset (+ (* row 256) i))
257 32))) ; gap in mapping
258 ;; Don't insert control codes, non-Unicode characters.
259 (if (or (< ch 32) (= ch 127))
260 (setq ch (single-key-description ch))
261 (if (and (>= ch 128) (< ch 160))
262 (setq ch (format "%02Xh" ch))
263 (if (> ch #x10FFFF)
264 (setq ch 32))))
265 (insert "\t" ch)
266 (setq i (1+ i))))
267 (insert "\n"))
268
269 ;;;###autoload
270 (defun list-charset-chars (charset)
271 "Display a list of characters in character set CHARSET."
272 (interactive (list (read-charset "Character set: ")))
273 (or (charsetp charset)
274 (error "Invalid character set: %s" charset))
275 (with-output-to-temp-buffer "*Character List*"
276 (with-current-buffer standard-output
277 (if (coding-system-p charset)
278 ;; Useful to be able to do C-u C-x = to find file code, for
279 ;; instance:
280 (set-buffer-file-coding-system charset))
281 (setq mode-line-format (copy-sequence mode-line-format))
282 (let ((slot (memq 'mode-line-buffer-identification mode-line-format)))
283 (if slot
284 (setcdr slot
285 (cons (format " (%s)" charset)
286 (cdr slot)))))
287 (setq tab-width 4)
288 (set-buffer-multibyte t)
289 (let ((dim (charset-dimension charset))
290 (chars (charset-chars charset))
291 ;; (plane (charset-iso-graphic-plane charset))
292 (plane 1)
293 (range (plist-get (charset-plist charset) :code-space))
294 min max min2 max2)
295 (if (> dim 2)
296 (error "Can only list 1- and 2-dimensional charsets"))
297 (insert (format "Characters in the coded character set %s.\n" charset))
298 (narrow-to-region (point) (point))
299 (setq min (aref range 0)
300 max (aref range 1))
301 (if (= dim 1)
302 (list-block-of-chars charset 0 min max)
303 (setq min2 (aref range 2)
304 max2 (aref range 3))
305 (let ((i min2))
306 (while (<= i max2)
307 (list-block-of-chars charset i min max)
308 (setq i (1+ i)))))
309 (put-text-property (point-min) (point-max) 'charset charset)
310 (widen)))))
311
312
313 ;;;###autoload
314 (defun describe-character-set (charset)
315 "Display information about built-in character set CHARSET."
316 (interactive (list (read-charset "Charset: ")))
317 (or (charsetp charset)
318 (error "Invalid charset: %S" charset))
319 (help-setup-xref (list #'describe-character-set charset) (interactive-p))
320 (with-output-to-temp-buffer (help-buffer)
321 (with-current-buffer standard-output
322 (insert "Character set: " (symbol-name charset))
323 (let ((name (get-charset-property charset :name)))
324 (if (not (eq name charset))
325 (insert " (alias of " (symbol-name name) ?\))))
326 (insert "\n\n" (charset-description charset) "\n\n")
327 (insert "Number of contained characters: ")
328 (dotimes (i (charset-dimension charset))
329 (unless (= i 0)
330 (insert ?x))
331 (insert (format "%d" (charset-chars charset (1+ i)))))
332 (insert ?\n)
333 (let ((char (charset-iso-final-char charset)))
334 (when (> char 0)
335 (insert "Final char of ISO2022 designation sequence: ")
336 (insert (format "`%c'\n" char))))
337 (insert (format "Width (how many columns on screen): %d\n"
338 (aref char-width-table (make-char charset))))
339 (let (aliases)
340 (dolist (c charset-list)
341 (if (and (not (eq c charset))
342 (eq charset (get-charset-property c :name)))
343 (push c aliases)))
344 (if aliases
345 (insert "Aliases: " (mapconcat #'symbol-name aliases ", ") ?\n)))
346
347 (dolist (elt `((:ascii-compatible-p "ASCII compatible." nil)
348 (:map "Map file: " identity)
349 (:unify-map "Unification map file: " identity)
350 (:invalid-code
351 nil
352 ,(lambda (c)
353 (format "Invalid character: %c (code %d)" c c)))
354 (:emacs-mule-id "Id in emacs-mule coding system: "
355 number-to-string)
356 (:parents "Parents: "
357 (lambda (parents)
358 (mapconcat ,(lambda (elt)
359 (format "%s" elt))
360 parents
361 ", ")))
362 (:code-space "Code space: " ,(lambda (c)
363 (format "%s" c)))
364 (:code-offset "Code offset: " number-to-string)
365 (:iso-revision-number "ISO revision number: "
366 number-to-string)
367 (:supplementary-p
368 "Used only as a parent of some other charset." nil)))
369 (let ((val (get-charset-property charset (car elt))))
370 (when val
371 (if (cadr elt) (insert (cadr elt)))
372 (if (nth 2 elt)
373 (insert (funcall (nth 2 elt) val)))
374 (insert ?\n)))))))
375 \f
376 ;;; CODING-SYSTEM
377
378 (eval-when-compile ; dynamic bondage
379 (defvar graphic-register))
380
381 ;; Print information about designation of each graphic register in
382 ;; DESIGNATIONS in human readable format. See the documentation of
383 ;; `define-coding-system' for the meaning of DESIGNATIONS
384 ;; (`:designation' property).
385 (defun print-designation (designations)
386 (let (charset)
387 (dotimes (graphic-register 4)
388 (setq charset (aref designations graphic-register))
389 (princ (format
390 " G%d -- %s\n"
391 graphic-register
392 (cond ((null charset)
393 "never used")
394 ((eq charset t)
395 "no initial designation, and used by any charsets")
396 ((symbolp charset)
397 (format "%s:%s"
398 charset (charset-description charset)))
399 ((listp charset)
400 (if (charsetp (car charset))
401 (format "%s:%s, and also used by the following:"
402 (car charset)
403 (charset-description (car charset)))
404 "no initial designation, and used by the following:"))
405 (t
406 "invalid designation information"))))
407 (when (listp charset)
408 (setq charset (cdr charset))
409 (while charset
410 (cond ((eq (car charset) t)
411 (princ "\tany other charsets\n"))
412 ((charsetp (car charset))
413 (princ (format "\t%s:%s\n"
414 (car charset)
415 (charset-description (car charset)))))
416 (t
417 "invalid designation information"))
418 (setq charset (cdr charset)))))))
419
420 ;;;###autoload
421 (defun describe-coding-system (coding-system)
422 "Display information about CODING-SYSTEM."
423 (interactive "zDescribe coding system (default current choices): ")
424 (if (null coding-system)
425 (describe-current-coding-system)
426 (help-setup-xref (list #'describe-coding-system coding-system)
427 (interactive-p))
428 (with-output-to-temp-buffer (help-buffer)
429 (print-coding-system-briefly coding-system 'doc-string)
430 (let ((type (coding-system-type coding-system))
431 ;; Fixme: use this
432 (extra-spec (coding-system-plist coding-system)))
433 (princ "Type: ")
434 (princ type)
435 (cond ((eq type 'undecided)
436 (princ " (do automatic conversion)"))
437 ((eq type 'utf-8)
438 (princ " (UTF-8: Emacs internal multibyte form)"))
439 ((eq type 'utf-16)
440 ;; (princ " (UTF-16)")
441 )
442 ((eq type 'shift-jis)
443 (princ " (Shift-JIS, MS-KANJI)"))
444 ((eq type 'iso-2022)
445 (princ " (variant of ISO-2022)\n")
446 (princ "Initial designations:\n")
447 (print-designation (coding-system-get coding-system
448 :designation))
449
450 (when (coding-system-get coding-system :flags)
451 (princ "Other specifications: \n ")
452 (apply #'print-list
453 (coding-system-get coding-system :flags))))
454 ((eq type 'charset)
455 (princ " (charset)"))
456 ((eq type 'ccl)
457 (princ " (do conversion by CCL program)"))
458 ((eq type 'raw-text)
459 (princ " (text with random binary characters)"))
460 ((eq type 'emacs-mule)
461 (princ " (Emacs 21 internal encoding)"))
462 (t (princ ": invalid coding-system.")))
463 (princ "\nEOL type: ")
464 (let ((eol-type (coding-system-eol-type coding-system)))
465 (cond ((vectorp eol-type)
466 (princ "Automatic selection from:\n\t")
467 (princ eol-type)
468 (princ "\n"))
469 ((or (null eol-type) (eq eol-type 0)) (princ "LF\n"))
470 ((eq eol-type 1) (princ "CRLF\n"))
471 ((eq eol-type 2) (princ "CR\n"))
472 (t (princ "invalid\n")))))
473 (let ((postread (coding-system-get coding-system :post-read-conversion)))
474 (when postread
475 (princ "After decoding text normally,")
476 (princ " perform post-conversion using the function: ")
477 (princ "\n ")
478 (princ postread)
479 (princ "\n")))
480 (let ((prewrite (coding-system-get coding-system :pre-write-conversion)))
481 (when prewrite
482 (princ "Before encoding text normally,")
483 (princ " perform pre-conversion using the function: ")
484 (princ "\n ")
485 (princ prewrite)
486 (princ "\n")))
487 (with-current-buffer standard-output
488 (let ((charsets (coding-system-charset-list coding-system)))
489 (when (and (not (eq (coding-system-base coding-system) 'raw-text))
490 charsets)
491 (cond
492 ((eq charsets 'iso-2022)
493 (insert "This coding system can encode all ISO 2022 charsets."))
494 ((eq charsets 'emacs-mule)
495 (insert "This coding system can encode all emacs-mule charsets\
496 ."""))
497 (t
498 (insert "This coding system encodes the following charsets:\n ")
499 (while charsets
500 (insert " " (symbol-name (car charsets)))
501 (search-backward (symbol-name (car charsets)))
502 (help-xref-button 0 'help-character-set (car charsets))
503 (goto-char (point-max))
504 (setq charsets (cdr charsets)))))))))))
505
506 ;;;###autoload
507 (defun describe-current-coding-system-briefly ()
508 "Display coding systems currently used in a brief format in echo area.
509
510 The format is \"F[..],K[..],T[..],P>[..],P<[..], default F[..],P<[..],P<[..]\",
511 where mnemonics of the following coding systems come in this order
512 in place of `..':
513 `buffer-file-coding-system' (of the current buffer)
514 eol-type of `buffer-file-coding-system' (of the current buffer)
515 Value returned by `keyboard-coding-system'
516 eol-type of `keyboard-coding-system'
517 Value returned by `terminal-coding-system'.
518 eol-type of `terminal-coding-system'
519 `process-coding-system' for read (of the current buffer, if any)
520 eol-type of `process-coding-system' for read (of the current buffer, if any)
521 `process-coding-system' for write (of the current buffer, if any)
522 eol-type of `process-coding-system' for write (of the current buffer, if any)
523 `default-buffer-file-coding-system'
524 eol-type of `default-buffer-file-coding-system'
525 `default-process-coding-system' for read
526 eol-type of `default-process-coding-system' for read
527 `default-process-coding-system' for write
528 eol-type of `default-process-coding-system'"
529 (interactive)
530 (let* ((proc (get-buffer-process (current-buffer)))
531 (process-coding-systems (if proc (process-coding-system proc))))
532 (message
533 "F[%c%s],K[%c%s],T[%c%s],P>[%c%s],P<[%c%s], default F[%c%s],P>[%c%s],P<[%c%s]"
534 (coding-system-mnemonic buffer-file-coding-system)
535 (coding-system-eol-type-mnemonic buffer-file-coding-system)
536 (coding-system-mnemonic (keyboard-coding-system))
537 (coding-system-eol-type-mnemonic (keyboard-coding-system))
538 (coding-system-mnemonic (terminal-coding-system))
539 (coding-system-eol-type-mnemonic (terminal-coding-system))
540 (coding-system-mnemonic (car process-coding-systems))
541 (coding-system-eol-type-mnemonic (car process-coding-systems))
542 (coding-system-mnemonic (cdr process-coding-systems))
543 (coding-system-eol-type-mnemonic (cdr process-coding-systems))
544 (coding-system-mnemonic default-buffer-file-coding-system)
545 (coding-system-eol-type-mnemonic default-buffer-file-coding-system)
546 (coding-system-mnemonic (car default-process-coding-system))
547 (coding-system-eol-type-mnemonic (car default-process-coding-system))
548 (coding-system-mnemonic (cdr default-process-coding-system))
549 (coding-system-eol-type-mnemonic (cdr default-process-coding-system))
550 )))
551
552 (defun print-coding-system-briefly (coding-system &optional doc-string)
553 "Print symbol name and mnemonic letter of CODING-SYSTEM with `princ'.
554 If DOC-STRING is non-nil, print also the docstring of CODING-SYSTEM.
555 If DOC-STRING is `tightly', don't print an empty line before the
556 docstring, and print only the first line of the docstring."
557 (if (not coding-system)
558 (princ "nil\n")
559 (princ (format "%c -- %s"
560 (coding-system-mnemonic coding-system)
561 coding-system))
562 (let ((aliases (coding-system-aliases coding-system)))
563 (cond ((eq coding-system (car aliases))
564 (if (cdr aliases)
565 (princ (format " %S" (cons 'alias: (cdr aliases))))))
566 ((memq coding-system aliases)
567 (princ (format " (alias of %s)" (car aliases))))
568 (t
569 (let ((eol-type (coding-system-eol-type coding-system))
570 (base-eol-type (coding-system-eol-type (car aliases))))
571 (if (and (integerp eol-type)
572 (vectorp base-eol-type)
573 (not (eq coding-system (aref base-eol-type eol-type))))
574 (princ (format " (alias of %s)"
575 (aref base-eol-type eol-type))))))))
576 (princ "\n")
577 (or (eq doc-string 'tightly)
578 (princ "\n"))
579 (if doc-string
580 (let ((doc (or (coding-system-doc-string coding-system) "")))
581 (when (eq doc-string 'tightly)
582 (if (string-match "\n" doc)
583 (setq doc (substring doc 0 (match-beginning 0))))
584 (setq doc (concat " " doc)))
585 (princ (format "%s\n" doc))))))
586
587 ;;;###autoload
588 (defun describe-current-coding-system ()
589 "Display coding systems currently used, in detail."
590 (interactive)
591 (with-output-to-temp-buffer "*Help*"
592 (let* ((proc (get-buffer-process (current-buffer)))
593 (process-coding-systems (if proc (process-coding-system proc))))
594 (princ "Coding system for saving this buffer:\n ")
595 (if (local-variable-p 'buffer-file-coding-system)
596 (print-coding-system-briefly buffer-file-coding-system)
597 (princ "Not set locally, use the default.\n"))
598 (princ "Default coding system (for new files):\n ")
599 (print-coding-system-briefly default-buffer-file-coding-system)
600 (princ "Coding system for keyboard input:\n ")
601 (print-coding-system-briefly (keyboard-coding-system))
602 (princ "Coding system for terminal output:\n ")
603 (print-coding-system-briefly (terminal-coding-system))
604 (princ "Coding system for inter-client cut and paste:\n ")
605 (print-coding-system-briefly selection-coding-system)
606 (when (get-buffer-process (current-buffer))
607 (princ "Coding systems for process I/O:\n")
608 (princ " encoding input to the process: ")
609 (print-coding-system-briefly (cdr process-coding-systems))
610 (princ " decoding output from the process: ")
611 (print-coding-system-briefly (car process-coding-systems)))
612 (princ "Defaults for subprocess I/O:\n")
613 (princ " decoding: ")
614 (print-coding-system-briefly (car default-process-coding-system))
615 (princ " encoding: ")
616 (print-coding-system-briefly (cdr default-process-coding-system)))
617
618 (with-current-buffer standard-output
619
620 (princ "
621 Priority order for recognizing coding systems when reading files:\n")
622 (let ((i 1))
623 (dolist (elt (coding-system-priority-list))
624 (princ (format " %d. %s " i elt))
625 (let ((aliases (coding-system-aliases elt)))
626 (if (eq elt (car aliases))
627 (if (cdr aliases)
628 (princ (cons 'alias: (cdr aliases))))
629 (princ (list 'alias 'of (car aliases))))
630 (terpri)
631 (setq i (1+ i)))))
632
633 (princ "\n Other coding systems cannot be distinguished automatically
634 from these, and therefore cannot be recognized automatically
635 with the present coding system priorities.\n\n")
636
637 ;; Fixme: should this be replaced or junked?
638 (if nil
639 (let ((categories '(coding-category-iso-7 coding-category-iso-7-else))
640 coding-system codings)
641 (while categories
642 (setq coding-system (symbol-value (car categories)))
643 (mapc
644 (lambda (x)
645 (if (and (not (eq x coding-system))
646 (let ((flags (coding-system-get :flags)))
647 (not (or (memq 'use-roman flags)
648 (memq 'use-oldjis flags)))))
649 (setq codings (cons x codings))))
650 (get (car categories) 'coding-systems))
651 (if codings
652 (let ((max-col (window-width))
653 pos)
654 (princ (format "\
655 The following are decoded correctly but recognized as %s:\n "
656 coding-system))
657 (while codings
658 (setq pos (point))
659 (insert (format " %s" (car codings)))
660 (when (> (current-column) max-col)
661 (goto-char pos)
662 (insert "\n ")
663 (goto-char (point-max)))
664 (setq codings (cdr codings)))
665 (insert "\n\n")))
666 (setq categories (cdr categories)))))
667
668 (princ "Particular coding systems specified for certain file names:\n")
669 (terpri)
670 (princ " OPERATION\tTARGET PATTERN\t\tCODING SYSTEM(s)\n")
671 (princ " ---------\t--------------\t\t----------------\n")
672 (let ((func (lambda (operation alist)
673 (princ " ")
674 (princ operation)
675 (if (not alist)
676 (princ "\tnothing specified\n")
677 (while alist
678 (indent-to 16)
679 (prin1 (car (car alist)))
680 (if (>= (current-column) 40)
681 (newline))
682 (indent-to 40)
683 (princ (cdr (car alist)))
684 (princ "\n")
685 (setq alist (cdr alist)))))))
686 (funcall func "File I/O" file-coding-system-alist)
687 (funcall func "Process I/O" process-coding-system-alist)
688 (funcall func "Network I/O" network-coding-system-alist))
689 (help-mode))))
690
691 (defun print-coding-system (coding-system)
692 "Print detailed information on CODING-SYSTEM."
693 (let ((type (coding-system-type coding-system))
694 (eol-type (coding-system-eol-type coding-system))
695 (flags (coding-system-get coding-system :flags))
696 (aliases (coding-system-aliases coding-system)))
697 (if (not (eq (car aliases) coding-system))
698 (princ (format "%s (alias of %s)\n" coding-system (car aliases)))
699 (princ coding-system)
700 (setq aliases (cdr aliases))
701 (while aliases
702 (princ ",")
703 (princ (car aliases))
704 (setq aliases (cdr aliases)))
705 (princ (format ":%s:%c:%d:"
706 type
707 (coding-system-mnemonic coding-system)
708 (if (integerp eol-type) eol-type 3)))
709 (cond ((eq type 'iso2022)
710 (let ((idx 0)
711 charset)
712 (while (< idx 4)
713 (setq charset (aref flags idx))
714 (cond ((null charset)
715 (princ -1))
716 ((eq charset t)
717 (princ -2))
718 ((charsetp charset)
719 (princ charset))
720 ((listp charset)
721 (princ "(")
722 (princ (car charset))
723 (setq charset (cdr charset))
724 (while charset
725 (princ ",")
726 (princ (car charset))
727 (setq charset (cdr charset)))
728 (princ ")")))
729 (princ ",")
730 (setq idx (1+ idx)))
731 (while (< idx 12)
732 (princ (if (aref flags idx) 1 0))
733 (princ ",")
734 (setq idx (1+ idx)))
735 (princ (if (aref flags idx) 1 0))))
736 ((eq type 'ccl)
737 (let (i len)
738 (if (symbolp (car flags))
739 (princ (format " %s" (car flags)))
740 (setq i 0 len (length (car flags)))
741 (while (< i len)
742 (princ (format " %x" (aref (car flags) i)))
743 (setq i (1+ i))))
744 (princ ",")
745 (if (symbolp (cdr flags))
746 (princ (format "%s" (cdr flags)))
747 (setq i 0 len (length (cdr flags)))
748 (while (< i len)
749 (princ (format " %x" (aref (cdr flags) i)))
750 (setq i (1+ i))))))
751 (t (princ 0)))
752 (princ ":")
753 (princ (coding-system-doc-string coding-system))
754 (princ "\n"))))
755
756 ;;;###autoload
757 (defun list-coding-systems (&optional arg)
758 "Display a list of all coding systems.
759 This shows the mnemonic letter, name, and description of each coding system.
760
761 With prefix arg, the output format gets more cryptic,
762 but still contains full information about each coding system."
763 (interactive "P")
764 (with-output-to-temp-buffer "*Help*"
765 (list-coding-systems-1 arg)))
766
767 (defun list-coding-systems-1 (arg)
768 (if (null arg)
769 (princ "\
770 ###############################################
771 # List of coding systems in the following format:
772 # MNEMONIC-LETTER -- CODING-SYSTEM-NAME
773 # DOC-STRING
774 ")
775 (princ "\
776 #########################
777 ## LIST OF CODING SYSTEMS
778 ## Each line corresponds to one coding system
779 ## Format of a line is:
780 ## NAME[,ALIAS...]:TYPE:MNEMONIC:EOL:FLAGS:POST-READ-CONVERSION
781 ## :PRE-WRITE-CONVERSION:DOC-STRING,
782 ## where
783 ## NAME = coding system name
784 ## ALIAS = alias of the coding system
785 ## TYPE = nil (no conversion), t (undecided or automatic detection),
786 ## 0 (EMACS-MULE), 1 (SJIS), 2 (ISO2022), 3 (BIG5), or 4 (CCL)
787 ## EOL = 0 (LF), 1 (CRLF), 2 (CR), or 3 (Automatic detection)
788 ## FLAGS =
789 ## if TYPE = 2 then
790 ## comma (`,') separated data of the following:
791 ## G0, G1, G2, G3, SHORT-FORM, ASCII-EOL, ASCII-CNTL, SEVEN,
792 ## LOCKING-SHIFT, SINGLE-SHIFT, USE-ROMAN, USE-OLDJIS, NO-ISO6429
793 ## else if TYPE = 4 then
794 ## comma (`,') separated CCL programs for read and write
795 ## else
796 ## 0
797 ## POST-READ-CONVERSION, PRE-WRITE-CONVERSION = function name to be called
798 ##
799 "))
800 (dolist (coding-system (sort-coding-systems (coding-system-list 'base-only)))
801 (if (null arg)
802 (print-coding-system-briefly coding-system 'tightly)
803 (print-coding-system coding-system))))
804
805 ;; Fixme: delete?
806 ;;;###autoload
807 (defun list-coding-categories ()
808 "Display a list of all coding categories."
809 (with-output-to-temp-buffer "*Help*"
810 (princ "\
811 ############################
812 ## LIST OF CODING CATEGORIES (ordered by priority)
813 ## CATEGORY:CODING-SYSTEM
814 ##
815 ")
816 (let ((l coding-category-list))
817 (while l
818 (princ (format "%s:%s\n" (car l) (symbol-value (car l))))
819 (setq l (cdr l))))))
820 \f
821 ;;; FONT
822
823 (defun describe-font-internal (font-info &optional verbose)
824 "Print information about a font in FONT-INFO."
825 (print-list "name (opened by):" (aref font-info 0))
826 (print-list " full name:" (aref font-info 1))
827 (print-list " size:" (format "%2d" (aref font-info 2)))
828 (print-list " height:" (format "%2d" (aref font-info 3)))
829 (print-list " baseline-offset:" (format "%2d" (aref font-info 4)))
830 (print-list "relative-compose:" (format "%2d" (aref font-info 5))))
831
832 ;;;###autoload
833 (defun describe-font (fontname)
834 "Display information about a font whose name is FONTNAME.
835 The font must be already used by Emacs."
836 (interactive "sFont name (default current choice for ASCII chars): ")
837 (or (and window-system (fboundp 'fontset-list))
838 (error "No fonts being used"))
839 (let (fontset font-info)
840 (when (or (not fontname) (= (length fontname) 0))
841 (setq fontname (frame-parameter nil 'font))
842 ;; Check if FONTNAME is a fontset.
843 (if (query-fontset fontname)
844 (setq fontset fontname
845 fontname (nth 1 (assq 'ascii
846 (aref (fontset-info fontname) 2))))))
847 (setq font-info (font-info fontname))
848 (if (null font-info)
849 (if fontset
850 ;; The font should be surely used. So, there's some
851 ;; problem about getting information about it. It is
852 ;; better to print the fontname to show which font has
853 ;; this problem.
854 (message "No information about \"%s\"" fontname)
855 (message "No matching font being used"))
856 (with-output-to-temp-buffer "*Help*"
857 (describe-font-internal font-info 'verbose)))))
858
859 (defun print-fontset-element (val)
860 ;; VAL has this format:
861 ;; ((REQUESTED-FONT-NAME OPENED-FONT-NAME ...) ...)
862 ;; CHAR RANGE is already inserted. Get character codes from
863 ;; the current line.
864 (beginning-of-line)
865 (let ((from (following-char))
866 (to (if (looking-at "[^.]*[.]* ")
867 (char-after (match-end 0)))))
868 (if (re-search-forward "[ \t]*$" nil t)
869 (delete-region (match-beginning 0) (match-end 0)))
870
871 ;; For non-ASCII characters, insert also CODE RANGE.
872 (if (or (>= from 128) (and to (>= to 128)))
873 (if to
874 (insert (format " (#x%02X .. #x%02X)" from to))
875 (insert (format " (#x%02X)" from))))
876
877 ;; Insert a requested font name.
878 (dolist (elt val)
879 (let ((requested (car elt)))
880 (if (stringp requested)
881 (insert "\n " requested)
882 (let (family registry weight slant width adstyle)
883 (if (and (fboundp 'fontp) (fontp requested))
884 (setq family (font-get requested :family)
885 registry (font-get requested :registry)
886 weight (font-get requested :weight)
887 slant (font-get requested :slant)
888 width (font-get requested :width)
889 adstyle (font-get requested :adstyle))
890 (setq family (aref requested 0)
891 registry (aref requested 5)
892 weight (aref requested 1)
893 slant (aref requested 2)
894 width (aref requested 3)
895 adstyle (aref requested 4)))
896 (if (not family)
897 (setq family "*-*")
898 (if (symbolp family)
899 (setq family (symbol-name family)))
900 (or (string-match "-" family)
901 (setq family (concat "*-" family))))
902 (if (not registry)
903 (setq registry "*-*")
904 (if (symbolp registry)
905 (setq registry (symbol-name registry)))
906 (or (string-match "-" registry)
907 (= (aref registry (1- (length registry))) ?*)
908 (setq registry (concat registry "*"))))
909 (insert (format"\n -%s-%s-%s-%s-%s-*-*-*-*-*-*-%s"
910 family (or weight "*") (or slant "*") (or width "*")
911 (or adstyle "*") registry)))))
912
913 ;; Insert opened font names (if any).
914 (if (and (boundp 'print-opened) (symbol-value 'print-opened))
915 (dolist (opened (cdr elt))
916 (insert "\n\t[" opened "]"))))))
917
918 (defun print-fontset (fontset &optional print-opened)
919 "Print information about FONTSET.
920 If FONTSET is nil, print information about the default fontset.
921 If optional arg PRINT-OPENED is non-nil, also print names of all opened
922 fonts for FONTSET. This function actually inserts the information in
923 the current buffer."
924 (or fontset
925 (setq fontset (query-fontset "fontset-default")))
926 (beginning-of-line)
927 (insert "Fontset: " fontset "\n")
928 (insert (propertize "CHAR RANGE" 'face 'underline)
929 " (" (propertize "CODE RANGE" 'face 'underline) ")\n")
930 (insert " " (propertize "FONT NAME" 'face 'underline)
931 " (" (propertize "REQUESTED" 'face 'underline)
932 " and [" (propertize "OPENED" 'face 'underline) "])")
933 (let ((info (fontset-info fontset)))
934 (describe-vector info 'print-fontset-element)
935 (insert "\n ---<fallback to the default fontset>---")
936 (describe-vector (char-table-extra-slot info 0) 'print-fontset-element)))
937
938 ;;;###autoload
939 (defun describe-fontset (fontset)
940 "Display information about FONTSET.
941 This shows which font is used for which character(s)."
942 (interactive
943 (if (not (and window-system (fboundp 'fontset-list)))
944 (error "No fontsets being used")
945 (let ((fontset-list (nconc
946 (fontset-list)
947 (mapcar 'cdr fontset-alias-alist)))
948 (completion-ignore-case t))
949 (list (completing-read
950 "Fontset (default used by the current frame): "
951 fontset-list nil t)))))
952 (if (= (length fontset) 0)
953 (setq fontset (frame-parameter nil 'font)))
954 (setq fontset (query-fontset fontset))
955 (help-setup-xref (list #'describe-fontset fontset) (interactive-p))
956 (with-output-to-temp-buffer (help-buffer)
957 (with-current-buffer standard-output
958 (print-fontset fontset t))))
959
960 ;;;###autoload
961 (defun list-fontsets (arg)
962 "Display a list of all fontsets.
963 This shows the name, size, and style of each fontset.
964 With prefix arg, also list the fonts contained in each fontset;
965 see the function `describe-fontset' for the format of the list."
966 (interactive "P")
967 (if (not (and window-system (fboundp 'fontset-list)))
968 (error "No fontsets being used")
969 (help-setup-xref (list #'list-fontsets arg) (interactive-p))
970 (with-output-to-temp-buffer (help-buffer)
971 (with-current-buffer standard-output
972 ;; This code is duplicated near the end of mule-diag.
973 (let ((fontsets
974 (sort (fontset-list)
975 (lambda (x y)
976 (string< (fontset-plain-name x)
977 (fontset-plain-name y))))))
978 (while fontsets
979 (if arg
980 (print-fontset (car fontsets) nil)
981 (insert "Fontset: " (car fontsets) "\n"))
982 (setq fontsets (cdr fontsets))))))))
983 \f
984 ;;;###autoload
985 (defun list-input-methods ()
986 "Display information about all input methods."
987 (interactive)
988 (help-setup-xref '(list-input-methods) (interactive-p))
989 (with-output-to-temp-buffer (help-buffer)
990 (list-input-methods-1)
991 (with-current-buffer standard-output
992 (save-excursion
993 (goto-char (point-min))
994 (while (re-search-forward
995 "^ \\([^ ]+\\) (`.*' in mode line)$" nil t)
996 (help-xref-button 1 'help-input-method (match-string 1)))))))
997
998 (defun list-input-methods-1 ()
999 (if (not input-method-alist)
1000 (progn
1001 (princ "
1002 No input method is available, perhaps because you have not
1003 installed LEIM (Libraries of Emacs Input Methods)."))
1004 (princ "LANGUAGE\n NAME (`TITLE' in mode line)\n")
1005 (princ " SHORT-DESCRIPTION\n------------------------------\n")
1006 (setq input-method-alist
1007 (sort input-method-alist
1008 (lambda (x y) (string< (nth 1 x) (nth 1 y)))))
1009 (let ((l input-method-alist)
1010 language elt)
1011 (while l
1012 (setq elt (car l) l (cdr l))
1013 (when (not (equal language (nth 1 elt)))
1014 (setq language (nth 1 elt))
1015 (princ language)
1016 (terpri))
1017 (princ (format " %s (`%s' in mode line)\n %s\n"
1018 (car elt)
1019 (let ((title (nth 3 elt)))
1020 (if (and (consp title) (stringp (car title)))
1021 (car title)
1022 title))
1023 (let ((description (nth 4 elt)))
1024 (string-match ".*" description)
1025 (match-string 0 description))))))))
1026 \f
1027 ;;; DIAGNOSIS
1028
1029 ;; Insert a header of a section with SECTION-NUMBER and TITLE.
1030 (defun insert-section (section-number title)
1031 (insert "########################################\n"
1032 "# Section " (format "%d" section-number) ". " title "\n"
1033 "########################################\n\n"))
1034
1035 ;;;###autoload
1036 (defun mule-diag ()
1037 "Display diagnosis of the multilingual environment (Mule).
1038
1039 This shows various information related to the current multilingual
1040 environment, including lists of input methods, coding systems,
1041 character sets, and fontsets (if Emacs is running under a window
1042 system which uses fontsets)."
1043 (interactive)
1044 (with-output-to-temp-buffer "*Mule-Diagnosis*"
1045 (with-current-buffer standard-output
1046 (insert "###############################################\n"
1047 "### Current Status of Multilingual Features ###\n"
1048 "###############################################\n\n"
1049 "CONTENTS: Section 1. General Information\n"
1050 " Section 2. Display\n"
1051 " Section 3. Input methods\n"
1052 " Section 4. Coding systems\n"
1053 " Section 5. Character sets\n")
1054 (if (and window-system (fboundp 'fontset-list))
1055 (insert " Section 6. Fontsets\n"))
1056 (insert "\n")
1057
1058 (insert-section 1 "General Information")
1059 (insert "Version of this emacs:\n " (emacs-version) "\n\n")
1060 (insert "Configuration options:\n " system-configuration-options "\n\n")
1061 (insert "Multibyte characters awareness:\n"
1062 (format " default: %S\n" default-enable-multibyte-characters)
1063 (format " current-buffer: %S\n\n" enable-multibyte-characters))
1064 (insert "Current language environment: " current-language-environment
1065 "\n\n")
1066
1067 (insert-section 2 "Display")
1068 (if window-system
1069 (insert "Window-system: "
1070 (symbol-name window-system)
1071 (format "%s" window-system-version))
1072 (insert "Terminal: " (getenv "TERM")))
1073 (insert "\n\n")
1074
1075 (if (eq window-system 'x)
1076 (let ((font (cdr (assq 'font (frame-parameters)))))
1077 (insert "The selected frame is using the "
1078 (if (query-fontset font) "fontset" "font")
1079 ":\n\t" font))
1080 (insert "Coding system of the terminal: "
1081 (symbol-name (terminal-coding-system))))
1082 (insert "\n\n")
1083
1084 (insert-section 3 "Input methods")
1085 (list-input-methods-1)
1086 (insert "\n")
1087 (if default-input-method
1088 (insert (format "Default input method: %s\n" default-input-method))
1089 (insert "No default input method is specified\n"))
1090
1091 (insert-section 4 "Coding systems")
1092 (list-coding-systems-1 t)
1093 (insert "\n")
1094
1095 (insert-section 5 "Character sets")
1096 (list-character-sets-2)
1097 (insert "\n")
1098
1099 (when (and window-system (fboundp 'fontset-list))
1100 ;; This code duplicates most of list-fontsets.
1101 (insert-section 6 "Fontsets")
1102 (insert "Fontset-Name\t\t\t\t\t\t WDxHT Style\n")
1103 (insert "------------\t\t\t\t\t\t ----- -----\n")
1104 (let ((fontsets (fontset-list)))
1105 (while fontsets
1106 (print-fontset (car fontsets) t)
1107 (setq fontsets (cdr fontsets)))))
1108 (print-help-return-message))))
1109
1110 ;;;###autoload
1111 (defcustom unicodedata-file nil
1112 "Location of UnicodeData file.
1113 This is the UnicodeData.txt file from the Unicode consortium, used for
1114 diagnostics. If it is non-nil `describe-char-after' will print data
1115 looked up from it."
1116 :group 'mule
1117 :type '(choice (const :tag "None" nil)
1118 file))
1119
1120 ;; We could convert the unidata file into a Lispy form once-for-all
1121 ;; and distribute it for loading on demand. It might be made more
1122 ;; space-efficient by splitting strings word-wise and replacing them
1123 ;; with lists of symbols interned in a private obarray, e.g.
1124 ;; "LATIN SMALL LETTER A" => '(LATIN SMALL LETTER A).
1125
1126 ;;;###autoload
1127 (defun unicode-data (char)
1128 "Return a list of Unicode data for unicode CHAR.
1129 Each element is a list of a property description and the property value.
1130 The list is null if CHAR isn't found in `unicodedata-file'."
1131 (when unicodedata-file
1132 (unless (file-exists-p unicodedata-file)
1133 (error "`unicodedata-file' %s not found" unicodedata-file))
1134 (save-excursion
1135 (set-buffer (find-file-noselect unicodedata-file t t))
1136 (goto-char (point-min))
1137 (let ((hex (format "%04X" char))
1138 found first last)
1139 (if (re-search-forward (concat "^" hex) nil t)
1140 (setq found t)
1141 ;; It's not listed explicitly. Look for ranges, e.g. CJK
1142 ;; ideographs, and check whether it's in one of them.
1143 (while (and (re-search-forward "^\\([^;]+\\);[^;]+First>;" nil t)
1144 (>= char (setq first
1145 (string-to-number (match-string 1) 16)))
1146 (progn
1147 (forward-line 1)
1148 (looking-at "^\\([^;]+\\);[^;]+Last>;")
1149 (> char
1150 (setq last
1151 (string-to-number (match-string 1) 16))))))
1152 (if (and (>= char first)
1153 (<= char last))
1154 (setq found t)))
1155 (if found
1156 (let ((fields (mapcar (lambda (elt)
1157 (if (> (length elt) 0)
1158 elt))
1159 (cdr (split-string
1160 (buffer-substring
1161 (line-beginning-position)
1162 (line-end-position))
1163 ";")))))
1164 ;; The length depends on whether the last field was empty.
1165 (unless (or (= 13 (length fields))
1166 (= 14 (length fields)))
1167 (error "Invalid contents in %s" unicodedata-file))
1168 ;; The field names and values lists are slightly
1169 ;; modified from Mule-UCS unidata.el.
1170 (list
1171 (list "Name" (let ((name (nth 0 fields)))
1172 ;; Check for <..., First>, <..., Last>
1173 (if (string-match "\\`\\(<[^,]+\\)," name)
1174 (concat (match-string 1 name) ">")
1175 name)))
1176 (list "Category"
1177 (cdr (assoc
1178 (nth 1 fields)
1179 '(("Lu" . "uppercase letter")
1180 ("Ll" . "lowercase letter")
1181 ("Lt" . "titlecase letter")
1182 ("Mn" . "non-spacing mark")
1183 ("Mc" . "spacing-combining mark")
1184 ("Me" . "enclosing mark")
1185 ("Nd" . "decimal digit")
1186 ("Nl" . "letter number")
1187 ("No" . "other number")
1188 ("Zs" . "space separator")
1189 ("Zl" . "line separator")
1190 ("Zp" . "paragraph separator")
1191 ("Cc" . "other control")
1192 ("Cf" . "other format")
1193 ("Cs" . "surrogate")
1194 ("Co" . "private use")
1195 ("Cn" . "not assigned")
1196 ("Lm" . "modifier letter")
1197 ("Lo" . "other letter")
1198 ("Pc" . "connector punctuation")
1199 ("Pd" . "dash punctuation")
1200 ("Ps" . "open punctuation")
1201 ("Pe" . "close punctuation")
1202 ("Pi" . "initial-quotation punctuation")
1203 ("Pf" . "final-quotation punctuation")
1204 ("Po" . "other punctuation")
1205 ("Sm" . "math symbol")
1206 ("Sc" . "currency symbol")
1207 ("Sk" . "modifier symbol")
1208 ("So" . "other symbol")))))
1209 (list "Combining class"
1210 (cdr (assoc
1211 (string-to-number (nth 2 fields))
1212 '((0 . "Spacing")
1213 (1 . "Overlays and interior")
1214 (7 . "Nuktas")
1215 (8 . "Hiragana/Katakana voicing marks")
1216 (9 . "Viramas")
1217 (10 . "Start of fixed position classes")
1218 (199 . "End of fixed position classes")
1219 (200 . "Below left attached")
1220 (202 . "Below attached")
1221 (204 . "Below right attached")
1222 (208 . "Left attached (reordrant around \
1223 single base character)")
1224 (210 . "Right attached")
1225 (212 . "Above left attached")
1226 (214 . "Above attached")
1227 (216 . "Above right attached")
1228 (218 . "Below left")
1229 (220 . "Below")
1230 (222 . "Below right")
1231 (224 . "Left (reordrant around single base \
1232 character)")
1233 (226 . "Right")
1234 (228 . "Above left")
1235 (230 . "Above")
1236 (232 . "Above right")
1237 (233 . "Double below")
1238 (234 . "Double above")
1239 (240 . "Below (iota subscript)")))))
1240 (list "Bidi category"
1241 (cdr (assoc
1242 (nth 3 fields)
1243 '(("L" . "Left-to-Right")
1244 ("LRE" . "Left-to-Right Embedding")
1245 ("LRO" . "Left-to-Right Override")
1246 ("R" . "Right-to-Left")
1247 ("AL" . "Right-to-Left Arabic")
1248 ("RLE" . "Right-to-Left Embedding")
1249 ("RLO" . "Right-to-Left Override")
1250 ("PDF" . "Pop Directional Format")
1251 ("EN" . "European Number")
1252 ("ES" . "European Number Separator")
1253 ("ET" . "European Number Terminator")
1254 ("AN" . "Arabic Number")
1255 ("CS" . "Common Number Separator")
1256 ("NSM" . "Non-Spacing Mark")
1257 ("BN" . "Boundary Neutral")
1258 ("B" . "Paragraph Separator")
1259 ("S" . "Segment Separator")
1260 ("WS" . "Whitespace")
1261 ("ON" . "Other Neutrals")))))
1262 (list "Decomposition"
1263 (if (nth 4 fields)
1264 (let* ((parts (split-string (nth 4 fields)))
1265 (info (car parts)))
1266 (if (string-match "\\`<\\(.+\\)>\\'" info)
1267 (setq info (match-string 1 info))
1268 (setq info nil))
1269 (if info (setq parts (cdr parts)))
1270 (setq parts (mapconcat
1271 (lambda (arg)
1272 (string (string-to-number arg 16)))
1273 parts " "))
1274 (concat info parts))))
1275 (list "Decimal digit value"
1276 (nth 5 fields))
1277 (list "Digit value"
1278 (nth 6 fields))
1279 (list "Numeric value"
1280 (nth 7 fields))
1281 (list "Mirrored"
1282 (if (equal "Y" (nth 8 fields))
1283 "yes"))
1284 (list "Old name" (nth 9 fields))
1285 (list "ISO 10646 comment" (nth 10 fields))
1286 (list "Uppercase" (and (nth 11 fields)
1287 (string (string-to-number
1288 (nth 11 fields) 16))))
1289 (list "Lowercase" (and (nth 12 fields)
1290 (string (string-to-number
1291 (nth 12 fields) 16))))
1292 (list "Titlecase" (and (nth 13 fields)
1293 (string (string-to-number
1294 (nth 13 fields) 16)))))))))))
1295
1296 (provide 'mule-diag)
1297
1298 ;;; arch-tag: cd3b607c-2893-45a0-a4fa-a6535754dbee
1299 ;;; mule-diag.el ends here