]> code.delx.au - gnu-emacs/blob - lisp/descr-text.el
(eshell): Fix broken info-link.
[gnu-emacs] / lisp / descr-text.el
1 ;;; descr-text.el --- describe text mode
2
3 ;; Copyright (c) 1994, 95, 96, 2001, 02, 03, 04 Free Software Foundation, Inc.
4
5 ;; Author: Boris Goldowsky <boris@gnu.org>
6 ;; Keywords: faces
7
8 ;; This file is part of GNU Emacs.
9
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
13 ;; any later version.
14
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
19
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
24
25 ;;; Commentary:
26
27 ;;; Describe-Text Mode.
28
29 ;;; Code:
30
31 (eval-when-compile (require 'button))
32
33 (defun describe-text-done ()
34 "Delete the current window or bury the current buffer."
35 (interactive)
36 (if (> (count-windows) 1)
37 (delete-window)
38 (bury-buffer)))
39
40 (defvar describe-text-mode-map
41 (let ((map (make-sparse-keymap)))
42 (set-keymap-parent map widget-keymap)
43 map)
44 "Keymap for `describe-text-mode'.")
45
46 (defcustom describe-text-mode-hook nil
47 "List of hook functions ran by `describe-text-mode'."
48 :type 'hook
49 :group 'facemenu)
50
51 (defun describe-text-mode ()
52 "Major mode for buffers created by `describe-char'.
53
54 \\{describe-text-mode-map}
55 Entry to this mode calls the value of `describe-text-mode-hook'
56 if that value is non-nil."
57 (kill-all-local-variables)
58 (setq major-mode 'describe-text-mode
59 mode-name "Describe-Text")
60 (use-local-map describe-text-mode-map)
61 (widget-setup)
62 (add-hook 'change-major-mode-hook 'font-lock-defontify nil t)
63 (run-hooks 'describe-text-mode-hook))
64
65 ;;; Describe-Text Utilities.
66
67 (defun describe-text-widget (widget)
68 "Insert text to describe WIDGET in the current buffer."
69 (widget-create 'link
70 :notify `(lambda (&rest ignore)
71 (widget-browse ',widget))
72 (format "%S" (if (symbolp widget)
73 widget
74 (car widget))))
75 (widget-insert " ")
76 (widget-create 'info-link :tag "widget" "(widget)Top"))
77
78 (defun describe-text-sexp (sexp)
79 "Insert a short description of SEXP in the current buffer."
80 (let ((pp (condition-case signal
81 (pp-to-string sexp)
82 (error (prin1-to-string signal)))))
83 (when (string-match "\n\\'" pp)
84 (setq pp (substring pp 0 (1- (length pp)))))
85 (if (cond ((string-match "\n" pp)
86 nil)
87 ((> (length pp) (- (window-width) (current-column)))
88 nil)
89 (t t))
90 (widget-insert pp)
91 (widget-create 'push-button
92 :tag "show"
93 :action (lambda (widget &optional event)
94 (with-output-to-temp-buffer
95 "*Pp Eval Output*"
96 (princ (widget-get widget :value))))
97 pp))))
98
99 (defun describe-property-list (properties)
100 "Insert a description of PROPERTIES in the current buffer.
101 PROPERTIES should be a list of overlay or text properties.
102 The `category' and `face' properties are made into widget buttons
103 that call `describe-text-category' or `describe-face' when pushed."
104 ;; Sort the properties by the size of their value.
105 (dolist (elt (sort (let ((ret nil)
106 (key nil)
107 (val nil)
108 (len nil))
109 (while properties
110 (setq key (pop properties)
111 val (pop properties)
112 len 0)
113 (unless (or (memq key '(category face))
114 (widgetp val))
115 (setq val (pp-to-string val)
116 len (length val)))
117 (push (list key val len) ret))
118 ret)
119 (lambda (a b)
120 (< (nth 2 a)
121 (nth 2 b)))))
122 (let ((key (nth 0 elt))
123 (value (nth 1 elt)))
124 (widget-insert (propertize (format " %-20s " key)
125 'font-lock-face 'italic))
126 (cond ((eq key 'category)
127 (widget-create 'link
128 :notify `(lambda (&rest ignore)
129 (describe-text-category ',value))
130 (format "%S" value)))
131 ((eq key 'face)
132 (widget-create 'link
133 :notify `(lambda (&rest ignore)
134 (describe-face ',value))
135 (format "%S" value)))
136 ((widgetp value)
137 (describe-text-widget value))
138 (t
139 (widget-insert value))))
140 (widget-insert "\n")))
141 \f
142 ;;; Describe-Text Commands.
143
144 (defun describe-text-category (category)
145 "Describe a text property category."
146 (interactive "S")
147 (save-excursion
148 (with-output-to-temp-buffer "*Help*"
149 (set-buffer standard-output)
150 (widget-insert "Category " (format "%S" category) ":\n\n")
151 (describe-property-list (symbol-plist category))
152 (describe-text-mode)
153 (goto-char (point-min)))))
154
155 ;;;###autoload
156 (defun describe-text-properties (pos &optional output-buffer)
157 "Describe widgets, buttons, overlays and text properties at POS.
158 Interactively, describe them for the character after point.
159 If optional second argument OUTPUT-BUFFER is non-nil,
160 insert the output into that buffer, and don't initialize or clear it
161 otherwise."
162 (interactive "d")
163 (if (>= pos (point-max))
164 (error "No character follows specified position"))
165 (if output-buffer
166 (describe-text-properties-1 pos output-buffer)
167 (if (not (or (text-properties-at pos) (overlays-at pos)))
168 (message "This is plain text.")
169 (let ((buffer (current-buffer)))
170 (when (eq buffer (get-buffer "*Help*"))
171 (error "Can't do self inspection"))
172 (save-excursion
173 (with-output-to-temp-buffer "*Help*"
174 (set-buffer standard-output)
175 (setq output-buffer (current-buffer))
176 (widget-insert "Text content at position " (format "%d" pos) ":\n\n")
177 (with-current-buffer buffer
178 (describe-text-properties-1 pos output-buffer))
179 (describe-text-mode)
180 (goto-char (point-min))))))))
181
182 (defun describe-text-properties-1 (pos output-buffer)
183 (let* ((properties (text-properties-at pos))
184 (overlays (overlays-at pos))
185 overlay
186 (wid-field (get-char-property pos 'field))
187 (wid-button (get-char-property pos 'button))
188 (wid-doc (get-char-property pos 'widget-doc))
189 ;; If button.el is not loaded, we have no buttons in the text.
190 (button (and (fboundp 'button-at) (button-at pos)))
191 (button-type (and button (button-type button)))
192 (button-label (and button (button-label button)))
193 (widget (or wid-field wid-button wid-doc)))
194 (with-current-buffer output-buffer
195 ;; Widgets
196 (when (widgetp widget)
197 (newline)
198 (widget-insert (cond (wid-field "This is an editable text area")
199 (wid-button "This is an active area")
200 (wid-doc "This is documentation text")))
201 (widget-insert " of a ")
202 (describe-text-widget widget)
203 (widget-insert ".\n\n"))
204 ;; Buttons
205 (when (and button (not (widgetp wid-button)))
206 (newline)
207 (widget-insert "Here is a " (format "%S" button-type)
208 " button labeled `" button-label "'.\n\n"))
209 ;; Overlays
210 (when overlays
211 (newline)
212 (if (eq (length overlays) 1)
213 (widget-insert "There is an overlay here:\n")
214 (widget-insert "There are " (format "%d" (length overlays))
215 " overlays here:\n"))
216 (dolist (overlay overlays)
217 (widget-insert " From " (format "%d" (overlay-start overlay))
218 " to " (format "%d" (overlay-end overlay)) "\n")
219 (describe-property-list (overlay-properties overlay)))
220 (widget-insert "\n"))
221 ;; Text properties
222 (when properties
223 (newline)
224 (widget-insert "There are text properties here:\n")
225 (describe-property-list properties)))))
226 \f
227 ;;; We cannot use the UnicodeData.txt file as such; it is not free.
228 ;;; We can turn that info a different format and release the result
229 ;;; as free data. When that is done, we could reinstate the code below.
230 ;;; For the mean time, here is a dummy placeholder.
231 ;;; -- rms
232 (defun describe-char-unicode-data (char) nil)
233
234 ;;; (defcustom describe-char-unicodedata-file nil
235 ;;; "Location of Unicode data file.
236 ;;; This is the UnicodeData.txt file from the Unicode consortium, used for
237 ;;; diagnostics. If it is non-nil `describe-char-after' will print data
238 ;;; looked up from it. This facility is mostly of use to people doing
239 ;;; multilingual development.
240
241 ;;; This is a fairly large file, not typically present on GNU systems. At
242 ;;; the time of writing it is at
243 ;;; <URL:ftp://www.unicode.org/Public/UNIDATA/UnicodeData.txt>."
244 ;;; :group 'mule
245 ;;; :version "21.5"
246 ;;; :type '(choice (const :tag "None" nil)
247 ;;; file))
248
249 ;;; ;; We could convert the unidata file into a Lispy form once-for-all
250 ;;; ;; and distribute it for loading on demand. It might be made more
251 ;;; ;; space-efficient by splitting strings word-wise and replacing them
252 ;;; ;; with lists of symbols interned in a private obarray, e.g.
253 ;;; ;; "LATIN SMALL LETTER A" => '(LATIN SMALL LETTER A).
254
255 ;;; ;; Fixme: Check whether this needs updating for Unicode 4.
256 ;;; (defun describe-char-unicode-data (char)
257 ;;; "Return a list of Unicode data for unicode CHAR.
258 ;;; Each element is a list of a property description and the property value.
259 ;;; The list is null if CHAR isn't found in `describe-char-unicodedata-file'."
260 ;;; (when describe-char-unicodedata-file
261 ;;; (unless (file-exists-p describe-char-unicodedata-file)
262 ;;; (error "`unicodedata-file' %s not found" describe-char-unicodedata-file))
263 ;;; (save-excursion
264 ;;; ;; Find file in fundamental mode to avoid, e.g. flyspell turned
265 ;;; ;; on for .txt. Don't use RAWFILE arg in case of DOS line endings.
266 ;;; (set-buffer (let ((auto-mode-alist))
267 ;;; (find-file-noselect describe-char-unicodedata-file)))
268 ;;; (goto-char (point-min))
269 ;;; (let ((hex (format "%04X" char))
270 ;;; found first last)
271 ;;; (if (re-search-forward (concat "^" hex) nil t)
272 ;;; (setq found t)
273 ;;; ;; It's not listed explicitly. Look for ranges, e.g. CJK
274 ;;; ;; ideographs, and check whether it's in one of them.
275 ;;; (while (and (re-search-forward "^\\([^;]+\\);[^;]+First>;" nil t)
276 ;;; (>= char (setq first
277 ;;; (string-to-number (match-string 1) 16)))
278 ;;; (progn
279 ;;; (forward-line 1)
280 ;;; (looking-at "^\\([^;]+\\);[^;]+Last>;")
281 ;;; (> char
282 ;;; (setq last
283 ;;; (string-to-number (match-string 1) 16))))))
284 ;;; (if (and (>= char first)
285 ;;; (<= char last))
286 ;;; (setq found t)))
287 ;;; (if found
288 ;;; (let ((fields (mapcar (lambda (elt)
289 ;;; (if (> (length elt) 0)
290 ;;; elt))
291 ;;; (cdr (split-string
292 ;;; (buffer-substring
293 ;;; (line-beginning-position)
294 ;;; (line-end-position))
295 ;;; ";")))))
296 ;;; ;; The length depends on whether the last field was empty.
297 ;;; (unless (or (= 13 (length fields))
298 ;;; (= 14 (length fields)))
299 ;;; (error "Invalid contents in %s" describe-char-unicodedata-file))
300 ;;; ;; The field names and values lists are slightly
301 ;;; ;; modified from Mule-UCS unidata.el.
302 ;;; (list
303 ;;; (list "Name" (let ((name (nth 0 fields)))
304 ;;; ;; Check for <..., First>, <..., Last>
305 ;;; (if (string-match "\\`\\(<[^,]+\\)," name)
306 ;;; (concat (match-string 1 name) ">")
307 ;;; name)))
308 ;;; (list "Category"
309 ;;; (cdr (assoc
310 ;;; (nth 1 fields)
311 ;;; '(("Lu" . "uppercase letter")
312 ;;; ("Ll" . "lowercase letter")
313 ;;; ("Lt" . "titlecase letter")
314 ;;; ("Mn" . "non-spacing mark")
315 ;;; ("Mc" . "spacing-combining mark")
316 ;;; ("Me" . "enclosing mark")
317 ;;; ("Nd" . "decimal digit")
318 ;;; ("Nl" . "letter number")
319 ;;; ("No" . "other number")
320 ;;; ("Zs" . "space separator")
321 ;;; ("Zl" . "line separator")
322 ;;; ("Zp" . "paragraph separator")
323 ;;; ("Cc" . "other control")
324 ;;; ("Cf" . "other format")
325 ;;; ("Cs" . "surrogate")
326 ;;; ("Co" . "private use")
327 ;;; ("Cn" . "not assigned")
328 ;;; ("Lm" . "modifier letter")
329 ;;; ("Lo" . "other letter")
330 ;;; ("Pc" . "connector punctuation")
331 ;;; ("Pd" . "dash punctuation")
332 ;;; ("Ps" . "open punctuation")
333 ;;; ("Pe" . "close punctuation")
334 ;;; ("Pi" . "initial-quotation punctuation")
335 ;;; ("Pf" . "final-quotation punctuation")
336 ;;; ("Po" . "other punctuation")
337 ;;; ("Sm" . "math symbol")
338 ;;; ("Sc" . "currency symbol")
339 ;;; ("Sk" . "modifier symbol")
340 ;;; ("So" . "other symbol")))))
341 ;;; (list "Combining class"
342 ;;; (cdr (assoc
343 ;;; (string-to-number (nth 2 fields))
344 ;;; '((0 . "Spacing")
345 ;;; (1 . "Overlays and interior")
346 ;;; (7 . "Nuktas")
347 ;;; (8 . "Hiragana/Katakana voicing marks")
348 ;;; (9 . "Viramas")
349 ;;; (10 . "Start of fixed position classes")
350 ;;; (199 . "End of fixed position classes")
351 ;;; (200 . "Below left attached")
352 ;;; (202 . "Below attached")
353 ;;; (204 . "Below right attached")
354 ;;; (208 . "Left attached (reordrant around \
355 ;;; single base character)")
356 ;;; (210 . "Right attached")
357 ;;; (212 . "Above left attached")
358 ;;; (214 . "Above attached")
359 ;;; (216 . "Above right attached")
360 ;;; (218 . "Below left")
361 ;;; (220 . "Below")
362 ;;; (222 . "Below right")
363 ;;; (224 . "Left (reordrant around single base \
364 ;;; character)")
365 ;;; (226 . "Right")
366 ;;; (228 . "Above left")
367 ;;; (230 . "Above")
368 ;;; (232 . "Above right")
369 ;;; (233 . "Double below")
370 ;;; (234 . "Double above")
371 ;;; (240 . "Below (iota subscript)")))))
372 ;;; (list "Bidi category"
373 ;;; (cdr (assoc
374 ;;; (nth 3 fields)
375 ;;; '(("L" . "Left-to-Right")
376 ;;; ("LRE" . "Left-to-Right Embedding")
377 ;;; ("LRO" . "Left-to-Right Override")
378 ;;; ("R" . "Right-to-Left")
379 ;;; ("AL" . "Right-to-Left Arabic")
380 ;;; ("RLE" . "Right-to-Left Embedding")
381 ;;; ("RLO" . "Right-to-Left Override")
382 ;;; ("PDF" . "Pop Directional Format")
383 ;;; ("EN" . "European Number")
384 ;;; ("ES" . "European Number Separator")
385 ;;; ("ET" . "European Number Terminator")
386 ;;; ("AN" . "Arabic Number")
387 ;;; ("CS" . "Common Number Separator")
388 ;;; ("NSM" . "Non-Spacing Mark")
389 ;;; ("BN" . "Boundary Neutral")
390 ;;; ("B" . "Paragraph Separator")
391 ;;; ("S" . "Segment Separator")
392 ;;; ("WS" . "Whitespace")
393 ;;; ("ON" . "Other Neutrals")))))
394 ;;; (list
395 ;;; "Decomposition"
396 ;;; (if (nth 4 fields)
397 ;;; (let* ((parts (split-string (nth 4 fields)))
398 ;;; (info (car parts)))
399 ;;; (if (string-match "\\`<\\(.+\\)>\\'" info)
400 ;;; (setq info (match-string 1 info))
401 ;;; (setq info nil))
402 ;;; (if info (setq parts (cdr parts)))
403 ;;; ;; Maybe printing ? for unrepresentable unicodes
404 ;;; ;; here and below should be changed?
405 ;;; (setq parts (mapconcat
406 ;;; (lambda (arg)
407 ;;; (string (or (decode-char
408 ;;; 'ucs
409 ;;; (string-to-number arg 16))
410 ;;; ??)))
411 ;;; parts " "))
412 ;;; (concat info parts))))
413 ;;; (list "Decimal digit value"
414 ;;; (nth 5 fields))
415 ;;; (list "Digit value"
416 ;;; (nth 6 fields))
417 ;;; (list "Numeric value"
418 ;;; (nth 7 fields))
419 ;;; (list "Mirrored"
420 ;;; (if (equal "Y" (nth 8 fields))
421 ;;; "yes"))
422 ;;; (list "Old name" (nth 9 fields))
423 ;;; (list "ISO 10646 comment" (nth 10 fields))
424 ;;; (list "Uppercase" (and (nth 11 fields)
425 ;;; (string (or (decode-char
426 ;;; 'ucs
427 ;;; (string-to-number
428 ;;; (nth 11 fields) 16))
429 ;;; ??))))
430 ;;; (list "Lowercase" (and (nth 12 fields)
431 ;;; (string (or (decode-char
432 ;;; 'ucs
433 ;;; (string-to-number
434 ;;; (nth 12 fields) 16))
435 ;;; ??))))
436 ;;; (list "Titlecase" (and (nth 13 fields)
437 ;;; (string (or (decode-char
438 ;;; 'ucs
439 ;;; (string-to-number
440 ;;; (nth 13 fields) 16))
441 ;;; ??)))))))))))
442
443 ;; Return information about how CHAR is displayed at the buffer
444 ;; position POS. If the selected frame is on a graphic display,
445 ;; return a cons (FONTNAME . GLYPH-CODE). Otherwise, return a string
446 ;; describing the terminal codes for the character.
447 (defun describe-char-display (pos char)
448 (if (display-graphic-p (selected-frame))
449 (internal-char-font pos char)
450 (let* ((coding (terminal-coding-system))
451 (encoded (encode-coding-char char coding)))
452 (if encoded
453 (encoded-string-description encoded coding)))))
454
455 \f
456 ;;;###autoload
457 (defun describe-char (pos)
458 "Describe the character after POS (interactively, the character after point).
459 The information includes character code, charset and code points in it,
460 syntax, category, how the character is encoded in a file,
461 character composition information (if relevant),
462 as well as widgets, buttons, overlays, and text properties."
463 (interactive "d")
464 (if (>= pos (point-max))
465 (error "No character follows specified position"))
466 (let* ((char (char-after pos))
467 (charset (char-charset char))
468 (buffer (current-buffer))
469 (composition (find-composition pos nil nil t))
470 (component-chars nil)
471 (display-table (or (window-display-table)
472 buffer-display-table
473 standard-display-table))
474 (disp-vector (and display-table (aref display-table char)))
475 (multibyte-p enable-multibyte-characters)
476 item-list max-width unicode)
477 (if (eq charset 'unknown)
478 (setq item-list
479 `(("character"
480 ,(format "%s (0%o, %d, 0x%x) -- invalid character code"
481 (if (< char 256)
482 (single-key-description char)
483 (char-to-string char))
484 char char char))))
485
486 (if (or (< char 256)
487 (memq 'mule-utf-8 (find-coding-systems-region pos (1+ pos)))
488 (get-char-property pos 'untranslated-utf-8))
489 (setq unicode (or (get-char-property pos 'untranslated-utf-8)
490 (encode-char char 'ucs))))
491 (setq item-list
492 `(("character"
493 ,(format "%s (0%o, %d, 0x%x%s)" (if (< char 256)
494 (single-key-description char)
495 (char-to-string char))
496 char char char
497 (if unicode
498 (format ", U+%04X" unicode)
499 "")))
500 ("charset"
501 ,(symbol-name charset)
502 ,(format "(%s)" (charset-description charset)))
503 ("code point"
504 ,(let ((split (split-char char)))
505 (if (= (charset-dimension charset) 1)
506 (format "%d" (nth 1 split))
507 (format "%d %d" (nth 1 split) (nth 2 split)))))
508 ("syntax"
509 ,(let ((syntax (syntax-after pos)))
510 (with-temp-buffer
511 (internal-describe-syntax-value syntax)
512 (buffer-string))))
513 ("category"
514 ,@(let ((category-set (char-category-set char)))
515 (if (not category-set)
516 '("-- none --")
517 (mapcar #'(lambda (x) (format "%c:%s "
518 x (category-docstring x)))
519 (category-set-mnemonics category-set)))))
520 ,@(let ((props (aref char-code-property-table char))
521 ps)
522 (when props
523 (while props
524 (push (format "%s:" (pop props)) ps)
525 (push (format "%s;" (pop props)) ps))
526 (list (cons "Properties" (nreverse ps)))))
527 ("buffer code"
528 ,(encoded-string-description
529 (string-as-unibyte (char-to-string char)) nil))
530 ("file code"
531 ,@(let* ((coding buffer-file-coding-system)
532 (encoded (encode-coding-char char coding)))
533 (if encoded
534 (list (encoded-string-description encoded coding)
535 (format "(encoded by coding system %S)" coding))
536 (list "not encodable by coding system"
537 (symbol-name coding)))))
538 ("display"
539 ,(cond
540 (disp-vector
541 (setq disp-vector (copy-sequence disp-vector))
542 (dotimes (i (length disp-vector))
543 (setq char (aref disp-vector i))
544 (aset disp-vector i
545 (cons char (describe-char-display pos char))))
546 (format "by display table entry [%s] (see below)"
547 (mapconcat #'(lambda (x) (format "?%c" (car x)))
548 disp-vector " ")))
549 (composition
550 (let ((from (car composition))
551 (to (nth 1 composition))
552 (next (1+ pos))
553 (components (nth 2 composition))
554 ch)
555 (setcar composition
556 (and (< from pos) (buffer-substring from pos)))
557 (setcar (cdr composition)
558 (and (< next to) (buffer-substring next to)))
559 (dotimes (i (length components))
560 (if (integerp (setq ch (aref components i)))
561 (push (cons ch (describe-char-display pos ch))
562 component-chars)))
563 (setq component-chars (nreverse component-chars))
564 (format "composed to form \"%s\" (see below)"
565 (buffer-substring from to))))
566 (t
567 (let ((display (describe-char-display pos char)))
568 (if (display-graphic-p (selected-frame))
569 (if display
570 (concat
571 "by this font (glyph code)\n"
572 (format " %s (0x%02X)"
573 (car display) (cdr display)))
574 "no font available")
575 (if display
576 (format "terminal code %s" display)
577 "not encodable for terminal"))))))
578 ,@(let ((unicodedata (and unicode
579 (describe-char-unicode-data unicode))))
580 (if unicodedata
581 (cons (list "Unicode data" " ") unicodedata))))))
582 (setq max-width (apply #'max (mapcar #'(lambda (x) (length (car x)))
583 item-list)))
584 (when (eq (current-buffer) (get-buffer "*Help*"))
585 (error "Can't describe char in Help buffer"))
586 (with-output-to-temp-buffer "*Help*"
587 (with-current-buffer standard-output
588 (set-buffer-multibyte multibyte-p)
589 (let ((formatter (format "%%%ds:" max-width)))
590 (dolist (elt item-list)
591 (when (cadr elt)
592 (insert (format formatter (car elt)))
593 (dolist (clm (cdr elt))
594 (when (>= (+ (current-column)
595 (or (string-match "\n" clm)
596 (string-width clm)) 1)
597 (window-width))
598 (insert "\n")
599 (indent-to (1+ max-width)))
600 (insert " " clm))
601 (insert "\n"))))
602
603 (when disp-vector
604 (insert
605 "\nThe display table entry is displayed by ")
606 (if (display-graphic-p (selected-frame))
607 (progn
608 (insert "these fonts (glyph codes):\n")
609 (dotimes (i (length disp-vector))
610 (insert (car (aref disp-vector i)) ?:
611 (propertize " " 'display '(space :align-to 5))
612 (if (cdr (aref disp-vector i))
613 (format "%s (0x%02X)" (cadr (aref disp-vector i))
614 (cddr (aref disp-vector i)))
615 "-- no font --")
616 "\n ")))
617 (insert "these terminal codes:\n")
618 (dotimes (i (length disp-vector))
619 (insert (car (aref disp-vector i))
620 (propertize " " 'display '(space :align-to 5))
621 (or (cdr (aref disp-vector i)) "-- not encodable --")
622 "\n"))))
623
624 (when composition
625 (insert "\nComposed")
626 (if (car composition)
627 (if (cadr composition)
628 (insert " with the surrounding characters \""
629 (car composition) "\" and \""
630 (cadr composition) "\"")
631 (insert " with the preceding character(s) \""
632 (car composition) "\""))
633 (if (cadr composition)
634 (insert " with the following character(s) \""
635 (cadr composition) "\"")))
636 (insert " by the rule:\n\t("
637 (mapconcat (lambda (x)
638 (format (if (consp x) "%S" "?%c") x))
639 (nth 2 composition)
640 " ")
641 ")")
642 (insert "\nThe component character(s) are displayed by ")
643 (if (display-graphic-p (selected-frame))
644 (progn
645 (insert "these fonts (glyph codes):")
646 (dolist (elt component-chars)
647 (insert "\n " (car elt) ?:
648 (propertize " " 'display '(space :align-to 5))
649 (if (cdr elt)
650 (format "%s (0x%02X)" (cadr elt) (cddr elt))
651 "-- no font --"))))
652 (insert "these terminal codes:")
653 (dolist (elt component-chars)
654 (insert "\n " (car elt) ":"
655 (propertize " " 'display '(space :align-to 5))
656 (or (cdr elt) "-- not encodable --"))))
657 (insert "\nSee the variable `reference-point-alist' for "
658 "the meaning of the rule.\n"))
659
660 (let ((output (current-buffer)))
661 (with-current-buffer buffer
662 (describe-text-properties pos output))
663 (describe-text-mode))))))
664
665 (defalias 'describe-char-after 'describe-char)
666 (make-obsolete 'describe-char-after 'describe-char "21.5")
667
668 (provide 'descr-text)
669
670 ;;; arch-tag: fc55a498-f3e9-4312-b5bd-98cc02480af1
671 ;;; descr-text.el ends here