]> code.delx.au - gnu-emacs/blob - lisp/international/mule-diag.el
Split XEmacs/Emacs definitions and sample setup code into separate files
[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 Free Software Foundation, Inc.
5 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
6 ;; 2005, 2006
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 ## WIDTH (occupied column numbers: 1 or 2),
188 ## DIRECTION (0:left-to-right, 1:right-to-left),
189 ## ISO-FINAL-CHAR (character code of ISO-2022's final character)
190 ## ISO-GRAPHIC-PLANE (ISO-2022's graphic plane, 0:GL, 1:GR)
191 ## DESCRIPTION (describing string of the charset)
192 ")
193 (let ((l charset-list)
194 charset)
195 (while l
196 (setq charset (car l) l (cdr l))
197 (princ (format "%s:%d:%d:%d:%d:%s\n"
198 charset
199 (charset-dimension charset)
200 (charset-chars charset)
201 (aref char-width-table (make-char charset))
202 ;;; (charset-direction charset)
203 (charset-iso-final-char charset)
204 ;;; (charset-iso-graphic-plane charset)
205 (charset-description charset))))))
206
207 (defvar non-iso-charset-alist nil
208 "Obsolete.")
209 (make-obsolete-variable 'non-iso-charset-alist "no longer relevant" "23.1")
210
211 (defun decode-codepage-char (codepage code)
212 "Decode a character that has code CODE in CODEPAGE.
213 Return a decoded character string. Each CODEPAGE corresponds to a
214 coding system cpCODEPAGE. This function is obsolete."
215 (decode-char (intern (format "cp%d" codepage)) code))
216 (make-obsolete 'decode-codepage-char 'decode-char "23.1")
217
218 ;; A variable to hold charset input history.
219 (defvar charset-history nil)
220
221
222 ;;;###autoload
223 (defun read-charset (prompt &optional default-value initial-input)
224 "Read a character set from the minibuffer, prompting with string PROMPT.
225 It must be an Emacs character set listed in the variable `charset-list'.
226
227 Optional arguments are DEFAULT-VALUE and INITIAL-INPUT.
228 DEFAULT-VALUE, if non-nil, is the default value.
229 INITIAL-INPUT, if non-nil, is a string inserted in the minibuffer initially.
230 See the documentation of the function `completing-read' for the
231 detailed meanings of these arguments."
232 (let* ((table (mapcar (lambda (x) (list (symbol-name x))) charset-list))
233 (charset (completing-read prompt table
234 nil t initial-input 'charset-history
235 default-value)))
236 (if (> (length charset) 0)
237 (intern charset))))
238
239 ;; List characters of the range MIN and MAX of CHARSET. If dimension
240 ;; of CHARSET is two (i.e. 2-byte charset), ROW is the first byte
241 ;; (block index) of the characters, and MIN and MAX are the second
242 ;; bytes of the characters. If the dimension is one, ROW should be 0.
243
244 (defun list-block-of-chars (charset row min max)
245 (let (i ch)
246 (insert-char ?- (+ 7 (* 4 16)))
247 (insert "\n ")
248 (setq i 0)
249 (while (< i 16)
250 (insert (format "%4X" i))
251 (setq i (1+ i)))
252 (setq i (* (/ min 16) 16))
253 (while (<= i max)
254 (if (= (% i 16) 0)
255 (insert (format "\n%6Xx" (/ (+ (* row 256) i) 16))))
256 (setq ch (if (< i min)
257 32
258 (or (decode-char charset (+ (* row 256) i))
259 32))) ; gap in mapping
260 ;; Don't insert a control code.
261 (if (or (< ch 32) (= ch 127))
262 (setq ch (single-key-description ch))
263 (if (and (>= ch 128) (< ch 160))
264 (setq ch (format "%02Xh" ch))))
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 (mapcar
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 (aref requested 0))
883 (registry (aref requested 5)))
884 (if (not family)
885 (setq family "*-*")
886 (or (string-match "-" family)
887 (setq family (concat "*-" family))))
888 (or (string-match "-" registry)
889 (= (aref registry (1- (length registry))) ?*)
890 (setq registry (concat registry "*")))
891 (insert "\n -" family
892 ?- (or (aref requested 1) ?*) ; weight
893 ?- (or (aref requested 2) ?*) ; slant
894 ?- (or (aref requested 3) ?*) ; width
895 ?- (or (aref requested 4) ?*) ; adstyle
896 "-*-*-*-*-*-*-" registry))))
897
898 ;; Insert opened font names (if any).
899 (if (and (boundp 'print-opened) (symbol-value 'print-opened))
900 (dolist (opened (cdr elt))
901 (insert "\n\t[" opened "]"))))))
902
903 (defun print-fontset (fontset &optional print-opened)
904 "Print information about FONTSET.
905 If FONTSET is nil, print information about the default fontset.
906 If optional arg PRINT-OPENED is non-nil, also print names of all opened
907 fonts for FONTSET. This function actually inserts the information in
908 the current buffer."
909 (or fontset
910 (setq fontset (query-fontset "fontset-default")))
911 (beginning-of-line)
912 (insert "Fontset: " fontset "\n")
913 (insert (propertize "CHAR RANGE" 'face 'underline)
914 " (" (propertize "CODE RANGE" 'face 'underline) ")\n")
915 (insert " " (propertize "FONT NAME" 'face 'underline)
916 " (" (propertize "REQUESTED" 'face 'underline)
917 " and [" (propertize "OPENED" 'face 'underline) "])")
918 (let ((info (fontset-info fontset)))
919 (describe-vector info 'print-fontset-element)
920 (insert "\n ---<fallback to the default fontset>---")
921 (describe-vector (char-table-extra-slot info 0) 'print-fontset-element)))
922
923 ;;;###autoload
924 (defun describe-fontset (fontset)
925 "Display information about FONTSET.
926 This shows which font is used for which character(s)."
927 (interactive
928 (if (not (and window-system (fboundp 'fontset-list)))
929 (error "No fontsets being used")
930 (let ((fontset-list (nconc
931 (fontset-list)
932 (mapcar 'cdr fontset-alias-alist)))
933 (completion-ignore-case t))
934 (list (completing-read
935 "Fontset (default used by the current frame): "
936 fontset-list nil t)))))
937 (if (= (length fontset) 0)
938 (setq fontset (frame-parameter nil 'font)))
939 (setq fontset (query-fontset fontset))
940 (help-setup-xref (list #'describe-fontset fontset) (interactive-p))
941 (with-output-to-temp-buffer (help-buffer)
942 (with-current-buffer standard-output
943 (print-fontset fontset t))))
944
945 ;;;###autoload
946 (defun list-fontsets (arg)
947 "Display a list of all fontsets.
948 This shows the name, size, and style of each fontset.
949 With prefix arg, also list the fonts contained in each fontset;
950 see the function `describe-fontset' for the format of the list."
951 (interactive "P")
952 (if (not (and window-system (fboundp 'fontset-list)))
953 (error "No fontsets being used")
954 (help-setup-xref (list #'list-fontsets arg) (interactive-p))
955 (with-output-to-temp-buffer (help-buffer)
956 (with-current-buffer standard-output
957 ;; This code is duplicated near the end of mule-diag.
958 (let ((fontsets
959 (sort (fontset-list)
960 (lambda (x y)
961 (string< (fontset-plain-name x)
962 (fontset-plain-name y))))))
963 (while fontsets
964 (if arg
965 (print-fontset (car fontsets) nil)
966 (insert "Fontset: " (car fontsets) "\n"))
967 (setq fontsets (cdr fontsets))))))))
968 \f
969 ;;;###autoload
970 (defun list-input-methods ()
971 "Display information about all input methods."
972 (interactive)
973 (help-setup-xref '(list-input-methods) (interactive-p))
974 (with-output-to-temp-buffer (help-buffer)
975 (list-input-methods-1)
976 (with-current-buffer standard-output
977 (save-excursion
978 (goto-char (point-min))
979 (while (re-search-forward
980 "^ \\([^ ]+\\) (`.*' in mode line)$" nil t)
981 (help-xref-button 1 'help-input-method (match-string 1)))))))
982
983 (defun list-input-methods-1 ()
984 (if (not input-method-alist)
985 (progn
986 (princ "
987 No input method is available, perhaps because you have not
988 installed LEIM (Libraries of Emacs Input Methods)."))
989 (princ "LANGUAGE\n NAME (`TITLE' in mode line)\n")
990 (princ " SHORT-DESCRIPTION\n------------------------------\n")
991 (setq input-method-alist
992 (sort input-method-alist
993 (lambda (x y) (string< (nth 1 x) (nth 1 y)))))
994 (let ((l input-method-alist)
995 language elt)
996 (while l
997 (setq elt (car l) l (cdr l))
998 (when (not (equal language (nth 1 elt)))
999 (setq language (nth 1 elt))
1000 (princ language)
1001 (terpri))
1002 (princ (format " %s (`%s' in mode line)\n %s\n"
1003 (car elt)
1004 (let ((title (nth 3 elt)))
1005 (if (and (consp title) (stringp (car title)))
1006 (car title)
1007 title))
1008 (let ((description (nth 4 elt)))
1009 (string-match ".*" description)
1010 (match-string 0 description))))))))
1011 \f
1012 ;;; DIAGNOSIS
1013
1014 ;; Insert a header of a section with SECTION-NUMBER and TITLE.
1015 (defun insert-section (section-number title)
1016 (insert "########################################\n"
1017 "# Section " (format "%d" section-number) ". " title "\n"
1018 "########################################\n\n"))
1019
1020 ;;;###autoload
1021 (defun mule-diag ()
1022 "Display diagnosis of the multilingual environment (Mule).
1023
1024 This shows various information related to the current multilingual
1025 environment, including lists of input methods, coding systems,
1026 character sets, and fontsets (if Emacs is running under a window
1027 system which uses fontsets)."
1028 (interactive)
1029 (with-output-to-temp-buffer "*Mule-Diagnosis*"
1030 (with-current-buffer standard-output
1031 (insert "###############################################\n"
1032 "### Current Status of Multilingual Features ###\n"
1033 "###############################################\n\n"
1034 "CONTENTS: Section 1. General Information\n"
1035 " Section 2. Display\n"
1036 " Section 3. Input methods\n"
1037 " Section 4. Coding systems\n"
1038 " Section 5. Character sets\n")
1039 (if (and window-system (fboundp 'fontset-list))
1040 (insert " Section 6. Fontsets\n"))
1041 (insert "\n")
1042
1043 (insert-section 1 "General Information")
1044 (insert "Version of this emacs:\n " (emacs-version) "\n\n")
1045 (insert "Configuration options:\n " system-configuration-options "\n\n")
1046 (insert "Multibyte characters awareness:\n"
1047 (format " default: %S\n" default-enable-multibyte-characters)
1048 (format " current-buffer: %S\n\n" enable-multibyte-characters))
1049 (insert "Current language environment: " current-language-environment
1050 "\n\n")
1051
1052 (insert-section 2 "Display")
1053 (if window-system
1054 (insert "Window-system: "
1055 (symbol-name window-system)
1056 (format "%s" window-system-version))
1057 (insert "Terminal: " (getenv "TERM")))
1058 (insert "\n\n")
1059
1060 (if (eq window-system 'x)
1061 (let ((font (cdr (assq 'font (frame-parameters)))))
1062 (insert "The selected frame is using the "
1063 (if (query-fontset font) "fontset" "font")
1064 ":\n\t" font))
1065 (insert "Coding system of the terminal: "
1066 (symbol-name (terminal-coding-system))))
1067 (insert "\n\n")
1068
1069 (insert-section 3 "Input methods")
1070 (list-input-methods-1)
1071 (insert "\n")
1072 (if default-input-method
1073 (insert (format "Default input method: %s\n" default-input-method))
1074 (insert "No default input method is specified\n"))
1075
1076 (insert-section 4 "Coding systems")
1077 (list-coding-systems-1 t)
1078 (insert "\n")
1079
1080 (insert-section 5 "Character sets")
1081 (list-character-sets-2)
1082 (insert "\n")
1083
1084 (when (and window-system (fboundp 'fontset-list))
1085 ;; This code duplicates most of list-fontsets.
1086 (insert-section 6 "Fontsets")
1087 (insert "Fontset-Name\t\t\t\t\t\t WDxHT Style\n")
1088 (insert "------------\t\t\t\t\t\t ----- -----\n")
1089 (let ((fontsets (fontset-list)))
1090 (while fontsets
1091 (print-fontset (car fontsets) t)
1092 (setq fontsets (cdr fontsets)))))
1093 (print-help-return-message))))
1094
1095 ;;;###autoload
1096 (defcustom unicodedata-file nil
1097 "Location of UnicodeData file.
1098 This is the UnicodeData.txt file from the Unicode consortium, used for
1099 diagnostics. If it is non-nil `describe-char-after' will print data
1100 looked up from it."
1101 :group 'mule
1102 :type '(choice (const :tag "None" nil)
1103 file))
1104
1105 ;; We could convert the unidata file into a Lispy form once-for-all
1106 ;; and distribute it for loading on demand. It might be made more
1107 ;; space-efficient by splitting strings word-wise and replacing them
1108 ;; with lists of symbols interned in a private obarray, e.g.
1109 ;; "LATIN SMALL LETTER A" => '(LATIN SMALL LETTER A).
1110
1111 ;;;###autoload
1112 (defun unicode-data (char)
1113 "Return a list of Unicode data for unicode CHAR.
1114 Each element is a list of a property description and the property value.
1115 The list is null if CHAR isn't found in `unicodedata-file'."
1116 (when unicodedata-file
1117 (unless (file-exists-p unicodedata-file)
1118 (error "`unicodedata-file' %s not found" unicodedata-file))
1119 (save-excursion
1120 (set-buffer (find-file-noselect unicodedata-file t t))
1121 (goto-char (point-min))
1122 (let ((hex (format "%04X" char))
1123 found first last)
1124 (if (re-search-forward (concat "^" hex) nil t)
1125 (setq found t)
1126 ;; It's not listed explicitly. Look for ranges, e.g. CJK
1127 ;; ideographs, and check whether it's in one of them.
1128 (while (and (re-search-forward "^\\([^;]+\\);[^;]+First>;" nil t)
1129 (>= char (setq first
1130 (string-to-number (match-string 1) 16)))
1131 (progn
1132 (forward-line 1)
1133 (looking-at "^\\([^;]+\\);[^;]+Last>;")
1134 (> char
1135 (setq last
1136 (string-to-number (match-string 1) 16))))))
1137 (if (and (>= char first)
1138 (<= char last))
1139 (setq found t)))
1140 (if found
1141 (let ((fields (mapcar (lambda (elt)
1142 (if (> (length elt) 0)
1143 elt))
1144 (cdr (split-string
1145 (buffer-substring
1146 (line-beginning-position)
1147 (line-end-position))
1148 ";")))))
1149 ;; The length depends on whether the last field was empty.
1150 (unless (or (= 13 (length fields))
1151 (= 14 (length fields)))
1152 (error "Invalid contents in %s" unicodedata-file))
1153 ;; The field names and values lists are slightly
1154 ;; modified from Mule-UCS unidata.el.
1155 (list
1156 (list "Name" (let ((name (nth 0 fields)))
1157 ;; Check for <..., First>, <..., Last>
1158 (if (string-match "\\`\\(<[^,]+\\)," name)
1159 (concat (match-string 1 name) ">")
1160 name)))
1161 (list "Category"
1162 (cdr (assoc
1163 (nth 1 fields)
1164 '(("Lu" . "uppercase letter")
1165 ("Ll" . "lowercase letter")
1166 ("Lt" . "titlecase letter")
1167 ("Mn" . "non-spacing mark")
1168 ("Mc" . "spacing-combining mark")
1169 ("Me" . "enclosing mark")
1170 ("Nd" . "decimal digit")
1171 ("Nl" . "letter number")
1172 ("No" . "other number")
1173 ("Zs" . "space separator")
1174 ("Zl" . "line separator")
1175 ("Zp" . "paragraph separator")
1176 ("Cc" . "other control")
1177 ("Cf" . "other format")
1178 ("Cs" . "surrogate")
1179 ("Co" . "private use")
1180 ("Cn" . "not assigned")
1181 ("Lm" . "modifier letter")
1182 ("Lo" . "other letter")
1183 ("Pc" . "connector punctuation")
1184 ("Pd" . "dash punctuation")
1185 ("Ps" . "open punctuation")
1186 ("Pe" . "close punctuation")
1187 ("Pi" . "initial-quotation punctuation")
1188 ("Pf" . "final-quotation punctuation")
1189 ("Po" . "other punctuation")
1190 ("Sm" . "math symbol")
1191 ("Sc" . "currency symbol")
1192 ("Sk" . "modifier symbol")
1193 ("So" . "other symbol")))))
1194 (list "Combining class"
1195 (cdr (assoc
1196 (string-to-number (nth 2 fields))
1197 '((0 . "Spacing")
1198 (1 . "Overlays and interior")
1199 (7 . "Nuktas")
1200 (8 . "Hiragana/Katakana voicing marks")
1201 (9 . "Viramas")
1202 (10 . "Start of fixed position classes")
1203 (199 . "End of fixed position classes")
1204 (200 . "Below left attached")
1205 (202 . "Below attached")
1206 (204 . "Below right attached")
1207 (208 . "Left attached (reordrant around \
1208 single base character)")
1209 (210 . "Right attached")
1210 (212 . "Above left attached")
1211 (214 . "Above attached")
1212 (216 . "Above right attached")
1213 (218 . "Below left")
1214 (220 . "Below")
1215 (222 . "Below right")
1216 (224 . "Left (reordrant around single base \
1217 character)")
1218 (226 . "Right")
1219 (228 . "Above left")
1220 (230 . "Above")
1221 (232 . "Above right")
1222 (233 . "Double below")
1223 (234 . "Double above")
1224 (240 . "Below (iota subscript)")))))
1225 (list "Bidi category"
1226 (cdr (assoc
1227 (nth 3 fields)
1228 '(("L" . "Left-to-Right")
1229 ("LRE" . "Left-to-Right Embedding")
1230 ("LRO" . "Left-to-Right Override")
1231 ("R" . "Right-to-Left")
1232 ("AL" . "Right-to-Left Arabic")
1233 ("RLE" . "Right-to-Left Embedding")
1234 ("RLO" . "Right-to-Left Override")
1235 ("PDF" . "Pop Directional Format")
1236 ("EN" . "European Number")
1237 ("ES" . "European Number Separator")
1238 ("ET" . "European Number Terminator")
1239 ("AN" . "Arabic Number")
1240 ("CS" . "Common Number Separator")
1241 ("NSM" . "Non-Spacing Mark")
1242 ("BN" . "Boundary Neutral")
1243 ("B" . "Paragraph Separator")
1244 ("S" . "Segment Separator")
1245 ("WS" . "Whitespace")
1246 ("ON" . "Other Neutrals")))))
1247 (list "Decomposition"
1248 (if (nth 4 fields)
1249 (let* ((parts (split-string (nth 4 fields)))
1250 (info (car parts)))
1251 (if (string-match "\\`<\\(.+\\)>\\'" info)
1252 (setq info (match-string 1 info))
1253 (setq info nil))
1254 (if info (setq parts (cdr parts)))
1255 (setq parts (mapconcat
1256 (lambda (arg)
1257 (string (string-to-number arg 16)))
1258 parts " "))
1259 (concat info parts))))
1260 (list "Decimal digit value"
1261 (nth 5 fields))
1262 (list "Digit value"
1263 (nth 6 fields))
1264 (list "Numeric value"
1265 (nth 7 fields))
1266 (list "Mirrored"
1267 (if (equal "Y" (nth 8 fields))
1268 "yes"))
1269 (list "Old name" (nth 9 fields))
1270 (list "ISO 10646 comment" (nth 10 fields))
1271 (list "Uppercase" (and (nth 11 fields)
1272 (string (string-to-number
1273 (nth 11 fields) 16))))
1274 (list "Lowercase" (and (nth 12 fields)
1275 (string (string-to-number
1276 (nth 12 fields) 16))))
1277 (list "Titlecase" (and (nth 13 fields)
1278 (string (string-to-number
1279 (nth 13 fields) 16)))))))))))
1280
1281 (provide 'mule-diag)
1282
1283 ;;; arch-tag: cd3b607c-2893-45a0-a4fa-a6535754dbee
1284 ;;; mule-diag.el ends here