diff options
| author | Kenichi Handa | 2000-05-13 00:37:45 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2000-05-13 00:37:45 +0000 |
| commit | b1e3566cd39f1441d2f52b21e15b7e2d8438624d (patch) | |
| tree | 25e6cb885911c8abc9b68b2e57ed913f56156958 | |
| parent | cead26f64a18690771f9fded04043cd098c95431 (diff) | |
| download | emacs-b1e3566cd39f1441d2f52b21e15b7e2d8438624d.tar.gz emacs-b1e3566cd39f1441d2f52b21e15b7e2d8438624d.zip | |
(syntax-description-table): New variable.
(describe-char-after): New function.
(describe-font-internal): Adjusted for the change of font-info.
(describe-font): Likewise.
(print-fontset): Rewritten for the new fontset implementation.
(describe-fontset): Include fontset alias names in completion.
(list-fontsets): Adjusted for the change of print-fontset.
| -rw-r--r-- | lisp/international/mule-diag.el | 256 |
1 files changed, 174 insertions, 82 deletions
diff --git a/lisp/international/mule-diag.el b/lisp/international/mule-diag.el index 78178093921..715c98607b8 100644 --- a/lisp/international/mule-diag.el +++ b/lisp/international/mule-diag.el | |||
| @@ -454,6 +454,99 @@ detailed meanings of these arguments." | |||
| 454 | (t | 454 | (t |
| 455 | (error "Invalid charset %s" charset)))))) | 455 | (error "Invalid charset %s" charset)))))) |
| 456 | 456 | ||
| 457 | |||
| 458 | ;;;###autoload | ||
| 459 | (defun describe-char-after (&optional pos) | ||
| 460 | "Display information of in current buffer at position POS. | ||
| 461 | The information includes character code, charset and code points in it, | ||
| 462 | syntax, category, how the character is encoded in a file, | ||
| 463 | which font is being used for displaying the character." | ||
| 464 | (interactive) | ||
| 465 | (or pos | ||
| 466 | (setq pos (point))) | ||
| 467 | (if (>= pos (point-max)) | ||
| 468 | (error "No character at point")) | ||
| 469 | (let* ((char (char-after pos)) | ||
| 470 | (charset (char-charset char)) | ||
| 471 | (composition (find-composition (point) nil nil t)) | ||
| 472 | (composed (if composition (buffer-substring (car composition) | ||
| 473 | (nth 1 composition)))) | ||
| 474 | item-list max-width) | ||
| 475 | (unless (eq charset 'unknown) | ||
| 476 | (setq item-list | ||
| 477 | `(("character" | ||
| 478 | ,(format "%s (0%o, %d, 0x%x)" (if (< char 256) | ||
| 479 | (single-key-description char) | ||
| 480 | (char-to-string char)) | ||
| 481 | char char char)) | ||
| 482 | ("charset" | ||
| 483 | ,(symbol-name charset) | ||
| 484 | ,(format "(%s)" (charset-description charset))) | ||
| 485 | ("code point" | ||
| 486 | ,(let ((split (split-char char))) | ||
| 487 | (if (= (charset-dimension charset) 1) | ||
| 488 | (format "%d" (nth 1 split)) | ||
| 489 | (format "%d %d" (nth 1 split) (nth 2 split))))) | ||
| 490 | ("syntax" | ||
| 491 | ,(nth 2 (assq (char-syntax char) syntax-code-table))) | ||
| 492 | ("category" | ||
| 493 | ,@(let ((category-set (char-category-set char))) | ||
| 494 | (if (not category-set) | ||
| 495 | '("-- none --") | ||
| 496 | (mapcar #'(lambda (x) (format "%c:%s " | ||
| 497 | x (category-docstring x))) | ||
| 498 | (category-set-mnemonics category-set))))) | ||
| 499 | ("buffer code" | ||
| 500 | ,(encoded-string-description | ||
| 501 | (string-as-unibyte (char-to-string char)) nil)) | ||
| 502 | ("file code" | ||
| 503 | ,@(let* ((coding buffer-file-coding-system) | ||
| 504 | (encoded (encode-coding-char char coding))) | ||
| 505 | (if encoded | ||
| 506 | (list (encoded-string-description encoded coding) | ||
| 507 | (format "(encoded by coding system %S)" coding)) | ||
| 508 | (list "not encodable by coding system" | ||
| 509 | (symbol-name coding))))) | ||
| 510 | ,(if window-system | ||
| 511 | (list "font" (char-font (point))) | ||
| 512 | (list "terminal code" | ||
| 513 | (let* ((coding (terminal-coding-system)) | ||
| 514 | (encoded (encode-coding-char char coding))) | ||
| 515 | (if encoded | ||
| 516 | (encoded-string-description encoded coding) | ||
| 517 | "not encodable")))))) | ||
| 518 | (setq max-width (apply #'max (mapcar #'(lambda (x) (length (car x))) | ||
| 519 | item-list))) | ||
| 520 | (with-output-to-temp-buffer "*Help*" | ||
| 521 | (save-excursion | ||
| 522 | (set-buffer standard-output) | ||
| 523 | (let ((formatter (format "%%%ds:" max-width))) | ||
| 524 | (dolist (elt item-list) | ||
| 525 | (insert (format formatter (car elt))) | ||
| 526 | (dolist (clm (cdr elt)) | ||
| 527 | (when (>= (+ (current-column) (string-width clm) 1) | ||
| 528 | (frame-width)) | ||
| 529 | (insert "\n") | ||
| 530 | (indent-to (1+ max-width))) | ||
| 531 | (insert " " clm)) | ||
| 532 | (insert "\n"))) | ||
| 533 | (when composition | ||
| 534 | (insert "\nComposed with the following characerter(s) " | ||
| 535 | (mapconcat (lambda (x) (format "`%c'" x)) | ||
| 536 | (substring composed 1) | ||
| 537 | ", ") | ||
| 538 | " to form `" composed "'") | ||
| 539 | (if (nth 3 composition) | ||
| 540 | (insert ".\n") | ||
| 541 | (insert "\nby the rule (" | ||
| 542 | (mapconcat (lambda (x) | ||
| 543 | (format (if (consp x) "%S" "?%c") x)) | ||
| 544 | (nth 2 composition) | ||
| 545 | " ") | ||
| 546 | ").\n" | ||
| 547 | "See the variable `reference-point-alist' for the meaning of the rule.\n"))) | ||
| 548 | ))))) | ||
| 549 | |||
| 457 | 550 | ||
| 458 | ;;; CODING-SYSTEM | 551 | ;;; CODING-SYSTEM |
| 459 | 552 | ||
| @@ -893,13 +986,10 @@ but still contains full information about each coding system." | |||
| 893 | (defun describe-font-internal (font-info &optional verbose) | 986 | (defun describe-font-internal (font-info &optional verbose) |
| 894 | (print-list "name (opened by):" (aref font-info 0)) | 987 | (print-list "name (opened by):" (aref font-info 0)) |
| 895 | (print-list " full name:" (aref font-info 1)) | 988 | (print-list " full name:" (aref font-info 1)) |
| 896 | (let ((charset (aref font-info 2))) | 989 | (print-list " size:" (format "%2d" (aref font-info 2))) |
| 897 | (print-list " charset:" | 990 | (print-list " height:" (format "%2d" (aref font-info 3))) |
| 898 | (format "%s (%s)" charset (charset-description charset)))) | 991 | (print-list " baseline-offset:" (format "%2d" (aref font-info 4))) |
| 899 | (print-list " size:" (format "%d" (aref font-info 3))) | 992 | (print-list "relative-compose:" (format "%2d" (aref font-info 5)))) |
| 900 | (print-list " height:" (format "%d" (aref font-info 4))) | ||
| 901 | (print-list " baseline-offset:" (format "%d" (aref font-info 5))) | ||
| 902 | (print-list "relative-compose:" (format "%d" (aref font-info 6)))) | ||
| 903 | 993 | ||
| 904 | ;;;###autoload | 994 | ;;;###autoload |
| 905 | (defun describe-font (fontname) | 995 | (defun describe-font (fontname) |
| @@ -911,7 +1001,7 @@ but still contains full information about each coding system." | |||
| 911 | (setq fontname (cdr (assq 'font (frame-parameters)))) | 1001 | (setq fontname (cdr (assq 'font (frame-parameters)))) |
| 912 | (if (query-fontset fontname) | 1002 | (if (query-fontset fontname) |
| 913 | (setq fontname | 1003 | (setq fontname |
| 914 | (nth 2 (assq 'ascii (aref (fontset-info fontname) 2)))))) | 1004 | (nth 1 (assq 'ascii (fontset-info fontname)))))) |
| 915 | (let ((font-info (font-info fontname))) | 1005 | (let ((font-info (font-info fontname))) |
| 916 | (if (null font-info) | 1006 | (if (null font-info) |
| 917 | (message "No matching font") | 1007 | (message "No matching font") |
| @@ -919,93 +1009,95 @@ but still contains full information about each coding system." | |||
| 919 | (describe-font-internal font-info 'verbose))))) | 1009 | (describe-font-internal font-info 'verbose))))) |
| 920 | 1010 | ||
| 921 | ;; Print information of FONTSET. If optional arg PRINT-FONTS is | 1011 | ;; Print information of FONTSET. If optional arg PRINT-FONTS is |
| 922 | ;; non-nil, print also names of all fonts in FONTSET. This function | 1012 | ;; non-nil, print also names of all opened fonts for FONTSET. This |
| 923 | ;; actually INSERT such information in the current buffer. | 1013 | ;; function actually INSERT such information in the current buffer. |
| 924 | (defun print-fontset (fontset &optional print-fonts) | 1014 | (defun print-fontset (fontset &optional print-fonts) |
| 925 | (let* ((fontset-info (fontset-info fontset)) | 1015 | (let ((tail (cdr (fontset-info fontset))) |
| 926 | (size (aref fontset-info 0)) | 1016 | elt chars font-spec opened prev-charset charset from to) |
| 927 | (height (aref fontset-info 1)) | ||
| 928 | (fonts (and print-fonts (aref fontset-info 2))) | ||
| 929 | (xlfd-fields (x-decompose-font-name fontset)) | ||
| 930 | style) | ||
| 931 | (if xlfd-fields | ||
| 932 | (let ((weight (aref xlfd-fields xlfd-regexp-weight-subnum)) | ||
| 933 | (slant (aref xlfd-fields xlfd-regexp-slant-subnum))) | ||
| 934 | (if (string-match "^bold$\\|^demibold$" weight) | ||
| 935 | (setq style (concat weight " ")) | ||
| 936 | (setq style "medium ")) | ||
| 937 | (cond ((string-match "^i$" slant) | ||
| 938 | (setq style (concat style "italic"))) | ||
| 939 | ((string-match "^o$" slant) | ||
| 940 | (setq style (concat style "slant"))) | ||
| 941 | ((string-match "^ri$" slant) | ||
| 942 | (setq style (concat style "reverse italic"))) | ||
| 943 | ((string-match "^ro$" slant) | ||
| 944 | (setq style (concat style "reverse slant"))))) | ||
| 945 | (setq style " ? ")) | ||
| 946 | (beginning-of-line) | 1017 | (beginning-of-line) |
| 947 | (insert fontset) | 1018 | (insert "Fontset: " fontset "\n") |
| 948 | (indent-to 58) | 1019 | (insert "CHARSET or CHAR RANGE") |
| 949 | (insert (if (and size (> size 0)) (format "%2dx%d" size height) " -")) | 1020 | (indent-to 25) |
| 950 | (indent-to 64) | 1021 | (insert "FONT NAME\n") |
| 951 | (insert style "\n") | 1022 | (insert "---------------------") |
| 952 | (when print-fonts | 1023 | (indent-to 25) |
| 953 | (insert " O Charset / Fontname\n" | 1024 | (insert "---------") |
| 954 | " - ------------------\n") | 1025 | (insert "\n") |
| 955 | (sort-charset-list) | 1026 | (while tail |
| 956 | (let ((l charset-list) | 1027 | (setq elt (car tail) tail (cdr tail)) |
| 957 | charset font-info opened fontname) | 1028 | (setq chars (car elt) font-spec (car (cdr elt)) opened (cdr (cdr elt))) |
| 958 | (while l | 1029 | (if (symbolp chars) |
| 959 | (setq charset (car l) l (cdr l)) | 1030 | (setq charset chars from nil to nil) |
| 960 | (setq font-info (assq charset fonts)) | 1031 | (if (integerp chars) |
| 961 | (if (null font-info) | 1032 | (setq charset (char-charset chars) from chars to chars) |
| 962 | (setq opened ?? fontname "not specified") | 1033 | (setq charset (char-charset (car chars)) |
| 963 | (if (nth 2 font-info) | 1034 | from (car chars) to (cdr chars)))) |
| 964 | (if (stringp (nth 2 font-info)) | 1035 | (unless (eq charset prev-charset) |
| 965 | (setq opened ?o fontname (nth 2 font-info)) | 1036 | (insert (symbol-name charset)) |
| 966 | (setq opened ?- fontname (nth 1 font-info))) | 1037 | (if from |
| 967 | (setq opened ?x fontname (nth 1 font-info)))) | 1038 | (insert "\n"))) |
| 968 | (insert (format " %c %s\n %s\n" | 1039 | (when from |
| 969 | opened charset fontname))))))) | 1040 | (let ((split (split-char from))) |
| 1041 | (if (and (= (charset-dimension charset) 2) | ||
| 1042 | (= (nth 2 split) 0)) | ||
| 1043 | (setq from | ||
| 1044 | (make-char charset (nth 1 split) | ||
| 1045 | (if (= (charset-chars charset) 94) 33 32)))) | ||
| 1046 | (insert " " from)) | ||
| 1047 | (when (/= from to) | ||
| 1048 | (insert "-") | ||
| 1049 | (let ((split (split-char to))) | ||
| 1050 | (if (and (= (charset-dimension charset) 2) | ||
| 1051 | (= (nth 2 split) 0)) | ||
| 1052 | (setq to | ||
| 1053 | (make-char charset (nth 1 split) | ||
| 1054 | (if (= (charset-chars charset) 94) 126 127)))) | ||
| 1055 | (insert to)))) | ||
| 1056 | (indent-to 25) | ||
| 1057 | (if (stringp font-spec) | ||
| 1058 | (insert font-spec) | ||
| 1059 | (if (car font-spec) | ||
| 1060 | (if (string-match "-" (car font-spec)) | ||
| 1061 | (insert "-" (car font-spec) "-") | ||
| 1062 | (insert "-*-" (car font-spec) "-")) | ||
| 1063 | (insert "-*-")) | ||
| 1064 | (if (cdr font-spec) | ||
| 1065 | (if (string-match "-" (cdr font-spec)) | ||
| 1066 | (insert (cdr font-spec)) | ||
| 1067 | (insert (cdr font-spec) "-*")) | ||
| 1068 | (insert "*"))) | ||
| 1069 | (insert "\n") | ||
| 1070 | (when print-fonts | ||
| 1071 | (while opened | ||
| 1072 | (indent-to 5) | ||
| 1073 | (insert "[" (car opened) "]\n") | ||
| 1074 | (setq opened (cdr opened)))) | ||
| 1075 | (setq prev-charset charset) | ||
| 1076 | ))) | ||
| 970 | 1077 | ||
| 971 | ;;;###autoload | 1078 | ;;;###autoload |
| 972 | (defun describe-fontset (fontset) | 1079 | (defun describe-fontset (fontset) |
| 973 | "Display information of FONTSET. | 1080 | "Display information of FONTSET. |
| 974 | This shows the name, size, and style of FONTSET, and the list of fonts | 1081 | This shows which font is used for which character(s)." |
| 975 | contained in FONTSET. | ||
| 976 | |||
| 977 | The column WDxHT contains width and height (pixels) of each fontset | ||
| 978 | \(i.e. those of ASCII font in the fontset). The letter `-' in this | ||
| 979 | column means that the corresponding fontset is not yet used in any | ||
| 980 | frame. | ||
| 981 | |||
| 982 | The O column for each font contains one of the following letters: | ||
| 983 | o -- font already opened | ||
| 984 | - -- font not yet opened | ||
| 985 | x -- font can't be opened | ||
| 986 | ? -- no font specified | ||
| 987 | |||
| 988 | The Charset column for each font contains a name of character set | ||
| 989 | displayed (for this fontset) using that font." | ||
| 990 | (interactive | 1082 | (interactive |
| 991 | (if (not (and window-system (fboundp 'fontset-list))) | 1083 | (if (not (and window-system (fboundp 'fontset-list))) |
| 992 | (error "No fontsets being used") | 1084 | (error "No fontsets being used") |
| 993 | (let ((fontset-list (mapcar '(lambda (x) (list x)) (fontset-list))) | 1085 | (let ((fontset-list (append |
| 1086 | (mapcar '(lambda (x) (list x)) (fontset-list)) | ||
| 1087 | (mapcar '(lambda (x) (list (cdr x))) | ||
| 1088 | fontset-alias-alist))) | ||
| 994 | (completion-ignore-case t)) | 1089 | (completion-ignore-case t)) |
| 995 | (list (completing-read | 1090 | (list (completing-read |
| 996 | "Fontset (default, used by the current frame): " | 1091 | "Fontset (default, used by the current frame): " |
| 997 | fontset-list nil t))))) | 1092 | fontset-list nil t))))) |
| 998 | (if (= (length fontset) 0) | 1093 | (if (= (length fontset) 0) |
| 999 | (setq fontset (cdr (assq 'font (frame-parameters))))) | 1094 | (setq fontset (cdr (assq 'font (frame-parameters))))) |
| 1000 | (if (not (query-fontset fontset)) | 1095 | (if (not (setq fontset (query-fontset fontset))) |
| 1001 | (error "Current frame is using font, not fontset")) | 1096 | (error "Current frame is using font, not fontset")) |
| 1002 | (let ((fontset-info (fontset-info fontset))) | 1097 | (with-output-to-temp-buffer "*Help*" |
| 1003 | (with-output-to-temp-buffer "*Help*" | 1098 | (save-excursion |
| 1004 | (save-excursion | 1099 | (set-buffer standard-output) |
| 1005 | (set-buffer standard-output) | 1100 | (print-fontset fontset t)))) |
| 1006 | (insert "Fontset-Name\t\t\t\t\t\t WDxHT Style\n") | ||
| 1007 | (insert "------------\t\t\t\t\t\t ----- -----\n") | ||
| 1008 | (print-fontset fontset t))))) | ||
| 1009 | 1101 | ||
| 1010 | ;;;###autoload | 1102 | ;;;###autoload |
| 1011 | (defun list-fontsets (arg) | 1103 | (defun list-fontsets (arg) |
| @@ -1020,15 +1112,15 @@ see the function `describe-fontset' for the format of the list." | |||
| 1020 | (save-excursion | 1112 | (save-excursion |
| 1021 | ;; This code is duplicated near the end of mule-diag. | 1113 | ;; This code is duplicated near the end of mule-diag. |
| 1022 | (set-buffer standard-output) | 1114 | (set-buffer standard-output) |
| 1023 | (insert "Fontset-Name\t\t\t\t\t\t WDxHT Style\n") | ||
| 1024 | (insert "------------\t\t\t\t\t\t ----- -----\n") | ||
| 1025 | (let ((fontsets | 1115 | (let ((fontsets |
| 1026 | (sort (fontset-list) | 1116 | (sort (fontset-list) |
| 1027 | (function (lambda (x y) | 1117 | (function (lambda (x y) |
| 1028 | (string< (fontset-plain-name x) | 1118 | (string< (fontset-plain-name x) |
| 1029 | (fontset-plain-name y))))))) | 1119 | (fontset-plain-name y))))))) |
| 1030 | (while fontsets | 1120 | (while fontsets |
| 1031 | (print-fontset (car fontsets) arg) | 1121 | (if arg |
| 1122 | (print-fontset (car fontsets) nil) | ||
| 1123 | (insert "Fontset: " (car fontsets) "\n")) | ||
| 1032 | (setq fontsets (cdr fontsets)))))))) | 1124 | (setq fontsets (cdr fontsets)))))))) |
| 1033 | 1125 | ||
| 1034 | ;;;###autoload | 1126 | ;;;###autoload |