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