1 ;;; mule-diag.el --- Show diagnosis of multilingual environment (Mule)
3 ;; Copyright (C) 1995,1999 Electrotechnical Laboratory, JAPAN.
4 ;; Licensed to the Free Software Foundation.
5 ;; Copyright (C) 1997 MORIOKA Tomohiko
7 ;; Keywords: multilingual, charset, coding system, fontset, diagnosis
9 ;; This file is part of XEmacs.
11 ;; XEmacs is free software; you can redistribute it and/or modify it
12 ;; under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; XEmacs is distributed in the hope that it will be useful, but
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 ;; General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with XEmacs; see the file COPYING. If not, write to the Free
23 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
26 ;;; General utility function
28 (eval-when-compile (load "mule-util"))
30 ;; Print all arguments with single space separator in one line.
31 (defun print-list (&rest args)
36 (setq args (cdr args)))
40 ;; Re-order the elements of charset-list.
41 ;; (defun sort-charset-list ()
44 ;; (function (lambda (x y) (< (charset-id x) (charset-id y)))))))
45 (defun sorted-charset-list ()
47 (function (lambda (x y) (< (charset-id x) (charset-id y))))))
52 (defun list-character-sets (&optional arg)
53 "Display a list of all character sets.
55 The ID column contains a charset identification number for internal use.
56 The B column contains a number of bytes occupied in a buffer
57 by any character in this character set.
58 The W column contains a number of columns occupied on the screen
59 by any character in this character set.
61 With prefix arg, the output format gets more cryptic,
62 but still shows the full information."
64 ;; (sort-charset-list)
65 (with-output-to-temp-buffer "*Help*"
67 (set-buffer standard-output)
68 (list-character-sets-1 arg)
70 (setq truncate-lines t))))
72 (defun list-character-sets-1 (arg)
73 (let ((l (sorted-charset-list))
77 (insert "ID Name B W Description\n")
78 (insert "-- ---- - - -----------\n")
80 (setq charset (car l) l (cdr l))
81 (insert (format "%03d %s" (charset-id charset) charset))
83 (insert (format "%d %d %s\n"
84 (charset-bytes charset)
85 (charset-width charset)
86 (charset-description charset)))))
88 #########################
90 ## Each line corresponds to one charset.
91 ## The following attributes are listed in this order
92 ## separated by a colon `:' in one line.
94 ## CHARSET-SYMBOL-NAME,
97 ## BYTES (of multibyte form: 1, 2, 3, or 4),
98 ## WIDTH (occupied column numbers: 1 or 2),
99 ## DIRECTION (0:left-to-right, 1:right-to-left),
100 ## ISO-FINAL-CHAR (character code of ISO-2022's final character)
101 ## ISO-GRAPHIC-PLANE (ISO-2022's graphic plane, 0:GL, 1:GR)
102 ## DESCRIPTION (describing string of the charset)
105 (setq charset (car l) l (cdr l))
106 (princ (format "%03d:%s:%d:%d:%d:%d:%d:%d:%d:%s\n"
109 (charset-dimension charset)
110 (charset-chars charset)
111 (charset-bytes charset)
112 (charset-width charset)
113 (charset-direction charset)
114 (charset-iso-final-char charset)
115 (charset-iso-graphic-plane charset)
116 (charset-description charset)))))))
120 (defun describe-designation (cs register)
122 (coding-system-property
123 cs (intern (format "charset-g%d" register))))
125 (coding-system-property
126 cs (intern (format "force-g%d-on-output" register)))))
131 (cond ((null charset) "never used")
132 ((eq t charset) "none")
133 (t (charset-name charset)))
134 (if force " (explicit designation required)" "")))))
137 (defun describe-coding-system (coding-system)
138 "Display information about CODING-SYSTEM."
139 (interactive "zDescribe coding system (default, current choices): ")
140 (if (or (null coding-system)
141 (string= (symbol-name coding-system) ""))
142 (describe-current-coding-system)
143 (with-output-to-temp-buffer "*Help*"
144 (print-coding-system-briefly coding-system 'doc-string)
145 (let ((type (coding-system-type coding-system)))
146 (princ (format "Type: %s" type))
147 (when (eq type 'iso2022)
148 (princ " (variant of ISO-2022)\n")
149 (princ "Initial designations:\n")
150 ;;(print-designation flags)
151 (describe-designation coding-system 0)
152 (describe-designation coding-system 1)
153 (describe-designation coding-system 2)
154 (describe-designation coding-system 3)
155 (princ "Other Form: \n ")
156 (princ (if (coding-system-short coding-system)
159 (if (coding-system-no-ascii-eol coding-system)
160 (princ ", ASCII@EOL"))
161 (if (coding-system-no-ascii-cntl coding-system)
162 (princ ", ASCII@CNTL"))
163 (princ (if (coding-system-seven coding-system)
166 (if (coding-system-lock-shift coding-system)
167 (princ ", use-locking-shift")
168 (princ ", use-single-shift"))
169 ;; (if (aref flags 10) (princ ", use-roman"))
170 ;; (if (aref flags 11) (princ ", use-old-jis"))
171 (if (coding-system-no-iso6429 coding-system)
172 (princ ", no-ISO6429"))
173 ;; (if (aref flags 13) (princ ", init-bol"))
174 ;; (if (aref flags 14) (princ ", designation-bol"))
175 ;; (if (aref flags 15) (princ ", convert-unsafe"))
176 ;; (if (aref flags 16) (princ ", accept-latin-extra-code"))
178 (princ "\nEOL type:")
179 (let ((eol-type (coding-system-eol-type coding-system)))
180 (cond ((null eol-type)
181 (princ "\n Automatic selection from\n ")
182 (princ (format "%s-unix, %s-dos or %s-mac.\n"
183 coding-system coding-system coding-system))
188 (t (princ "invalid\n")))))
189 (let ((postread (coding-system-get coding-system 'post-read-conversion)))
191 (princ "After decoding a text normally,")
192 (princ " perform post-conversion by the function: ")
196 (let ((prewrite (coding-system-get coding-system 'pre-write-conversion)))
198 (princ "Before encoding a text normally,")
199 (princ " perform pre-conversion by the function: ")
203 (let ((charsets (coding-system-get coding-system 'safe-charsets)))
206 (princ "This coding system can encode all charsets.\n")
207 (princ "This coding system encode the following charsets:\n")
211 (princ (car charsets))
212 (setq charsets (cdr charsets))))))
214 (set-buffer standard-output)
218 (defun describe-current-coding-system-briefly ()
219 "Display coding systems currently used in a brief format in echo area.
221 The format is \"F[..],K[..],T[..], default F[..]\",
222 where mnemonics of the following coding systems come in this order
223 at the place of `..':
224 `buffer-file-coding-system` (of the current buffer)
225 eol-type of buffer-file-coding-system (of the current buffer)
226 Value returned by `keyboard-coding-system'
227 eol-type of (keyboard-coding-system)
228 Value returned by `terminal-coding-system.
229 eol-type of (terminal-coding-system)
230 `default-buffer-file-coding-system'
231 eol-type of default-buffer-file-coding-system"
233 (let* ((proc (get-buffer-process (current-buffer)))
234 (process-coding-systems (if proc (process-coding-system proc))))
236 ;; "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]"
237 "F[%s%s],K[%s%s],T[%s%s], default F[%s%s]"
238 (coding-system-mnemonic buffer-file-coding-system)
239 (coding-system-eol-type-mnemonic buffer-file-coding-system)
240 (coding-system-mnemonic (keyboard-coding-system))
241 (coding-system-eol-type-mnemonic (keyboard-coding-system))
242 (coding-system-mnemonic (terminal-coding-system))
243 (coding-system-eol-type-mnemonic (terminal-coding-system))
244 ;; (coding-system-mnemonic (car process-coding-systems))
245 ;; (coding-system-eol-type-mnemonic (car process-coding-systems))
246 ;; (coding-system-mnemonic (cdr process-coding-systems))
247 ;; (coding-system-eol-type-mnemonic (cdr process-coding-systems))
248 (coding-system-mnemonic default-buffer-file-coding-system)
249 (coding-system-eol-type-mnemonic default-buffer-file-coding-system)
250 ;; (coding-system-mnemonic (car default-process-coding-system))
251 ;; (coding-system-eol-type-mnemonic (car default-process-coding-system))
252 ;; (coding-system-mnemonic (cdr default-process-coding-system))
253 ;; (coding-system-eol-type-mnemonic (cdr default-process-coding-system))
256 ;; Print symbol name and mnemonic letter of CODING-SYSTEM with `princ'.
257 (defun print-coding-system-briefly (coding-system &optional doc-string)
258 (if (not coding-system)
260 ;; In XEmacs, coding-system has own type.
261 (if (coding-system-p coding-system)
262 (setq coding-system (coding-system-name coding-system))
264 ;; In XEmacs, coding-system-mnemonic returns string.
265 (princ (format "%s -- %s"
266 (coding-system-mnemonic coding-system)
268 (let ((aliases (coding-system-get coding-system 'alias-coding-systems)))
269 (if (eq coding-system (car aliases))
271 (princ (format " %S" (cons 'alias: (cdr aliases)))))
272 (if (memq coding-system aliases)
273 (princ (format " (alias of %s)" (car aliases))))))
276 (setq doc-string (coding-system-doc-string coding-system)))
277 (princ (format " %s\n" doc-string)))))
280 (defun describe-current-coding-system ()
281 "Display coding systems currently used, in detail."
283 (with-output-to-temp-buffer "*Help*"
284 (let* ((proc (get-buffer-process (current-buffer)))
285 (process-coding-systems (if proc (process-coding-system proc))))
286 (princ "Coding system for saving this buffer:\n ")
287 ;; local-variable-p of XEmacs requires 2 arguments.
288 (if (local-variable-p 'buffer-file-coding-system (current-buffer))
289 (print-coding-system-briefly buffer-file-coding-system)
290 (princ "Not set locally, use the default.\n"))
291 (princ "Default coding system (for new files):\n ")
292 (print-coding-system-briefly default-buffer-file-coding-system)
293 (princ "Coding system for keyboard input:\n ")
294 (print-coding-system-briefly (keyboard-coding-system))
295 (princ "Coding system for terminal output:\n ")
296 (print-coding-system-briefly (terminal-coding-system))
297 (when (get-buffer-process (current-buffer))
298 (princ "Coding systems for process I/O:\n")
299 (princ " encoding input to the process: ")
300 (print-coding-system-briefly (cdr process-coding-systems))
301 (princ " decoding output from the process: ")
302 (print-coding-system-briefly (car process-coding-systems)))
303 ;;(princ "Defaults for subprocess I/O:\n")
304 ;;(princ " decoding: ")
305 ;;(print-coding-system-briefly (car default-process-coding-system))
306 ;;(princ " encoding: ")
307 ;;(print-coding-system-briefly (cdr default-process-coding-system))
310 (set-buffer standard-output)
313 "\nPriority order for recognizing coding systems when reading files:\n")
314 (let ((l (coding-priority-list)) ; It is function in XEmacs.
319 (setq coding (coding-category-system (car l))) ; for XEmacs
320 ;; Do not list up the same coding system twice.
321 (when (and coding (not (memq coding coding-list)))
322 (setq coding-list (cons coding coding-list))
323 (princ (format " %d. %s " i coding))
324 (setq aliases (coding-system-get coding 'alias-coding-systems))
325 (if (eq coding (car aliases))
327 (princ (cons 'alias: (cdr aliases))))
328 (if (memq coding aliases)
329 (princ (list 'alias 'of (car aliases)))))
334 (princ "\n Other coding systems cannot be distinguished automatically
335 from these, and therefore cannot be recognized automatically
336 with the present coding system priorities.\n\n")
338 (let ((categories '(iso-7)) ; for XEmacs
339 ;; '(coding-category-iso-7 coding-category-iso-7-else))
340 coding-system codings)
343 (setq coding-system (coding-category-system (car categories)))
347 (if (and (not (eq x coding-system))
348 (coding-system-get x 'no-initial-designation)
349 (let ((flags (coding-system-flags x)))
350 (not (or (aref flags 10) (aref flags 11)))))
351 (setq codings (cons x codings)))))
352 (get (car categories) 'coding-systems))
354 (let ((max-col (frame-width))
356 (princ (format " The followings are decoded correctly but recognized as %s:\n " coding-system))
359 (insert (format " %s" (car codings)))
360 (when (> (current-column) max-col)
363 (goto-char (point-max)))
364 (setq codings (cdr codings)))
366 (setq categories (cdr categories))))
368 (princ "Particular coding systems specified for certain file names:\n")
370 (princ " OPERATION\tTARGET PATTERN\t\tCODING SYSTEM(s)\n")
371 (princ " ---------\t--------------\t\t----------------\n")
372 (let ((func (lambda (operation alist)
376 (princ "\tnothing specified\n")
379 (prin1 (car (car alist)))
380 (if (>= (current-column) 40)
383 (princ (cdr (car alist)))
385 (setq alist (cdr alist)))))))
386 (funcall func "File I/O" file-coding-system-alist)
387 (funcall func "Process I/O" process-coding-system-alist)
388 (funcall func "Network I/O" network-coding-system-alist))
391 ;; Print detailed information on CODING-SYSTEM.
392 (defun print-coding-system (coding-system)
393 (princ coding-system)
394 ;; aliases for coding system are not supported in XEmacs 21.1.x
395 (if (and (functionp 'coding-system-alias-p) (coding-system-alias-p coding-system))
396 (princ (format " (alias of %s)\n" (coding-system-aliasee coding-system)))
397 (let ((type (coding-system-type coding-system))
398 (eol-type (coding-system-eol-type coding-system)))
399 (princ (format ";%s;%s;%s;"
401 (coding-system-mnemonic coding-system)
402 (symbol-name eol-type)))
404 (cond ((eq type 'iso2022) ; ISO-2022
406 ;; probably this should be implemented with (defmacro)?
408 (lambda (GX charset force-charset)
409 (let ((charset-name (coding-system-get coding-system (intern charset))))
412 (if (coding-system-property coding-system (intern force-charset))
413 (setq flag (concat GX ":[" (symbol-name charset-name) "]"))
414 (setq flag (concat GX ":" (symbol-name charset-name))))
415 (setq flags (append (list flag) flags))))))
417 '("G0" "G1" "G2" "G3")
418 '("charset-g0" "charset-g1" "charset-g2" "charset-g3")
419 '("force-g0-on-output" "force-g1-on-output"
420 "force-g2-on-output" "force-g3-on-output"))
422 ;; various other flags
423 (if (coding-system-get coding-system 'short)
424 (setq flags (append '("SHORT-FORM") flags)))
426 (unless (coding-system-get coding-system 'no-ascii-eol)
427 (setq flags (append '("ASCII-EOL") flags)))
429 (unless (coding-system-get coding-system 'no-ascii-cntl)
430 (setq flags (append '("ASCII-CNTL") flags)))
432 (if (coding-system-get coding-system 'seven)
433 (setq flags (append '("SEVEN") flags)))
435 (if (coding-system-get coding-system 'lock-shift)
436 (setq flags (append '("LOCKING-SHIFT") flags)))
438 (if (coding-system-get coding-system 'no-iso6429)
439 (setq flags (append '("NO-ISO6429") flags))))
441 ((eq type 'ccl) ; CCL
442 (princ (format "%s, %s"
443 (coding-system-get coding-system 'encode)
444 (coding-system-get coding-system 'decode) flags))))
445 (setq flags (reverse flags))
448 (princ (format "%s" (car flags)))
451 (princ (format ", %s" flag)))
455 (princ (coding-system-doc-string coding-system))
459 (defun list-coding-systems (&optional arg)
460 "Display a list of all coding systems.
461 This shows the mnemonic letter, name, and description of each coding system.
463 With prefix arg, the output format gets more cryptic,
464 but still contains full information about each coding system."
466 (with-displaying-help-buffer
468 (with-current-buffer standard-output
469 (list-coding-systems-1 arg)))))
472 (defun list-coding-systems-1 (arg)
475 ###############################################
476 # List of coding systems in the following format:
477 # MNEMONIC-LETTER -- CODING-SYSTEM-NAME
481 #########################
482 ## LIST OF CODING SYSTEMS
483 ## Each line corresponds to one coding system
484 ## Format of a line is:
485 ## NAME[,ALIAS...];TYPE;MNEMONIC;EOL;FLAGS;POST-READ-CONVERSION
486 ## ;PRE-WRITE-CONVERSION;DOC-STRING,
488 ## NAME = coding system name
489 ## ALIAS = alias of the coding system
490 ## TYPE = nil (no conversion), t (undecided or automatic detection),
491 ## 0 (EMACS-MULE), 1 (SJIS), 2 (ISO2022), 3 (BIG5), or 4 (CCL)
492 ## EOL = lf (LF), crlf (CRLF), cr (CR), or nil (Automatic detection)
494 ## if TYPE = 'ISO2022 then
495 ## comma (`,') separated data of the followings:
496 ## G0, G1, G2, G3, SHORT-FORM, ASCII-EOL, ASCII-CNTL, SEVEN,
497 ## LOCKING-SHIFT, NO-ISO6429
498 ## else if TYPE = 'CCL then
499 ## comma (`,') separated CCL programs for read and write
502 ## POST-READ-CONVERSION, PRE-WRITE-CONVERSION = function name to be called
506 ;; print only base coding systems (w/o "-dos", "-unix", "-mac")
507 (let ((bases (make-hash-table)))
508 ;; put base coding systems into hash-table
510 (lambda (coding-system)
511 (let* ((base (coding-system-base coding-system))
512 (base-name (coding-system-name base)))
514 (unless (gethash base-name bases)
515 (puthash base-name base bases))))
516 (coding-system-list))
518 ;; traverse hash-table and print each coding system
520 (lambda (key value) (print-coding-system-briefly value 'doc-string))
523 ;; print all coding systems in details
525 '(lambda (coding-system)
526 (print-coding-system coding-system))
527 (coding-system-list))))
530 (defun list-coding-categories ()
531 "Display a list of all coding categories."
533 (with-output-to-temp-buffer "*Help*"
535 ############################
536 ## LIST OF CODING CATEGORIES (ordered by priority)
537 ## CATEGORY:CODING-SYSTEM
540 (let ((l (coding-priority-list)))
542 (princ (format "%s:%s\n" (car l) (coding-category-system (car l))))
547 ;; Print information of a font in FONTINFO.
548 (defun describe-font-internal (font-info &optional verbose)
549 (print-list "name (opened by):" (aref font-info 0))
550 (print-list " full name:" (aref font-info 1))
551 (let ((charset (aref font-info 2)))
552 (print-list " charset:"
553 (format "%s (%s)" charset (charset-description charset))))
554 (print-list " size:" (format "%d" (aref font-info 3)))
555 (print-list " height:" (format "%d" (aref font-info 4)))
556 (print-list " baseline-offset:" (format "%d" (aref font-info 5)))
557 (print-list "relative-compose:" (format "%d" (aref font-info 6))))
560 (defun describe-font (fontname)
561 "Display information about fonts which partially match FONTNAME."
562 (interactive "sFontname (default, current choice for ASCII chars): ")
563 (or (and window-system (boundp 'global-fontset-alist))
564 (error "No fontsets being used"))
565 (when (or (not fontname) (= (length fontname) 0))
566 (setq fontname (cdr (assq 'font (frame-parameters))))
567 (if (query-fontset fontname)
569 (nth 2 (assq 'ascii (aref (fontset-info fontname) 2))))))
570 (let ((font-info (font-info fontname)))
572 (message "No matching font")
573 (with-output-to-temp-buffer "*Help*"
574 (describe-font-internal font-info 'verbose)))))
576 ;; Print information of FONTSET. If optional arg PRINT-FONTS is
577 ;; non-nil, print also names of all fonts in FONTSET. This function
578 ;; actually INSERT such information in the current buffer.
579 (defun print-fontset (fontset &optional print-fonts)
580 (let* ((fontset-info (fontset-info fontset))
581 (size (aref fontset-info 0))
582 (height (aref fontset-info 1))
583 (fonts (and print-fonts (aref fontset-info 2)))
584 (xlfd-fields (x-decompose-font-name fontset))
587 (let ((weight (aref xlfd-fields xlfd-regexp-weight-subnum))
588 (slant (aref xlfd-fields xlfd-regexp-slant-subnum)))
589 (if (string-match "^bold$\\|^demibold$" weight)
590 (setq style (concat weight " "))
591 (setq style "medium "))
592 (cond ((string-match "^i$" slant)
593 (setq style (concat style "italic")))
594 ((string-match "^o$" slant)
595 (setq style (concat style "slant")))
596 ((string-match "^ri$" slant)
597 (setq style (concat style "reverse italic")))
598 ((string-match "^ro$" slant)
599 (setq style (concat style "reverse slant")))))
604 (insert (if (> size 0) (format "%2dx%d" size height) " -"))
608 (insert " O Charset / Fontname\n"
609 " - ------------------\n")
611 (let ((l charset-list)
612 charset font-info opened fontname)
614 (setq charset (car l) l (cdr l))
615 (setq font-info (assq charset fonts))
617 (setq opened ?? fontname "not specified")
618 (if (nth 2 font-info)
619 (if (stringp (nth 2 font-info))
620 (setq opened ?o fontname (nth 2 font-info))
621 (setq opened ?- fontname (nth 1 font-info)))
622 (setq opened ?x fontname (nth 1 font-info))))
623 (insert (format " %c %s\n %s\n"
624 opened charset fontname)))))))
627 (defun describe-fontset (fontset)
628 "Display information of FONTSET.
629 This shows the name, size, and style of FONTSET, and the list of fonts
630 contained in FONTSET.
632 The column WDxHT contains width and height (pixels) of each fontset
633 \(i.e. those of ASCII font in the fontset). The letter `-' in this
634 column means that the corresponding fontset is not yet used in any
637 The O column for each font contains one of the following letters:
638 o -- font already opened
639 - -- font not yet opened
640 x -- font can't be opened
641 ? -- no font specified
643 The Charset column for each font contains a name of character set
644 displayed (for this fontset) using that font."
646 (if (not (and window-system (boundp 'global-fontset-alist)))
647 (error "No fontsets being used")
648 (let ((fontset-list (mapcar '(lambda (x) (list x)) (fontset-list)))
649 (completion-ignore-case t))
650 (list (completing-read
651 "Fontset (default, used by the current frame): "
652 fontset-list nil t)))))
653 (if (= (length fontset) 0)
654 (setq fontset (cdr (assq 'font (frame-parameters)))))
655 (if (not (query-fontset fontset))
656 (error "Current frame is using font, not fontset"))
657 (let ((fontset-info (fontset-info fontset)))
658 (with-output-to-temp-buffer "*Help*"
660 (set-buffer standard-output)
661 (insert "Fontset-Name\t\t\t\t\t\t WDxHT Style\n")
662 (insert "------------\t\t\t\t\t\t ----- -----\n")
663 (print-fontset fontset t)))))
666 (defun list-fontsets (arg)
667 "Display a list of all fontsets.
668 This shows the name, size, and style of each fontset.
669 With prefix arg, it also list the fonts contained in each fontset;
670 see the function `describe-fontset' for the format of the list."
672 (if (not (and window-system (boundp 'global-fontset-alist)))
673 (error "No fontsets being used")
674 (with-output-to-temp-buffer "*Help*"
676 ;; This code is duplicated near the end of mule-diag.
677 (set-buffer standard-output)
678 (insert "Fontset-Name\t\t\t\t\t\t WDxHT Style\n")
679 (insert "------------\t\t\t\t\t\t ----- -----\n")
682 (function (lambda (x y)
683 (string< (fontset-plain-name x)
684 (fontset-plain-name y)))))))
686 (print-fontset (car fontsets) arg)
687 (setq fontsets (cdr fontsets))))))))
690 (defun list-input-methods ()
691 "Display information about all input methods."
693 (with-displaying-help-buffer
695 (with-current-buffer standard-output
696 (list-input-methods-1)))))
699 (defun list-input-methods-1 ()
700 (if (not input-method-alist)
703 No input method is available, perhaps because you have not yet
704 installed LEIM (Libraries of Emacs Input Method).
706 LEIM is available from the same ftp directory as Emacs. For instance,
707 if there exists an archive file `emacs-20.N.tar.gz', there should also
708 be a file `leim-20.N.tar.gz'. When you extract this file, LEIM files
709 are put under the subdirectory `emacs-20.N/leim'. When you install
710 Emacs again, you should be able to use various input methods."))
711 (princ "LANGUAGE\n NAME (`TITLE' in mode line)\n")
712 (princ " SHORT-DESCRIPTION\n------------------------------\n")
713 (setq input-method-alist
714 (sort input-method-alist
715 (function (lambda (x y) (string< (nth 1 x) (nth 1 y))))))
716 (let ((l input-method-alist)
719 (setq elt (car l) l (cdr l))
720 (when (not (equal language (nth 1 elt)))
721 (setq language (nth 1 elt))
724 (princ (format " %s (`%s' in mode line)\n %s\n"
726 (let ((title (nth 3 elt)))
727 (if (and (consp title) (stringp (car title)))
730 (let ((description (nth 4 elt)))
731 (string-match ".*" description)
732 (match-string 0 description))))))))
736 ;; Insert a header of a section with SECTION-NUMBER and TITLE.
737 (defun insert-section (section-number title)
738 (insert "########################################\n"
739 "# Section " (format "%d" section-number) ". " title "\n"
740 "########################################\n\n"))
744 "Display diagnosis of the multilingual environment (Mule).
746 This shows various information related to the current multilingual
747 environment, including lists of input methods, coding systems,
748 character sets, and fontsets (if Emacs is running under a window
749 system which uses fontsets)."
751 (with-output-to-temp-buffer "*Mule-Diagnosis*"
753 (set-buffer standard-output)
754 (insert "###############################################\n"
755 "### Current Status of Multilingual Features ###\n"
756 "###############################################\n\n"
757 "CONTENTS: Section 1. General Information\n"
758 " Section 2. Display\n"
759 " Section 3. Input methods\n"
760 " Section 4. Coding systems\n"
761 " Section 5. Character sets\n")
762 (if (and window-system (boundp 'global-fontset-alist))
763 (insert " Section 6. Fontsets\n"))
766 (insert-section 1 "General Information")
767 (insert "Version of this emacs:\n " (emacs-version) "\n\n")
769 (insert-section 2 "Display")
771 (insert "Window-system: "
772 (symbol-name window-system)
773 (format "%s" window-system-version))
774 (insert "Terminal: " (getenv "TERM")))
777 (if (eq window-system 'x)
778 (let ((font (cdr (assq 'font (frame-parameters)))))
779 (insert "The selected frame is using the "
780 (if (query-fontset font) "fontset" "font")
782 (insert "Coding system of the terminal: "
783 (symbol-name (terminal-coding-system))))
786 (insert-section 3 "Input methods")
787 (list-input-methods-1)
789 (if default-input-method
790 (insert "Default input method: " default-input-method "\n")
791 (insert "No default input method is specified\n"))
793 (insert-section 4 "Coding systems")
794 (list-coding-systems-1 t)
796 ############################
797 ## LIST OF CODING CATEGORIES (ordered by priority)
798 ## CATEGORY:CODING-SYSTEM
801 (let ((l (coding-priority-list)))
803 (princ (format "%s:%s\n" (car l) (symbol-value (car l))))
807 (insert-section 5 "Character sets")
808 (list-character-sets-1 t)
811 (when (and window-system (boundp 'global-fontset-alist))
812 ;; This code duplicates most of list-fontsets.
813 (insert-section 6 "Fontsets")
814 (insert "Fontset-Name\t\t\t\t\t\t WDxHT Style\n")
815 (insert "------------\t\t\t\t\t\t ----- -----\n")
816 (let ((fontsets (fontset-list)))
818 (print-fontset (car fontsets) t)
819 (setq fontsets (cdr fontsets)))))
820 (print-help-return-message))))
826 (defun dump-charsets ()
827 "Dump information about all charsets into the file `CHARSETS'.
828 The file is saved in the directory `data-directory'."
829 (let ((file (expand-file-name "CHARSETS" data-directory))
831 (or (file-writable-p file)
832 (error "Can't write to file %s" file))
833 (setq buf (find-file-noselect file))
834 (save-window-excursion
837 (setq buffer-read-only nil)
839 (list-character-sets t)
840 (insert-buffer-substring "*Help*")
841 (let (make-backup-files
842 coding-system-for-write)
849 (defun dump-codings ()
850 "Dump information about all coding systems into the file `CODINGS'.
851 The file is saved in the directory `data-directory'."
852 (let ((file (expand-file-name "CODINGS" data-directory))
854 (or (file-writable-p file)
855 (error "Can't write to file %s" file))
856 (setq buf (find-file-noselect file))
857 (save-window-excursion
860 (setq buffer-read-only nil)
862 (list-coding-systems t)
863 (insert-buffer-substring "*Help*")
864 (list-coding-categories)
865 (insert-buffer-substring "*Help*")
866 (let (make-backup-files
867 coding-system-for-write)
873 ;;; mule-diag.el ends here