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