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