Mention `delete-frame-functions' replacing `delete-frame-hook',
[emacs.git] / lisp / international / mule-diag.el
blob78c0e1c0e6ef03b7abf62eb19e56551a0b71bf68
1 ;;; mule-diag.el --- show diagnosis of multilingual environment (Mule)
3 ;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN.
4 ;; Licensed to the Free Software Foundation.
5 ;; Copyright (C) 2001, 2002 Free Software Foundation, Inc.
7 ;; Keywords: multilingual, charset, coding system, fontset, diagnosis, i18n
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; any later version.
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
26 ;;; Commentary:
28 ;;; Code:
30 ;; Make sure the help-xref button type is defined.
31 (require 'help-fns)
33 ;;; General utility function
35 ;; Print all arguments with single space separator in one line.
36 (defun print-list (&rest args)
37 (while (cdr args)
38 (when (car args)
39 (princ (car args))
40 (princ " "))
41 (setq args (cdr args)))
42 (princ (car args))
43 (princ "\n"))
45 ;; Re-order the elements of charset-list.
46 (defun sort-charset-list ()
47 (setq charset-list
48 (sort charset-list
49 (lambda (x y) (< (charset-id x) (charset-id y))))))
51 ;;; CHARSET
53 (define-button-type 'sort-listed-character-sets
54 'help-echo (purecopy "mouse-2, RET: sort on this column")
55 'face 'bold
56 'action #'(lambda (button)
57 (sort-listed-character-sets (button-get button 'sort-key))))
59 (define-button-type 'list-charset-chars
60 :supertype 'help-xref
61 'help-function #'list-charset-chars
62 'help-echo "mouse-2, RET: show table of characters for this character set")
65 ;;;###autoload
66 (defun list-character-sets (arg)
67 "Display a list of all character sets.
69 The ID-NUM column contains a charset identification number for
70 internal Emacs use.
72 The MULTIBYTE-FORM column contains the format of the buffer and string
73 multibyte sequence of characters in the charset using one to four
74 hexadecimal digits.
75 `xx' stands for any byte in the range 0..127.
76 `XX' stands for any byte in the range 160..255.
78 The D column contains the dimension of this character set. The CH
79 column contains the number of characters in a block of this character
80 set. The FINAL-CHAR column contains an ISO-2022 <final-char> to use
81 for designating this character set in ISO-2022-based coding systems.
83 With prefix arg, the output format gets more cryptic,
84 but still shows the full information."
85 (interactive "P")
86 (help-setup-xref (list #'list-character-sets arg) (interactive-p))
87 (with-output-to-temp-buffer "*Character Set List*"
88 (with-current-buffer standard-output
89 (if arg
90 (list-character-sets-2)
91 ;; Insert header.
92 (insert "Indirectly supported character sets are shown below.\n")
93 (insert
94 (substitute-command-keys
95 (concat "Use "
96 (if (display-mouse-p) "\\[help-follow-mouse] or ")
97 "\\[help-follow]:\n")))
98 (insert " on a column title to sort by that title,")
99 (indent-to 56)
100 (insert "+----DIMENSION\n")
101 (insert " on a charset name to list characters.")
102 (indent-to 56)
103 (insert "| +--CHARS\n")
104 (let ((columns '(("ID-NUM" . id) "\t"
105 ("CHARSET-NAME" . name) "\t\t\t"
106 ("MULTIBYTE-FORM" . id) "\t"
107 ("D CH FINAL-CHAR" . iso-spec)))
108 pos)
109 (while columns
110 (if (stringp (car columns))
111 (insert (car columns))
112 (insert-text-button (car (car columns))
113 :type 'sort-listed-character-sets
114 'sort-key (cdr (car columns)))
115 (goto-char (point-max)))
116 (setq columns (cdr columns)))
117 (insert "\n"))
118 (insert "------\t------------\t\t\t--------------\t- -- ----------\n")
120 ;; Insert body sorted by charset IDs.
121 (list-character-sets-1 'id)
123 ;; Insert non-directly-supported charsets.
124 (insert-char ?- 72)
125 (insert "\n\nINDIRECTLY SUPPORTED CHARSETS SETS:\n\n"
126 (propertize "CHARSET NAME\tMAPPED TO" 'face 'bold)
127 "\n------------\t---------\n")
128 (dolist (elt non-iso-charset-alist)
129 (insert-text-button (symbol-name (car elt))
130 :type 'list-charset-chars
131 'help-args (list (car elt)))
132 (indent-to 16)
133 (dolist (e (nth 1 elt))
134 (when (>= (+ (current-column) 1 (string-width (symbol-name e)))
135 ;; This is an approximate value. We don't know
136 ;; the correct window width of this buffer yet.
138 (insert "\n")
139 (indent-to 16))
141 (insert (format "%s " e)))
142 (insert "\n"))))))
144 (defun sort-listed-character-sets (sort-key)
145 (if sort-key
146 (save-excursion
147 (help-setup-xref (list #'list-character-sets nil) t)
148 (let ((buffer-read-only nil))
149 (goto-char (point-min))
150 (re-search-forward "[0-9][0-9][0-9]")
151 (beginning-of-line)
152 (let ((pos (point)))
153 (search-forward "----------")
154 (beginning-of-line)
155 (save-restriction
156 (narrow-to-region pos (point))
157 (delete-region (point-min) (point-max))
158 (list-character-sets-1 sort-key)))))))
160 (defun charset-multibyte-form-string (charset)
161 (let ((info (charset-info charset)))
162 (cond ((eq charset 'ascii)
163 "xx")
164 ((eq charset 'eight-bit-control)
165 (format "%2X Xx" (aref info 6)))
166 ((eq charset 'eight-bit-graphic)
167 "XX")
169 (let ((str (format "%2X" (aref info 6))))
170 (if (> (aref info 7) 0)
171 (setq str (format "%s %2X"
172 str (aref info 7))))
173 (setq str (concat str " XX"))
174 (if (> (aref info 2) 1)
175 (setq str (concat str " XX")))
176 str)))))
178 ;; Insert a list of character sets sorted by SORT-KEY. SORT-KEY
179 ;; should be one of `id', `name', and `iso-spec'. If SORT-KEY is nil,
180 ;; it defaults to `id'.
182 (defun list-character-sets-1 (sort-key)
183 (or sort-key
184 (setq sort-key 'id))
185 (let ((tail (charset-list))
186 charset-info-list elt charset info sort-func)
187 (while tail
188 (setq charset (car tail) tail (cdr tail)
189 info (charset-info charset))
191 ;; Generate a list that contains all information to display.
192 (setq charset-info-list
193 (cons (list (charset-id charset) ; ID-NUM
194 charset ; CHARSET-NAME
195 (charset-multibyte-form-string charset); MULTIBYTE-FORM
196 (aref info 2) ; DIMENSION
197 (aref info 3) ; CHARS
198 (aref info 8) ; FINAL-CHAR
200 charset-info-list)))
202 ;; Determine a predicate for `sort' by SORT-KEY.
203 (setq sort-func
204 (cond ((eq sort-key 'id)
205 (lambda (x y) (< (car x) (car y))))
207 ((eq sort-key 'name)
208 (lambda (x y) (string< (nth 1 x) (nth 1 y))))
210 ((eq sort-key 'iso-spec)
211 ;; Sort by DIMENSION CHARS FINAL-CHAR
212 (lambda (x y)
213 (or (< (nth 3 x) (nth 3 y))
214 (and (= (nth 3 x) (nth 3 y))
215 (or (< (nth 4 x) (nth 4 y))
216 (and (= (nth 4 x) (nth 4 y))
217 (< (nth 5 x) (nth 5 y))))))))
219 (error "Invalid charset sort key: %s" sort-key))))
221 (setq charset-info-list (sort charset-info-list sort-func))
223 ;; Insert information of character sets.
224 (while charset-info-list
225 (setq elt (car charset-info-list)
226 charset-info-list (cdr charset-info-list))
227 (insert (format "%03d(%02X)" (car elt) (car elt))) ; ID-NUM
228 (indent-to 8)
229 (insert-text-button (symbol-name (nth 1 elt))
230 :type 'list-charset-chars
231 'help-args (list (nth 1 elt)))
232 (goto-char (point-max))
233 (insert "\t")
234 (indent-to 40)
235 (insert (nth 2 elt)) ; MULTIBYTE-FORM
236 (indent-to 56)
237 (insert (format "%d %2d " (nth 3 elt) (nth 4 elt)) ; DIMENSION and CHARS
238 (if (< (nth 5 elt) 0) "none" (nth 5 elt))) ; FINAL-CHAR
239 (insert "\n"))))
242 ;; List all character sets in a form that a program can easily parse.
244 (defun list-character-sets-2 ()
245 (insert "#########################
246 ## LIST OF CHARSETS
247 ## Each line corresponds to one charset.
248 ## The following attributes are listed in this order
249 ## separated by a colon `:' in one line.
250 ## CHARSET-ID,
251 ## CHARSET-SYMBOL-NAME,
252 ## DIMENSION (1 or 2)
253 ## CHARS (94 or 96)
254 ## BYTES (of multibyte form: 1, 2, 3, or 4),
255 ## WIDTH (occupied column numbers: 1 or 2),
256 ## DIRECTION (0:left-to-right, 1:right-to-left),
257 ## ISO-FINAL-CHAR (character code of ISO-2022's final character)
258 ## ISO-GRAPHIC-PLANE (ISO-2022's graphic plane, 0:GL, 1:GR)
259 ## DESCRIPTION (describing string of the charset)
261 (let ((l charset-list)
262 charset)
263 (while l
264 (setq charset (car l) l (cdr l))
265 (princ (format "%03d:%s:%d:%d:%d:%d:%d:%d:%d:%s\n"
266 (charset-id charset)
267 charset
268 (charset-dimension charset)
269 (charset-chars charset)
270 (charset-bytes charset)
271 (charset-width charset)
272 (charset-direction charset)
273 (charset-iso-final-char charset)
274 (charset-iso-graphic-plane charset)
275 (charset-description charset))))))
277 (defvar non-iso-charset-alist
278 `((mac-roman
279 (ascii latin-iso8859-1 mule-unicode-2500-33ff
280 mule-unicode-0100-24ff mule-unicode-e000-ffff)
281 mac-roman-decoder
282 ((0 255)))
283 (viscii
284 (ascii vietnamese-viscii-lower vietnamese-viscii-upper)
285 viet-viscii-nonascii-translation-table
286 ((0 255)))
287 (koi8-r
288 (ascii cyrillic-iso8859-5)
289 cyrillic-koi8-r-nonascii-translation-table
290 ((32 255)))
291 (alternativnyj
292 (ascii cyrillic-iso8859-5)
293 cyrillic-alternativnyj-nonascii-translation-table
294 ((32 255)))
295 (big5
296 (ascii chinese-big5-1 chinese-big5-2)
297 decode-big5-char
298 ((32 127)
299 ((?\xA1 ?\xFE) . (?\x40 ?\x7E ?\xA1 ?\xFE))))
300 (sjis
301 (ascii katakana-jisx0201 japanese-jisx0208)
302 decode-sjis-char
303 ((32 127 ?\xA1 ?\xDF)
304 ((?\x81 ?\x9F ?\xE0 ?\xEF) . (?\x40 ?\x7E ?\x80 ?\xFC)))))
305 "Alist of charset names vs the corresponding information.
306 This is mis-named for historical reasons. The charsets are actually
307 non-built-in ones. They correspond to Emacs coding systems, not Emacs
308 charsets, i.e. what Emacs can read (or write) by mapping to (or
309 from) Emacs internal charsets that typically correspond to a limited
310 set of ISO charsets.
312 Each element has the following format:
313 (CHARSET CHARSET-LIST TRANSLATION-METHOD [ CODE-RANGE ])
315 CHARSET is the name (symbol) of the charset.
317 CHARSET-LIST is a list of Emacs charsets into which characters of
318 CHARSET are mapped.
320 TRANSLATION-METHOD is a translation table (symbol) to translate a
321 character code of CHARSET to the corresponding Emacs character
322 code. It can also be a function to call with one argument, a
323 character code in CHARSET.
325 CODE-RANGE specifies the valid code ranges of CHARSET.
326 It is a list of RANGEs, where each RANGE is of the form:
327 (FROM1 TO1 FROM2 TO2 ...)
329 ((FROM1-1 TO1-1 FROM1-2 TO1-2 ...) . (FROM2-1 TO2-1 FROM2-2 TO2-2 ...))
330 In the first form, valid codes are between FROM1 and TO1, or FROM2 and
331 TO2, or...
332 The second form is used for 2-byte codes. The car part is the ranges
333 of the first byte, and the cdr part is the ranges of the second byte.")
336 (defun decode-codepage-char (codepage code)
337 "Decode a character that has code CODE in CODEPAGE.
338 Return a decoded character string. Each CODEPAGE corresponds to a
339 coding system cpCODEPAGE."
340 (let ((coding-system (intern (format "cp%d" codepage))))
341 (or (coding-system-p coding-system)
342 (codepage-setup codepage))
343 (string-to-char
344 (decode-coding-string (char-to-string code) coding-system))))
347 ;; Add DOS codepages to `non-iso-charset-alist'.
349 (let ((tail (cp-supported-codepages))
350 elt)
351 (while tail
352 (setq elt (car tail) tail (cdr tail))
353 ;; Now ELT is (CODEPAGE . CHARSET), where CODEPAGE is a string
354 ;; (e.g. "850"), CHARSET is a charset that characters in CODEPAGE
355 ;; are mapped to.
356 (unless (assq (intern (concat "cp" (car elt))) non-iso-charset-alist)
357 (setq non-iso-charset-alist
358 (cons (list (intern (concat "cp" (car elt)))
359 (list 'ascii (cdr elt))
360 `(lambda (code)
361 (decode-codepage-char ,(string-to-int (car elt))
362 code))
363 (list (list 0 255)))
364 non-iso-charset-alist)))))
367 ;; A variable to hold charset input history.
368 (defvar charset-history nil)
371 ;;;###autoload
372 (defun read-charset (prompt &optional default-value initial-input)
373 "Read a character set from the minibuffer, prompting with string PROMPT.
374 It must be an Emacs character set listed in the variable `charset-list'
375 or a non-ISO character set listed in the variable
376 `non-iso-charset-alist'.
378 Optional arguments are DEFAULT-VALUE and INITIAL-INPUT.
379 DEFAULT-VALUE, if non-nil, is the default value.
380 INITIAL-INPUT, if non-nil, is a string inserted in the minibuffer initially.
381 See the documentation of the function `completing-read' for the
382 detailed meanings of these arguments."
383 (let* ((table (append (mapcar (lambda (x) (list (symbol-name x)))
384 charset-list)
385 (mapcar (lambda (x) (list (symbol-name (car x))))
386 non-iso-charset-alist)))
387 (charset (completing-read prompt table
388 nil t initial-input 'charset-history
389 default-value)))
390 (if (> (length charset) 0)
391 (intern charset))))
394 ;; List characters of the range MIN and MAX of CHARSET. If dimension
395 ;; of CHARSET is two (i.e. 2-byte charset), ROW is the first byte
396 ;; (block index) of the characters, and MIN and MAX are the second
397 ;; bytes of the characters. If the dimension is one, ROW should be 0.
398 ;; For a non-ISO charset, CHARSET is a translation table (symbol) or a
399 ;; function to get Emacs' character codes that corresponds to the
400 ;; characters to list.
402 (defun list-block-of-chars (charset row min max)
403 (let (i ch)
404 (insert-char ?- (+ 4 (* 3 16)))
405 (insert "\n ")
406 (setq i 0)
407 (while (< i 16)
408 (insert (format "%3X" i))
409 (setq i (1+ i)))
410 (setq i (* (/ min 16) 16))
411 (while (<= i max)
412 (if (= (% i 16) 0)
413 (insert (format "\n%3Xx" (/ (+ (* row 256) i) 16))))
414 (setq ch (cond ((< i min)
416 ((charsetp charset)
417 (if (= row 0)
418 (make-char charset i)
419 (make-char charset row i)))
420 ((and (symbolp charset) (get charset 'translation-table))
421 (aref (get charset 'translation-table) i))
422 (t (funcall charset (+ (* row 256) i)))))
423 (if (and (char-table-p charset)
424 (or (< ch 32) (and (>= ch 127) (<= ch 255))))
425 ;; Don't insert a control code.
426 (setq ch 32))
427 (unless ch (setq ch 32))
428 (if (eq ch ?\t)
429 ;; Make it visible.
430 (setq ch (propertize "\t" 'display "^I")))
431 ;; This doesn't DTRT. Maybe it's better to insert "^J" and not
432 ;; worry about the buffer contents not being correct.
433 ;;; (if (eq ch ?\n)
434 ;;; (setq ch (propertize "\n" 'display "^J")))
435 (indent-to (+ (* (% i 16) 3) 6))
436 (insert ch)
437 (setq i (1+ i))))
438 (insert "\n"))
440 (defun list-iso-charset-chars (charset)
441 (let ((dim (charset-dimension charset))
442 (chars (charset-chars charset))
443 (plane (charset-iso-graphic-plane charset))
444 min max)
445 (insert (format "Characters in the coded character set %s.\n" charset))
447 (cond ((eq charset 'eight-bit-control)
448 (setq min 128 max 159))
449 ((eq charset 'eight-bit-graphic)
450 (setq min 160 max 255))
452 (if (= chars 94)
453 (setq min 33 max 126)
454 (setq min 32 max 127))
455 (or (= plane 0)
456 (setq min (+ min 128) max (+ max 128)))))
458 (if (= dim 1)
459 (list-block-of-chars charset 0 min max)
460 (let ((i min))
461 (while (<= i max)
462 (list-block-of-chars charset i min max)
463 (setq i (1+ i)))))))
465 (defun list-non-iso-charset-chars (charset)
466 "List all characters in non-built-in coded character set CHARSET."
467 (let* ((slot (assq charset non-iso-charset-alist))
468 (charsets (nth 1 slot))
469 (translate-method (nth 2 slot))
470 (ranges (nth 3 slot))
471 range)
472 (or slot
473 (error "Unknown character set: %s" charset))
474 (insert (format "Characters in the coded character set %s.\n" charset))
475 (if charsets
476 (insert "They are mapped to: "
477 (mapconcat #'symbol-name charsets ", ")
478 "\n"))
479 (while ranges
480 (setq range (pop ranges))
481 (if (integerp (car range))
482 ;; The form of RANGES is (FROM1 TO1 FROM2 TO2 ...).
483 (if (and (not (functionp translate-method))
484 (< (car (last range)) 256))
485 ;; Do it all in one block to avoid the listing being
486 ;; broken up at gaps in the range. Don't do that for
487 ;; function translate-method, since not all codes in
488 ;; that range may be valid.
489 (list-block-of-chars translate-method
490 0 (car range) (car (last range)))
491 (while range
492 (list-block-of-chars translate-method
493 0 (car range) (nth 1 range))
494 (setq range (nthcdr 2 range))))
495 ;; The form of RANGES is ((FROM1-1 TO1-1 ...) . (FROM2-1 TO2-1 ...)).
496 (let ((row-range (car range))
497 row row-max
498 col-range col col-max)
499 (while row-range
500 (setq row (car row-range) row-max (nth 1 row-range)
501 row-range (nthcdr 2 row-range))
502 (while (<= row row-max)
503 (setq col-range (cdr range))
504 (while col-range
505 (setq col (car col-range) col-max (nth 1 col-range)
506 col-range (nthcdr 2 col-range))
507 (list-block-of-chars translate-method row col col-max))
508 (setq row (1+ row)))))))))
511 ;;;###autoload
512 (defun list-charset-chars (charset)
513 "Display a list of characters in the specified character set.
514 This can list both Emacs `official' (ISO standard) charsets and the
515 characters encoded by various Emacs coding systems which correspond to
516 PC `codepages' and other coded character sets. See `non-iso-charset-alist'."
517 (interactive (list (read-charset "Character set: ")))
518 (with-output-to-temp-buffer "*Character List*"
519 (with-current-buffer standard-output
520 (setq mode-line-format (copy-sequence mode-line-format))
521 (let ((slot (memq 'mode-line-buffer-identification mode-line-format)))
522 (if slot
523 (setcdr slot
524 (cons (format " (%s)" charset)
525 (cdr slot)))))
526 (setq indent-tabs-mode nil)
527 (set-buffer-multibyte t)
528 (cond ((charsetp charset)
529 (list-iso-charset-chars charset))
530 ((assq charset non-iso-charset-alist)
531 (list-non-iso-charset-chars charset))
533 (error "Invalid character set %s" charset))))))
536 ;;;###autoload
537 (defun describe-character-set (charset)
538 "Display information about built-in character set CHARSET."
539 (interactive (list (let ((non-iso-charset-alist nil))
540 (read-charset "Charset: "))))
541 (or (charsetp charset)
542 (error "Invalid charset: %S" charset))
543 (let ((info (charset-info charset)))
544 (help-setup-xref (list #'describe-character-set charset) (interactive-p))
545 (with-output-to-temp-buffer (help-buffer)
546 (with-current-buffer standard-output
547 (insert "Character set: " (symbol-name charset)
548 (format " (ID:%d)\n\n" (aref info 0)))
549 (insert (aref info 13) "\n\n") ; description
550 (insert "Number of contained characters: "
551 (if (= (aref info 2) 1)
552 (format "%d\n" (aref info 3))
553 (format "%dx%d\n" (aref info 3) (aref info 3))))
554 (insert "Final char of ISO2022 designation sequence: ")
555 (if (>= (aref info 8) 0)
556 (insert (format "`%c'\n" (aref info 8)))
557 (insert "not assigned\n"))
558 (insert (format "Width (how many columns on screen): %d\n"
559 (aref info 4)))
560 (insert (format "Internal multibyte sequence: %s\n"
561 (charset-multibyte-form-string charset)))
562 (let ((coding (plist-get (aref info 14) 'preferred-coding-system)))
563 (when coding
564 (insert (format "Preferred coding system: %s\n" coding))
565 (search-backward (symbol-name coding))
566 (help-xref-button 0 'help-coding-system coding)))))))
568 ;;; CODING-SYSTEM
570 ;; Print information of designation of each graphic register in FLAGS
571 ;; in human readable format. See the documentation of
572 ;; `make-coding-system' for the meaning of FLAGS.
573 (defun print-designation (flags)
574 (let ((graphic-register 0)
575 charset)
576 (while (< graphic-register 4)
577 (setq charset (aref flags graphic-register))
578 (princ (format
579 " G%d -- %s\n"
580 graphic-register
581 (cond ((null charset)
582 "never used")
583 ((eq charset t)
584 "no initial designation, and used by any charsets")
585 ((symbolp charset)
586 (format "%s:%s"
587 charset (charset-description charset)))
588 ((listp charset)
589 (if (charsetp (car charset))
590 (format "%s:%s, and also used by the followings:"
591 (car charset)
592 (charset-description (car charset)))
593 "no initial designation, and used by the followings:"))
595 "invalid designation information"))))
596 (when (listp charset)
597 (setq charset (cdr charset))
598 (while charset
599 (cond ((eq (car charset) t)
600 (princ "\tany other charsets\n"))
601 ((charsetp (car charset))
602 (princ (format "\t%s:%s\n"
603 (car charset)
604 (charset-description (car charset)))))
606 "invalid designation information"))
607 (setq charset (cdr charset))))
608 (setq graphic-register (1+ graphic-register)))))
610 ;;;###autoload
611 (defun describe-coding-system (coding-system)
612 "Display information about CODING-SYSTEM."
613 (interactive "zDescribe coding system (default, current choices): ")
614 (if (null coding-system)
615 (describe-current-coding-system)
616 (help-setup-xref (list #'describe-coding-system coding-system)
617 (interactive-p))
618 (with-output-to-temp-buffer (help-buffer)
619 (print-coding-system-briefly coding-system 'doc-string)
620 (princ "\n")
621 (let ((vars (coding-system-get coding-system 'dependency)))
622 (when vars
623 (princ "See also the documentation of these customizable variables
624 which alter the behaviour of this coding system.\n")
625 (dolist (v vars)
626 (princ " `")
627 (princ v)
628 (princ "'\n"))
629 (princ "\n")))
631 (princ "Type: ")
632 (let ((type (coding-system-type coding-system))
633 (flags (coding-system-flags coding-system)))
634 (princ type)
635 (cond ((eq type nil)
636 (princ " (do no conversion)"))
637 ((eq type t)
638 (princ " (do automatic conversion)"))
639 ((eq type 0)
640 (princ " (Emacs internal multibyte form)"))
641 ((eq type 1)
642 (princ " (Shift-JIS, MS-KANJI)"))
643 ((eq type 2)
644 (princ " (variant of ISO-2022)\n")
645 (princ "Initial designations:\n")
646 (print-designation flags)
647 (princ "Other Form: \n ")
648 (princ (if (aref flags 4) "short-form" "long-form"))
649 (if (aref flags 5) (princ ", ASCII@EOL"))
650 (if (aref flags 6) (princ ", ASCII@CNTL"))
651 (princ (if (aref flags 7) ", 7-bit" ", 8-bit"))
652 (if (aref flags 8) (princ ", use-locking-shift"))
653 (if (aref flags 9) (princ ", use-single-shift"))
654 (if (aref flags 10) (princ ", use-roman"))
655 (if (aref flags 11) (princ ", use-old-jis"))
656 (if (aref flags 12) (princ ", no-ISO6429"))
657 (if (aref flags 13) (princ ", init-bol"))
658 (if (aref flags 14) (princ ", designation-bol"))
659 (if (aref flags 15) (princ ", convert-unsafe"))
660 (if (aref flags 16) (princ ", accept-latin-extra-code"))
661 (princ "."))
662 ((eq type 3)
663 (princ " (Big5)"))
664 ((eq type 4)
665 (princ " (do conversion by CCL program)"))
666 ((eq type 5)
667 (princ " (text with random binary characters)"))
668 (t (princ ": invalid coding-system."))))
669 (princ "\nEOL type: ")
670 (let ((eol-type (coding-system-eol-type coding-system)))
671 (cond ((vectorp eol-type)
672 (princ "Automatic selection from:\n\t")
673 (princ eol-type)
674 (princ "\n"))
675 ((or (null eol-type) (eq eol-type 0)) (princ "LF\n"))
676 ((eq eol-type 1) (princ "CRLF\n"))
677 ((eq eol-type 2) (princ "CR\n"))
678 (t (princ "invalid\n"))))
679 (let ((postread (coding-system-get coding-system 'post-read-conversion)))
680 (when postread
681 (princ "After decoding text normally,")
682 (princ " perform post-conversion using the function: ")
683 (princ "\n ")
684 (princ postread)
685 (princ "\n")))
686 (let ((prewrite (coding-system-get coding-system 'pre-write-conversion)))
687 (when prewrite
688 (princ "Before encoding text normally,")
689 (princ " perform pre-conversion using the function: ")
690 (princ "\n ")
691 (princ prewrite)
692 (princ "\n")))
693 (with-current-buffer standard-output
694 (let ((charsets (coding-system-get coding-system 'safe-charsets)))
695 (when (and (not (memq (coding-system-base coding-system)
696 '(raw-text emacs-mule)))
697 charsets)
698 (if (eq charsets t)
699 (insert "This coding system can encode all charsets except for
700 eight-bit-control and eight-bit-graphic.\n")
701 (insert "This coding system encodes the following charsets:\n ")
702 (while charsets
703 (insert " " (symbol-name (car charsets)))
704 (search-backward (symbol-name (car charsets)))
705 (help-xref-button 0 'help-character-set (car charsets))
706 (goto-char (point-max))
707 (setq charsets (cdr charsets))))))))))
710 ;;;###autoload
711 (defun describe-current-coding-system-briefly ()
712 "Display coding systems currently used in a brief format in echo area.
714 The format is \"F[..],K[..],T[..],P>[..],P<[..], default F[..],P<[..],P<[..]\",
715 where mnemonics of the following coding systems come in this order
716 in place of `..':
717 `buffer-file-coding-system' (of the current buffer)
718 eol-type of `buffer-file-coding-system' (of the current buffer)
719 Value returned by `keyboard-coding-system'
720 eol-type of `keyboard-coding-system'
721 Value returned by `terminal-coding-system'.
722 eol-type of `terminal-coding-system'
723 `process-coding-system' for read (of the current buffer, if any)
724 eol-type of `process-coding-system' for read (of the current buffer, if any)
725 `process-coding-system' for write (of the current buffer, if any)
726 eol-type of `process-coding-system' for write (of the current buffer, if any)
727 `default-buffer-file-coding-system'
728 eol-type of `default-buffer-file-coding-system'
729 `default-process-coding-system' for read
730 eol-type of `default-process-coding-system' for read
731 `default-process-coding-system' for write
732 eol-type of `default-process-coding-system'"
733 (interactive)
734 (let* ((proc (get-buffer-process (current-buffer)))
735 (process-coding-systems (if proc (process-coding-system proc))))
736 (message
737 "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]"
738 (coding-system-mnemonic buffer-file-coding-system)
739 (coding-system-eol-type-mnemonic buffer-file-coding-system)
740 (coding-system-mnemonic (keyboard-coding-system))
741 (coding-system-eol-type-mnemonic (keyboard-coding-system))
742 (coding-system-mnemonic (terminal-coding-system))
743 (coding-system-eol-type-mnemonic (terminal-coding-system))
744 (coding-system-mnemonic (car process-coding-systems))
745 (coding-system-eol-type-mnemonic (car process-coding-systems))
746 (coding-system-mnemonic (cdr process-coding-systems))
747 (coding-system-eol-type-mnemonic (cdr process-coding-systems))
748 (coding-system-mnemonic default-buffer-file-coding-system)
749 (coding-system-eol-type-mnemonic default-buffer-file-coding-system)
750 (coding-system-mnemonic (car default-process-coding-system))
751 (coding-system-eol-type-mnemonic (car default-process-coding-system))
752 (coding-system-mnemonic (cdr default-process-coding-system))
753 (coding-system-eol-type-mnemonic (cdr default-process-coding-system))
756 ;; Print symbol name and mnemonic letter of CODING-SYSTEM with `princ'.
757 (defun print-coding-system-briefly (coding-system &optional doc-string)
758 (if (not coding-system)
759 (princ "nil\n")
760 (princ (format "%c -- %s"
761 (coding-system-mnemonic coding-system)
762 coding-system))
763 (let ((aliases (coding-system-get coding-system 'alias-coding-systems)))
764 (cond ((eq coding-system (car aliases))
765 (if (cdr aliases)
766 (princ (format " %S" (cons 'alias: (cdr aliases))))))
767 ((memq coding-system aliases)
768 (princ (format " (alias of %s)" (car aliases))))
770 (let ((eol-type (coding-system-eol-type coding-system))
771 (base-eol-type (coding-system-eol-type (car aliases))))
772 (if (and (integerp eol-type)
773 (vectorp base-eol-type)
774 (not (eq coding-system (aref base-eol-type eol-type))))
775 (princ (format " (alias of %s)"
776 (aref base-eol-type eol-type))))))))
777 (princ "\n\n")
778 (if (and doc-string
779 (setq doc-string (coding-system-doc-string coding-system)))
780 (princ (format "%s\n" doc-string)))))
782 ;;;###autoload
783 (defun describe-current-coding-system ()
784 "Display coding systems currently used, in detail."
785 (interactive)
786 (with-output-to-temp-buffer "*Help*"
787 (let* ((proc (get-buffer-process (current-buffer)))
788 (process-coding-systems (if proc (process-coding-system proc))))
789 (princ "Coding system for saving this buffer:\n ")
790 (if (local-variable-p 'buffer-file-coding-system)
791 (print-coding-system-briefly buffer-file-coding-system)
792 (princ "Not set locally, use the default.\n"))
793 (princ "Default coding system (for new files):\n ")
794 (print-coding-system-briefly default-buffer-file-coding-system)
795 (princ "Coding system for keyboard input:\n ")
796 (print-coding-system-briefly (keyboard-coding-system))
797 (princ "Coding system for terminal output:\n ")
798 (print-coding-system-briefly (terminal-coding-system))
799 (when (get-buffer-process (current-buffer))
800 (princ "Coding systems for process I/O:\n")
801 (princ " encoding input to the process: ")
802 (print-coding-system-briefly (cdr process-coding-systems))
803 (princ " decoding output from the process: ")
804 (print-coding-system-briefly (car process-coding-systems)))
805 (princ "Defaults for subprocess I/O:\n")
806 (princ " decoding: ")
807 (print-coding-system-briefly (car default-process-coding-system))
808 (princ " encoding: ")
809 (print-coding-system-briefly (cdr default-process-coding-system)))
811 (with-current-buffer standard-output
813 (princ "
814 Priority order for recognizing coding systems when reading files:\n")
815 (let ((l coding-category-list)
816 (i 1)
817 (coding-list nil)
818 coding aliases)
819 (while l
820 (setq coding (symbol-value (car l)))
821 ;; Do not list up the same coding system twice.
822 (when (and coding (not (memq coding coding-list)))
823 (setq coding-list (cons coding coding-list))
824 (princ (format " %d. %s " i coding))
825 (setq aliases (coding-system-get coding 'alias-coding-systems))
826 (if (eq coding (car aliases))
827 (if (cdr aliases)
828 (princ (cons 'alias: (cdr aliases))))
829 (if (memq coding aliases)
830 (princ (list 'alias 'of (car aliases)))))
831 (terpri)
832 (setq i (1+ i)))
833 (setq l (cdr l))))
835 (princ "\n Other coding systems cannot be distinguished automatically
836 from these, and therefore cannot be recognized automatically
837 with the present coding system priorities.\n\n")
839 (let ((categories '(coding-category-iso-7 coding-category-iso-7-else))
840 coding-system codings)
841 (while categories
842 (setq coding-system (symbol-value (car categories)))
843 (mapcar
844 (lambda (x)
845 (if (and (not (eq x coding-system))
846 (coding-system-get x 'no-initial-designation)
847 (let ((flags (coding-system-flags x)))
848 (not (or (aref flags 10) (aref flags 11)))))
849 (setq codings (cons x codings))))
850 (get (car categories) 'coding-systems))
851 (if codings
852 (let ((max-col (frame-width))
853 pos)
854 (princ (format "\
855 The following are decoded correctly but recognized as %s:\n "
856 coding-system))
857 (while codings
858 (setq pos (point))
859 (insert (format " %s" (car codings)))
860 (when (> (current-column) max-col)
861 (goto-char pos)
862 (insert "\n ")
863 (goto-char (point-max)))
864 (setq codings (cdr codings)))
865 (insert "\n\n")))
866 (setq categories (cdr categories))))
868 (princ "Particular coding systems specified for certain file names:\n")
869 (terpri)
870 (princ " OPERATION\tTARGET PATTERN\t\tCODING SYSTEM(s)\n")
871 (princ " ---------\t--------------\t\t----------------\n")
872 (let ((func (lambda (operation alist)
873 (princ " ")
874 (princ operation)
875 (if (not alist)
876 (princ "\tnothing specified\n")
877 (while alist
878 (indent-to 16)
879 (prin1 (car (car alist)))
880 (if (>= (current-column) 40)
881 (newline))
882 (indent-to 40)
883 (princ (cdr (car alist)))
884 (princ "\n")
885 (setq alist (cdr alist)))))))
886 (funcall func "File I/O" file-coding-system-alist)
887 (funcall func "Process I/O" process-coding-system-alist)
888 (funcall func "Network I/O" network-coding-system-alist))
889 (help-mode))))
891 ;; Print detailed information on CODING-SYSTEM.
892 (defun print-coding-system (coding-system)
893 (let ((type (coding-system-type coding-system))
894 (eol-type (coding-system-eol-type coding-system))
895 (flags (coding-system-flags coding-system))
896 (aliases (coding-system-get coding-system 'alias-coding-systems)))
897 (if (not (eq (car aliases) coding-system))
898 (princ (format "%s (alias of %s)\n" coding-system (car aliases)))
899 (princ coding-system)
900 (setq aliases (cdr aliases))
901 (while aliases
902 (princ ",")
903 (princ (car aliases))
904 (setq aliases (cdr aliases)))
905 (princ (format ":%s:%c:%d:"
906 type
907 (coding-system-mnemonic coding-system)
908 (if (integerp eol-type) eol-type 3)))
909 (cond ((eq type 2) ; ISO-2022
910 (let ((idx 0)
911 charset)
912 (while (< idx 4)
913 (setq charset (aref flags idx))
914 (cond ((null charset)
915 (princ -1))
916 ((eq charset t)
917 (princ -2))
918 ((charsetp charset)
919 (princ charset))
920 ((listp charset)
921 (princ "(")
922 (princ (car charset))
923 (setq charset (cdr charset))
924 (while charset
925 (princ ",")
926 (princ (car charset))
927 (setq charset (cdr charset)))
928 (princ ")")))
929 (princ ",")
930 (setq idx (1+ idx)))
931 (while (< idx 12)
932 (princ (if (aref flags idx) 1 0))
933 (princ ",")
934 (setq idx (1+ idx)))
935 (princ (if (aref flags idx) 1 0))))
936 ((eq type 4) ; CCL
937 (let (i len)
938 (if (symbolp (car flags))
939 (princ (format " %s" (car flags)))
940 (setq i 0 len (length (car flags)))
941 (while (< i len)
942 (princ (format " %x" (aref (car flags) i)))
943 (setq i (1+ i))))
944 (princ ",")
945 (if (symbolp (cdr flags))
946 (princ (format "%s" (cdr flags)))
947 (setq i 0 len (length (cdr flags)))
948 (while (< i len)
949 (princ (format " %x" (aref (cdr flags) i)))
950 (setq i (1+ i))))))
951 (t (princ 0)))
952 (princ ":")
953 (princ (coding-system-doc-string coding-system))
954 (princ "\n"))))
956 ;;;###autoload
957 (defun list-coding-systems (&optional arg)
958 "Display a list of all coding systems.
959 This shows the mnemonic letter, name, and description of each coding system.
961 With prefix arg, the output format gets more cryptic,
962 but still contains full information about each coding system."
963 (interactive "P")
964 (with-output-to-temp-buffer "*Help*"
965 (list-coding-systems-1 arg)))
967 (defun list-coding-systems-1 (arg)
968 (if (null arg)
969 (princ "\
970 ###############################################
971 # List of coding systems in the following format:
972 # MNEMONIC-LETTER -- CODING-SYSTEM-NAME
973 # DOC-STRING
975 (princ "\
976 #########################
977 ## LIST OF CODING SYSTEMS
978 ## Each line corresponds to one coding system
979 ## Format of a line is:
980 ## NAME[,ALIAS...]:TYPE:MNEMONIC:EOL:FLAGS:POST-READ-CONVERSION
981 ## :PRE-WRITE-CONVERSION:DOC-STRING,
982 ## where
983 ## NAME = coding system name
984 ## ALIAS = alias of the coding system
985 ## TYPE = nil (no conversion), t (undecided or automatic detection),
986 ## 0 (EMACS-MULE), 1 (SJIS), 2 (ISO2022), 3 (BIG5), or 4 (CCL)
987 ## EOL = 0 (LF), 1 (CRLF), 2 (CR), or 3 (Automatic detection)
988 ## FLAGS =
989 ## if TYPE = 2 then
990 ## comma (`,') separated data of the followings:
991 ## G0, G1, G2, G3, SHORT-FORM, ASCII-EOL, ASCII-CNTL, SEVEN,
992 ## LOCKING-SHIFT, SINGLE-SHIFT, USE-ROMAN, USE-OLDJIS, NO-ISO6429
993 ## else if TYPE = 4 then
994 ## comma (`,') separated CCL programs for read and write
995 ## else
996 ## 0
997 ## POST-READ-CONVERSION, PRE-WRITE-CONVERSION = function name to be called
1000 (let ((bases (coding-system-list 'base-only))
1001 coding-system)
1002 (while bases
1003 (setq coding-system (car bases))
1004 (if (null arg)
1005 (print-coding-system-briefly coding-system 'doc-string)
1006 (print-coding-system coding-system))
1007 (setq bases (cdr bases)))))
1009 ;;;###autoload
1010 (defun list-coding-categories ()
1011 "Display a list of all coding categories."
1012 (with-output-to-temp-buffer "*Help*"
1013 (princ "\
1014 ############################
1015 ## LIST OF CODING CATEGORIES (ordered by priority)
1016 ## CATEGORY:CODING-SYSTEM
1019 (let ((l coding-category-list))
1020 (while l
1021 (princ (format "%s:%s\n" (car l) (symbol-value (car l))))
1022 (setq l (cdr l))))))
1024 ;;; FONT
1026 ;; Print information of a font in FONTINFO.
1027 (defun describe-font-internal (font-info &optional verbose)
1028 (print-list "name (opened by):" (aref font-info 0))
1029 (print-list " full name:" (aref font-info 1))
1030 (print-list " size:" (format "%2d" (aref font-info 2)))
1031 (print-list " height:" (format "%2d" (aref font-info 3)))
1032 (print-list " baseline-offset:" (format "%2d" (aref font-info 4)))
1033 (print-list "relative-compose:" (format "%2d" (aref font-info 5))))
1035 ;;;###autoload
1036 (defun describe-font (fontname)
1037 "Display information about fonts which partially match FONTNAME."
1038 (interactive "sFontname (default, current choice for ASCII chars): ")
1039 (or (and window-system (fboundp 'fontset-list))
1040 (error "No fontsets being used"))
1041 (when (or (not fontname) (= (length fontname) 0))
1042 (setq fontname (cdr (assq 'font (frame-parameters))))
1043 (if (query-fontset fontname)
1044 (setq fontname
1045 (nth 1 (assq 'ascii (aref (fontset-info fontname) 2))))))
1046 (let ((font-info (font-info fontname)))
1047 (if (null font-info)
1048 (message "No matching font")
1049 (with-output-to-temp-buffer "*Help*"
1050 (describe-font-internal font-info 'verbose)))))
1052 (defun print-fontset (fontset &optional print-fonts)
1053 "Print information about FONTSET.
1054 If optional arg PRINT-FONTS is non-nil, also print names of all opened
1055 fonts for FONTSET. This function actually inserts the information in
1056 the current buffer."
1057 (let ((tail (aref (fontset-info fontset) 2))
1058 elt chars font-spec opened prev-charset charset from to)
1059 (beginning-of-line)
1060 (insert "Fontset: " fontset "\n")
1061 (insert "CHARSET or CHAR RANGE")
1062 (indent-to 24)
1063 (insert "FONT NAME\n")
1064 (insert "---------------------")
1065 (indent-to 24)
1066 (insert "---------")
1067 (insert "\n")
1068 (while tail
1069 (setq elt (car tail) tail (cdr tail))
1070 (setq chars (car elt) font-spec (car (cdr elt)) opened (cdr (cdr elt)))
1071 (if (symbolp chars)
1072 (setq charset chars from nil to nil)
1073 (if (integerp chars)
1074 (setq charset (char-charset chars) from chars to chars)
1075 (setq charset (char-charset (car chars))
1076 from (car chars) to (cdr chars))))
1077 (unless (eq charset prev-charset)
1078 (insert (symbol-name charset))
1079 (if from
1080 (insert "\n")))
1081 (when from
1082 (let ((split (split-char from)))
1083 (if (and (= (charset-dimension charset) 2)
1084 (= (nth 2 split) 0))
1085 (setq from
1086 (make-char charset (nth 1 split)
1087 (if (= (charset-chars charset) 94) 33 32))))
1088 (insert " " from))
1089 (when (/= from to)
1090 (insert "-")
1091 (let ((split (split-char to)))
1092 (if (and (= (charset-dimension charset) 2)
1093 (= (nth 2 split) 0))
1094 (setq to
1095 (make-char charset (nth 1 split)
1096 (if (= (charset-chars charset) 94) 126 127))))
1097 (insert to))))
1098 (indent-to 24)
1099 (if (stringp font-spec)
1100 (insert font-spec)
1101 (if (car font-spec)
1102 (if (string-match "-" (car font-spec))
1103 (insert "-" (car font-spec) "-*-")
1104 (insert "-*-" (car font-spec) "-*-"))
1105 (insert "-*-"))
1106 (if (cdr font-spec)
1107 (if (string-match "-" (cdr font-spec))
1108 (insert (cdr font-spec))
1109 (insert (cdr font-spec) "-*"))
1110 (insert "*")))
1111 (insert "\n")
1112 (when print-fonts
1113 (while opened
1114 (indent-to 5)
1115 (insert "[" (car opened) "]\n")
1116 (setq opened (cdr opened))))
1117 (setq prev-charset charset)
1120 ;;;###autoload
1121 (defun describe-fontset (fontset)
1122 "Display information about FONTSET.
1123 This shows which font is used for which character(s)."
1124 (interactive
1125 (if (not (and window-system (fboundp 'fontset-list)))
1126 (error "No fontsets being used")
1127 (let ((fontset-list (nconc
1128 (fontset-list)
1129 (mapcar 'cdr fontset-alias-alist)))
1130 (completion-ignore-case t))
1131 (list (completing-read
1132 "Fontset (default, used by the current frame): "
1133 fontset-list nil t)))))
1134 (if (= (length fontset) 0)
1135 (setq fontset (cdr (assq 'font (frame-parameters)))))
1136 (if (not (setq fontset (query-fontset fontset)))
1137 (error "Current frame is using font, not fontset"))
1138 (help-setup-xref (list #'describe-fontset fontset) (interactive-p))
1139 (with-output-to-temp-buffer (help-buffer)
1140 (with-current-buffer standard-output
1141 (print-fontset fontset t))))
1143 ;;;###autoload
1144 (defun list-fontsets (arg)
1145 "Display a list of all fontsets.
1146 This shows the name, size, and style of each fontset.
1147 With prefix arg, also list the fonts contained in each fontset;
1148 see the function `describe-fontset' for the format of the list."
1149 (interactive "P")
1150 (if (not (and window-system (fboundp 'fontset-list)))
1151 (error "No fontsets being used")
1152 (help-setup-xref (list #'list-fontsets arg) (interactive-p))
1153 (with-output-to-temp-buffer (help-buffer)
1154 (with-current-buffer standard-output
1155 ;; This code is duplicated near the end of mule-diag.
1156 (let ((fontsets
1157 (sort (fontset-list)
1158 (lambda (x y)
1159 (string< (fontset-plain-name x)
1160 (fontset-plain-name y))))))
1161 (while fontsets
1162 (if arg
1163 (print-fontset (car fontsets) nil)
1164 (insert "Fontset: " (car fontsets) "\n"))
1165 (setq fontsets (cdr fontsets))))))))
1167 ;;;###autoload
1168 (defun list-input-methods ()
1169 "Display information about all input methods."
1170 (interactive)
1171 (help-setup-xref '(list-input-methods) (interactive-p))
1172 (with-output-to-temp-buffer (help-buffer)
1173 (list-input-methods-1)
1174 (with-current-buffer standard-output
1175 (save-excursion
1176 (goto-char (point-min))
1177 (while (re-search-forward
1178 "^ \\([^ ]+\\) (`.*' in mode line)$" nil t)
1179 (help-xref-button 1 #'help-input-method
1180 (match-string 1)
1181 "mouse-2: describe this method"))))))
1183 (defun list-input-methods-1 ()
1184 (if (not input-method-alist)
1185 (progn
1186 (princ "
1187 No input method is available, perhaps because you have not
1188 installed LEIM (Libraries of Emacs Input Methods)."))
1189 (princ "LANGUAGE\n NAME (`TITLE' in mode line)\n")
1190 (princ " SHORT-DESCRIPTION\n------------------------------\n")
1191 (setq input-method-alist
1192 (sort input-method-alist
1193 (lambda (x y) (string< (nth 1 x) (nth 1 y)))))
1194 (let ((l input-method-alist)
1195 language elt)
1196 (while l
1197 (setq elt (car l) l (cdr l))
1198 (when (not (equal language (nth 1 elt)))
1199 (setq language (nth 1 elt))
1200 (princ language)
1201 (terpri))
1202 (princ (format " %s (`%s' in mode line)\n %s\n"
1203 (car elt)
1204 (let ((title (nth 3 elt)))
1205 (if (and (consp title) (stringp (car title)))
1206 (car title)
1207 title))
1208 (let ((description (nth 4 elt)))
1209 (string-match ".*" description)
1210 (match-string 0 description))))))))
1212 ;;; DIAGNOSIS
1214 ;; Insert a header of a section with SECTION-NUMBER and TITLE.
1215 (defun insert-section (section-number title)
1216 (insert "########################################\n"
1217 "# Section " (format "%d" section-number) ". " title "\n"
1218 "########################################\n\n"))
1220 ;;;###autoload
1221 (defun mule-diag ()
1222 "Display diagnosis of the multilingual environment (Mule).
1224 This shows various information related to the current multilingual
1225 environment, including lists of input methods, coding systems,
1226 character sets, and fontsets (if Emacs is running under a window
1227 system which uses fontsets)."
1228 (interactive)
1229 (with-output-to-temp-buffer "*Mule-Diagnosis*"
1230 (with-current-buffer standard-output
1231 (insert "###############################################\n"
1232 "### Current Status of Multilingual Features ###\n"
1233 "###############################################\n\n"
1234 "CONTENTS: Section 1. General Information\n"
1235 " Section 2. Display\n"
1236 " Section 3. Input methods\n"
1237 " Section 4. Coding systems\n"
1238 " Section 5. Character sets\n")
1239 (if (and window-system (fboundp 'fontset-list))
1240 (insert " Section 6. Fontsets\n"))
1241 (insert "\n")
1243 (insert-section 1 "General Information")
1244 (insert "Version of this emacs:\n " (emacs-version) "\n\n")
1245 (insert "Configuration options:\n " system-configuration-options "\n\n")
1246 (insert "Multibyte characters awareness:\n"
1247 (format " default: %S\n" default-enable-multibyte-characters)
1248 (format " current-buffer: %S\n\n" enable-multibyte-characters))
1249 (insert "Current language environment: " current-language-environment
1250 "\n\n")
1252 (insert-section 2 "Display")
1253 (if window-system
1254 (insert "Window-system: "
1255 (symbol-name window-system)
1256 (format "%s" window-system-version))
1257 (insert "Terminal: " (getenv "TERM")))
1258 (insert "\n\n")
1260 (if (eq window-system 'x)
1261 (let ((font (cdr (assq 'font (frame-parameters)))))
1262 (insert "The selected frame is using the "
1263 (if (query-fontset font) "fontset" "font")
1264 ":\n\t" font))
1265 (insert "Coding system of the terminal: "
1266 (symbol-name (terminal-coding-system))))
1267 (insert "\n\n")
1269 (insert-section 3 "Input methods")
1270 (list-input-methods-1)
1271 (insert "\n")
1272 (if default-input-method
1273 (insert (format "Default input method: %s\n" default-input-method))
1274 (insert "No default input method is specified\n"))
1276 (insert-section 4 "Coding systems")
1277 (list-coding-systems-1 t)
1278 (princ "\
1279 ############################
1280 ## LIST OF CODING CATEGORIES (ordered by priority)
1281 ## CATEGORY:CODING-SYSTEM
1284 (let ((l coding-category-list))
1285 (while l
1286 (princ (format "%s:%s\n" (car l) (symbol-value (car l))))
1287 (setq l (cdr l))))
1288 (insert "\n")
1290 (insert-section 5 "Character sets")
1291 (list-character-sets-2)
1292 (insert "\n")
1294 (when (and window-system (fboundp 'fontset-list))
1295 ;; This code duplicates most of list-fontsets.
1296 (insert-section 6 "Fontsets")
1297 (insert "Fontset-Name\t\t\t\t\t\t WDxHT Style\n")
1298 (insert "------------\t\t\t\t\t\t ----- -----\n")
1299 (let ((fontsets (fontset-list)))
1300 (while fontsets
1301 (print-fontset (car fontsets) t)
1302 (setq fontsets (cdr fontsets)))))
1303 (print-help-return-message))))
1305 ;;; mule-diag.el ends here