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