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