(vc-ignore-vc-files, vc-master-templates, vc-header-alist):
[bpt/emacs.git] / lisp / descr-text.el
CommitLineData
dcb90b5f 1;;; descr-text.el --- describe text mode
2a1e884e 2
0d30b337 3;; Copyright (C) 1994, 1995, 1996, 2001, 2002, 2003, 2004,
409cc4a3 4;; 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
2a1e884e
RS
5
6;; Author: Boris Goldowsky <boris@gnu.org>
57d79b99 7;; Maintainer: FSF
2d65673f 8;; Keywords: faces, i18n, Unicode, multilingual
2a1e884e
RS
9
10;; This file is part of GNU Emacs.
11
12;; GNU Emacs is free software; you can redistribute it and/or modify
13;; it under the terms of the GNU General Public License as published by
b4aa6026 14;; the Free Software Foundation; either version 3, or (at your option)
2a1e884e
RS
15;; any later version.
16
17;; GNU Emacs is distributed in the hope that it will be useful,
18;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20;; GNU General Public License for more details.
21
22;; You should have received a copy of the GNU General Public License
23;; along with GNU Emacs; see the file COPYING. If not, write to the
086add15
LK
24;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
25;; Boston, MA 02110-1301, USA.
2a1e884e
RS
26
27;;; Commentary:
28
29;;; Describe-Text Mode.
30
31;;; Code:
32
e5a5c80c
NR
33(eval-when-compile (require 'quail))
34(require 'help-fns)
2a1e884e
RS
35
36;;; Describe-Text Utilities.
37
38(defun describe-text-widget (widget)
39 "Insert text to describe WIDGET in the current buffer."
57d79b99
NR
40 (insert-text-button
41 (symbol-name (if (symbolp widget) widget (car widget)))
42 'action `(lambda (&rest ignore)
e5a5c80c
NR
43 (widget-browse ',widget))
44 'help-echo "mouse-2, RET: browse this widget")
57d79b99 45 (insert " ")
e5a5c80c
NR
46 (insert-text-button
47 "(widget)Top" 'type 'help-info 'help-args '("(widget)Top")))
2a1e884e
RS
48
49(defun describe-text-sexp (sexp)
50 "Insert a short description of SEXP in the current buffer."
51 (let ((pp (condition-case signal
52 (pp-to-string sexp)
53 (error (prin1-to-string signal)))))
54 (when (string-match "\n\\'" pp)
55 (setq pp (substring pp 0 (1- (length pp)))))
56 (if (cond ((string-match "\n" pp)
57 nil)
58 ((> (length pp) (- (window-width) (current-column)))
59 nil)
60 (t t))
57d79b99
NR
61 (insert pp)
62 (insert-text-button
2fd54bf8 63 "[Show]" 'action `(lambda (&rest ignore)
57d79b99
NR
64 (with-output-to-temp-buffer
65 "*Pp Eval Output*"
66 (princ ',pp)))
67 'help-echo "mouse-2, RET: pretty print value in another buffer"))))
2a1e884e 68
4adb7c09 69(defun describe-property-list (properties)
2a1e884e
RS
70 "Insert a description of PROPERTIES in the current buffer.
71PROPERTIES should be a list of overlay or text properties.
7fb0741b 72The `category', `face' and `font-lock-face' properties are made
57d79b99 73into help buttons that call `describe-text-category' or
7fb0741b 74`describe-face' when pushed."
e2fa2f6e 75 ;; Sort the properties by the size of their value.
8b18fb8f 76 (dolist (elt (sort (let (ret)
e2fa2f6e 77 (while properties
8b18fb8f 78 (push (list (pop properties) (pop properties)) ret))
e2fa2f6e 79 ret)
d502fc06
RS
80 (lambda (a b) (string< (prin1-to-string (nth 0 a) t)
81 (prin1-to-string (nth 0 b) t)))))
e2fa2f6e
CW
82 (let ((key (nth 0 elt))
83 (value (nth 1 elt)))
57d79b99 84 (insert (propertize (format " %-20s " key)
e5a5c80c 85 'face 'help-argument-name))
2a1e884e 86 (cond ((eq key 'category)
e5a5c80c
NR
87 (insert-text-button
88 (symbol-name value)
89 'action `(lambda (&rest ignore)
90 (describe-text-category ',value))
91 'help-echo "mouse-2, RET: describe this category"))
8b18fb8f 92 ((memq key '(face font-lock-face mouse-face))
2fd54bf8
JL
93 (insert-text-button
94 (format "%S" value)
95 'type 'help-face 'help-args (list value)))
f13cc97d 96 ((widgetp value)
2a1e884e
RS
97 (describe-text-widget value))
98 (t
8b18fb8f 99 (describe-text-sexp value))))
57d79b99 100 (insert "\n")))
2a1e884e
RS
101\f
102;;; Describe-Text Commands.
103
104(defun describe-text-category (category)
105 "Describe a text property category."
e5a5c80c
NR
106 (interactive "SCategory: ")
107 (help-setup-xref (list #'describe-text-category category) (interactive-p))
2a1e884e 108 (save-excursion
ca9088e7
SM
109 (with-output-to-temp-buffer "*Help*"
110 (set-buffer standard-output)
57d79b99 111 (insert "Category " (format "%S" category) ":\n\n")
4adb7c09 112 (describe-property-list (symbol-plist category))
2a1e884e
RS
113 (goto-char (point-min)))))
114
115;;;###autoload
4adb7c09
RS
116(defun describe-text-properties (pos &optional output-buffer)
117 "Describe widgets, buttons, overlays and text properties at POS.
118Interactively, describe them for the character after point.
119If optional second argument OUTPUT-BUFFER is non-nil,
120insert the output into that buffer, and don't initialize or clear it
121otherwise."
2a1e884e 122 (interactive "d")
4adb7c09
RS
123 (if (>= pos (point-max))
124 (error "No character follows specified position"))
125 (if output-buffer
126 (describe-text-properties-1 pos output-buffer)
127 (if (not (or (text-properties-at pos) (overlays-at pos)))
128 (message "This is plain text.")
0911ac26
KS
129 (let ((buffer (current-buffer))
130 (target-buffer "*Help*"))
131 (when (eq buffer (get-buffer target-buffer))
e217c04e 132 (setq target-buffer "*Help*<2>"))
4adb7c09 133 (save-excursion
0911ac26 134 (with-output-to-temp-buffer target-buffer
ca9088e7 135 (set-buffer standard-output)
4adb7c09 136 (setq output-buffer (current-buffer))
57d79b99 137 (insert "Text content at position " (format "%d" pos) ":\n\n")
4adb7c09
RS
138 (with-current-buffer buffer
139 (describe-text-properties-1 pos output-buffer))
4adb7c09
RS
140 (goto-char (point-min))))))))
141
142(defun describe-text-properties-1 (pos output-buffer)
2a1e884e
RS
143 (let* ((properties (text-properties-at pos))
144 (overlays (overlays-at pos))
2a1e884e
RS
145 (wid-field (get-char-property pos 'field))
146 (wid-button (get-char-property pos 'button))
147 (wid-doc (get-char-property pos 'widget-doc))
148 ;; If button.el is not loaded, we have no buttons in the text.
149 (button (and (fboundp 'button-at) (button-at pos)))
150 (button-type (and button (button-type button)))
151 (button-label (and button (button-label button)))
152 (widget (or wid-field wid-button wid-doc)))
4adb7c09
RS
153 (with-current-buffer output-buffer
154 ;; Widgets
155 (when (widgetp widget)
156 (newline)
57d79b99
NR
157 (insert (cond (wid-field "This is an editable text area")
158 (wid-button "This is an active area")
159 (wid-doc "This is documentation text")))
160 (insert " of a ")
4adb7c09 161 (describe-text-widget widget)
57d79b99 162 (insert ".\n\n"))
4adb7c09
RS
163 ;; Buttons
164 (when (and button (not (widgetp wid-button)))
165 (newline)
2fd54bf8
JL
166 (insert "Here is a `" (format "%S" button-type)
167 "' button labeled `" button-label "'.\n\n"))
4adb7c09
RS
168 ;; Overlays
169 (when overlays
170 (newline)
171 (if (eq (length overlays) 1)
57d79b99
NR
172 (insert "There is an overlay here:\n")
173 (insert "There are " (format "%d" (length overlays))
4adb7c09
RS
174 " overlays here:\n"))
175 (dolist (overlay overlays)
57d79b99 176 (insert " From " (format "%d" (overlay-start overlay))
4adb7c09
RS
177 " to " (format "%d" (overlay-end overlay)) "\n")
178 (describe-property-list (overlay-properties overlay)))
57d79b99 179 (insert "\n"))
4adb7c09
RS
180 ;; Text properties
181 (when properties
182 (newline)
57d79b99 183 (insert "There are text properties here:\n")
4adb7c09 184 (describe-property-list properties)))))
d6c135fb 185\f
f1f194de
KH
186(defcustom describe-char-unidata-list nil
187 "List of Unicode-based character property names shown by `describe-char'."
188 :group 'mule
8589dc17 189 :version "23.1"
3253c7c6
SM
190 :type '(choice (const :tag "All properties" t)
191 (set
192 (const :tag "Unicode Name" name)
193 (const :tag "Unicode general category " general-category)
194 (const :tag "Unicode canonical combining class"
195 canonical-combining-class)
196 (const :tag "Unicode bidi class" bidi-class)
197 (const :tag "Unicode decomposition mapping" decomposition)
198 (const :tag "Unicode decimal digit value" decimal-digit-value)
199 (const :tag "Unicode digit value" digit-value)
200 (const :tag "Unicode numeric value" numeric-value)
201 (const :tag "Unicode mirrored" mirrored)
202 (const :tag "Unicode old name" old-name)
203 (const :tag "Unicode ISO 10646 comment" iso-10646-comment)
204 (const :tag "Unicode simple uppercase mapping" uppercase)
205 (const :tag "Unicode simple lowercase mapping" lowercase)
206 (const :tag "Unicode simple titlecase mapping" titlecase))))
f1f194de 207
49c2a2dc
SM
208(defcustom describe-char-unicodedata-file nil
209 "Location of Unicode data file.
2acb13b1 210This is the UnicodeData.txt file from the Unicode Consortium, used for
2a4960f9 211diagnostics. If it is non-nil `describe-char' will print data
49c2a2dc
SM
212looked up from it. This facility is mostly of use to people doing
213multilingual development.
4adb7c09 214
2acb13b1
JB
215This is a fairly large file, not typically present on GNU systems.
216At the time of writing it is at the URL
57d79b99 217`http://www.unicode.org/Public/UNIDATA/UnicodeData.txt'."
49c2a2dc 218 :group 'mule
bf247b6e 219 :version "22.1"
49c2a2dc
SM
220 :type '(choice (const :tag "None" nil)
221 file))
831ccfa6 222
49c2a2dc
SM
223(defun describe-char-unicode-data (char)
224 "Return a list of Unicode data for unicode CHAR.
225Each element is a list of a property description and the property value.
f1f194de
KH
226The list is null if CHAR isn't found in `describe-char-unicodedata-file'.
227This function is semi-obsolete. Use `get-char-code-property'."
49c2a2dc
SM
228 (when describe-char-unicodedata-file
229 (unless (file-exists-p describe-char-unicodedata-file)
230 (error "`unicodedata-file' %s not found" describe-char-unicodedata-file))
def7167b
JB
231 (with-current-buffer (get-buffer-create " *Unicode Data*")
232 (when (zerop (buffer-size))
233 ;; Don't use -literally in case of DOS line endings.
234 (insert-file-contents describe-char-unicodedata-file))
49c2a2dc
SM
235 (goto-char (point-min))
236 (let ((hex (format "%04X" char))
237 found first last)
238 (if (re-search-forward (concat "^" hex) nil t)
239 (setq found t)
240 ;; It's not listed explicitly. Look for ranges, e.g. CJK
241 ;; ideographs, and check whether it's in one of them.
242 (while (and (re-search-forward "^\\([^;]+\\);[^;]+First>;" nil t)
243 (>= char (setq first
244 (string-to-number (match-string 1) 16)))
245 (progn
246 (forward-line 1)
247 (looking-at "^\\([^;]+\\);[^;]+Last>;")
248 (> char
249 (setq last
250 (string-to-number (match-string 1) 16))))))
251 (if (and (>= char first)
252 (<= char last))
253 (setq found t)))
254 (if found
255 (let ((fields (mapcar (lambda (elt)
256 (if (> (length elt) 0)
257 elt))
258 (cdr (split-string
259 (buffer-substring
260 (line-beginning-position)
261 (line-end-position))
262 ";")))))
263 ;; The length depends on whether the last field was empty.
264 (unless (or (= 13 (length fields))
265 (= 14 (length fields)))
266 (error "Invalid contents in %s" describe-char-unicodedata-file))
267 ;; The field names and values lists are slightly
268 ;; modified from Mule-UCS unidata.el.
269 (list
270 (list "Name" (let ((name (nth 0 fields)))
271 ;; Check for <..., First>, <..., Last>
272 (if (string-match "\\`\\(<[^,]+\\)," name)
273 (concat (match-string 1 name) ">")
274 name)))
275 (list "Category"
f1f194de
KH
276 (let ((val (nth 1 fields)))
277 (or (char-code-property-description
278 'general-category (intern val))
279 val)))
49c2a2dc 280 (list "Combining class"
f1f194de
KH
281 (let ((val (nth 1 fields)))
282 (or (char-code-property-description
283 'canonical-combining-class (intern val))
284 val)))
49c2a2dc 285 (list "Bidi category"
f1f194de
KH
286 (let ((val (nth 1 fields)))
287 (or (char-code-property-description
288 'bidi-class (intern val))
289 val)))
49c2a2dc
SM
290 (list
291 "Decomposition"
292 (if (nth 4 fields)
293 (let* ((parts (split-string (nth 4 fields)))
294 (info (car parts)))
295 (if (string-match "\\`<\\(.+\\)>\\'" info)
296 (setq info (match-string 1 info))
297 (setq info nil))
298 (if info (setq parts (cdr parts)))
49c2a2dc
SM
299 (setq parts (mapconcat
300 (lambda (arg)
f1f194de 301 (string (string-to-number arg 16)))
49c2a2dc
SM
302 parts " "))
303 (concat info parts))))
304 (list "Decimal digit value"
305 (nth 5 fields))
306 (list "Digit value"
307 (nth 6 fields))
308 (list "Numeric value"
309 (nth 7 fields))
310 (list "Mirrored"
311 (if (equal "Y" (nth 8 fields))
312 "yes"))
313 (list "Old name" (nth 9 fields))
314 (list "ISO 10646 comment" (nth 10 fields))
315 (list "Uppercase" (and (nth 11 fields)
f1f194de
KH
316 (string (string-to-number
317 (nth 11 fields) 16))))
49c2a2dc 318 (list "Lowercase" (and (nth 12 fields)
f1f194de
KH
319 (string (string-to-number
320 (nth 12 fields) 16))))
49c2a2dc 321 (list "Titlecase" (and (nth 13 fields)
f1f194de
KH
322 (string (string-to-number
323 (nth 13 fields) 16)))))))))))
7fb0741b
KH
324
325;; Return information about how CHAR is displayed at the buffer
326;; position POS. If the selected frame is on a graphic display,
e463f071
KH
327;; return a cons (FONTNAME . GLYPH-CODE) where GLYPH-CODE is a
328;; hexadigit string representing the glyph-ID. Otherwise, return a
329;; string describing the terminal codes for the character.
7fb0741b
KH
330(defun describe-char-display (pos char)
331 (if (display-graphic-p (selected-frame))
e463f071 332 (let ((char-font-info (internal-char-font pos char)))
a6bbf9f4
KH
333 (if char-font-info
334 (if (integerp (cdr char-font-info))
335 (setcdr char-font-info (format "%02X" (cdr char-font-info)))
336 (setcdr char-font-info
337 (format "%04X%04X"
338 (cadr char-font-info) (cddr char-font-info)))))
e463f071 339 char-font-info)
7fb0741b
KH
340 (let* ((coding (terminal-coding-system))
341 (encoded (encode-coding-char char coding)))
342 (if encoded
343 (encoded-string-description encoded coding)))))
344
d6c135fb 345\f
4adb7c09
RS
346;;;###autoload
347(defun describe-char (pos)
348 "Describe the character after POS (interactively, the character after point).
349The information includes character code, charset and code points in it,
350syntax, category, how the character is encoded in a file,
351character composition information (if relevant),
352as well as widgets, buttons, overlays, and text properties."
353 (interactive "d")
4adb7c09
RS
354 (if (>= pos (point-max))
355 (error "No character follows specified position"))
356 (let* ((char (char-after pos))
357 (charset (char-charset char))
ca9088e7 358 (composition (find-composition pos nil nil t))
7fb0741b
KH
359 (component-chars nil)
360 (display-table (or (window-display-table)
361 buffer-display-table
362 standard-display-table))
363 (disp-vector (and display-table (aref display-table char)))
4adb7c09 364 (multibyte-p enable-multibyte-characters)
6482d093
KH
365 (overlays (mapcar #'(lambda (o) (overlay-properties o))
366 (overlays-at pos)))
6398b88f
AS
367 (char-description (if (not multibyte-p)
368 (single-key-description char)
369 (if (< char 128)
370 (single-key-description char)
371 (string-to-multibyte
372 (char-to-string char)))))
e5a5c80c
NR
373 (text-props-desc
374 (let ((tmp-buf (generate-new-buffer " *text-props*")))
375 (unwind-protect
376 (progn
377 (describe-text-properties pos tmp-buf)
378 (with-current-buffer tmp-buf (buffer-string)))
379 (kill-buffer tmp-buf))))
327719ee 380 item-list max-width code)
831ccfa6 381
327719ee 382 (setq code (encode-char char charset))
ed441285
KH
383 (setq item-list
384 `(("character"
41882805 385 ,(format "%s (%d, #o%o, #x%x)"
e5a5c80c
NR
386 (apply 'propertize char-description
387 (text-properties-at pos))
41882805 388 char char char))
327719ee 389 ("preferred charset"
57d79b99 390 ,`(insert-text-button
e5a5c80c
NR
391 ,(symbol-name charset)
392 'type 'help-character-set 'help-args '(,charset))
ed441285
KH
393 ,(format "(%s)" (charset-description charset)))
394 ("code point"
879dfc97
KH
395 ,(let ((str (if (integerp code)
396 (format (if (< code 256) "0x%02X" "0x%04X") code)
397 (format "0x%04X%04X" (car code) (cdr code)))))
398 (if (<= (charset-dimension charset) 2)
41882805
MB
399 `(insert-text-button
400 ,str
401 'action (lambda (&rest ignore)
879dfc97
KH
402 (list-charset-chars ',charset)
403 (with-selected-window
404 (get-buffer-window "*Character List*" 0)
405 (goto-char (point-min))
406 (forward-line 2) ;Skip the header.
407 (let ((case-fold-search nil))
408 (if (search-forward ,(char-to-string char)
409 nil t)
410 (goto-char (match-beginning 0))))))
41882805
MB
411 'help-echo
412 "mouse-2, RET: show this character in its character set")
879dfc97 413 str)))
ed441285 414 ("syntax"
d8ac3d27 415 ,(let ((syntax (syntax-after pos)))
ed441285
KH
416 (with-temp-buffer
417 (internal-describe-syntax-value syntax)
418 (buffer-string))))
419 ("category"
420 ,@(let ((category-set (char-category-set char)))
421 (if (not category-set)
422 '("-- none --")
9f40939d 423 (mapcar #'(lambda (x) (format "%c:%s"
ed441285
KH
424 x (category-docstring x)))
425 (category-set-mnemonics category-set)))))
309473d0 426 ("to input"
22259c93
KH
427 ,@(let ((key-list (and (eq input-method-function
428 'quail-input-method)
309473d0
KH
429 (quail-find-key char))))
430 (if (consp key-list)
431 (list "type"
432 (mapconcat #'(lambda (x) (concat "\"" x "\""))
fedbc8e5
JL
433 key-list " or ")
434 "with"
57d79b99 435 `(insert-text-button
2fd54bf8 436 ,current-input-method
e5a5c80c
NR
437 'type 'help-input-method
438 'help-args '(,current-input-method))))))
ed441285
KH
439 ("buffer code"
440 ,(encoded-string-description
441 (string-as-unibyte (char-to-string char)) nil))
442 ("file code"
443 ,@(let* ((coding buffer-file-coding-system)
444 (encoded (encode-coding-char char coding)))
445 (if encoded
446 (list (encoded-string-description encoded coding)
447 (format "(encoded by coding system %S)" coding))
448 (list "not encodable by coding system"
449 (symbol-name coding)))))
450 ("display"
451 ,(cond
452 (disp-vector
453 (setq disp-vector (copy-sequence disp-vector))
454 (dotimes (i (length disp-vector))
455 (setq char (aref disp-vector i))
456 (aset disp-vector i
8b18fb8f 457 (cons char (describe-char-display
da55bb96 458 pos (glyph-char char)))))
ed441285 459 (format "by display table entry [%s] (see below)"
8b18fb8f
JL
460 (mapconcat
461 #'(lambda (x)
da55bb96 462 (format "?%c" (glyph-char (car x))))
8b18fb8f 463 disp-vector " ")))
ed441285
KH
464 (composition
465 (let ((from (car composition))
466 (to (nth 1 composition))
467 (next (1+ pos))
468 (components (nth 2 composition))
469 ch)
470 (setcar composition
471 (and (< from pos) (buffer-substring from pos)))
472 (setcar (cdr composition)
473 (and (< next to) (buffer-substring next to)))
474 (dotimes (i (length components))
475 (if (integerp (setq ch (aref components i)))
476 (push (cons ch (describe-char-display pos ch))
477 component-chars)))
478 (setq component-chars (nreverse component-chars))
479 (format "composed to form \"%s\" (see below)"
480 (buffer-substring from to))))
481 (t
482 (let ((display (describe-char-display pos char)))
483 (if (display-graphic-p (selected-frame))
7fb0741b 484 (if display
ed441285
KH
485 (concat
486 "by this font (glyph code)\n"
e463f071 487 (format " %s (#x%s)"
ed441285
KH
488 (car display) (cdr display)))
489 "no font available")
490 (if display
491 (format "terminal code %s" display)
492 "not encodable for terminal"))))))
879dfc97
KH
493 ,@(let ((face
494 (if (not (or disp-vector composition))
495 (cond
496 ((and show-trailing-whitespace
497 (save-excursion (goto-char pos)
498 (looking-at "[ \t]+$")))
499 'trailing-whitespace)
500 ((and nobreak-char-display char (eq char '#xa0))
501 'nobreak-space)
502 ((and nobreak-char-display char (eq char '#xad))
503 'escape-glyph)
504 ((and (< char 32) (not (memq char '(9 10))))
505 'escape-glyph)))))
506 (if face (list (list "hardcoded face"
2fd54bf8
JL
507 `(insert-text-button
508 ,(symbol-name face)
509 'type 'help-face 'help-args '(,face))))))
180505d5 510 ,@(let ((unicodedata (describe-char-unicode-data char)))
ed441285
KH
511 (if unicodedata
512 (cons (list "Unicode data" " ") unicodedata)))))
95eede5c 513 (setq max-width (apply #'max (mapcar #'(lambda (x)
879dfc97 514 (if (cadr x) (length (car x)) 0))
4adb7c09 515 item-list)))
bfd94110 516 (help-setup-xref nil (interactive-p))
3db0e8bf 517 (with-help-window (help-buffer)
ca9088e7 518 (with-current-buffer standard-output
4adb7c09
RS
519 (set-buffer-multibyte multibyte-p)
520 (let ((formatter (format "%%%ds:" max-width)))
521 (dolist (elt item-list)
831ccfa6
DL
522 (when (cadr elt)
523 (insert (format formatter (car elt)))
524 (dolist (clm (cdr elt))
57d79b99 525 (if (eq (car-safe clm) 'insert-text-button)
fedbc8e5
JL
526 (progn (insert " ") (eval clm))
527 (when (>= (+ (current-column)
528 (or (string-match "\n" clm)
529 (string-width clm))
530 1)
531 (window-width))
532 (insert "\n")
533 (indent-to (1+ max-width)))
534 (insert " " clm)))
831ccfa6 535 (insert "\n"))))
7fb0741b 536
086c5b2b
KH
537 (when overlays
538 (save-excursion
539 (goto-char (point-min))
540 (re-search-forward "character:[ \t\n]+")
541 (let* ((end (+ (point) (length char-description))))
6398b88f 542 (mapc #'(lambda (props)
086c5b2b 543 (let ((o (make-overlay (point) end)))
6398b88f
AS
544 (while props
545 (overlay-put o (car props) (nth 1 props))
546 (setq props (cddr props)))))
086c5b2b 547 overlays))))
ed441285 548
7fb0741b
KH
549 (when disp-vector
550 (insert
551 "\nThe display table entry is displayed by ")
552 (if (display-graphic-p (selected-frame))
553 (progn
554 (insert "these fonts (glyph codes):\n")
555 (dotimes (i (length disp-vector))
da55bb96 556 (insert (glyph-char (car (aref disp-vector i))) ?:
7fb0741b
KH
557 (propertize " " 'display '(space :align-to 5))
558 (if (cdr (aref disp-vector i))
e463f071 559 (format "%s (#x%s)" (cadr (aref disp-vector i))
7fb0741b
KH
560 (cddr (aref disp-vector i)))
561 "-- no font --")
fedbc8e5 562 "\n")
da55bb96
KS
563 (let ((face (glyph-face (car (aref disp-vector i)))))
564 (when face
565 (insert (propertize " " 'display '(space :align-to 5))
566 "face: ")
567 (insert (concat "`" (symbol-name face) "'"))
568 (insert "\n")))))
7fb0741b
KH
569 (insert "these terminal codes:\n")
570 (dotimes (i (length disp-vector))
571 (insert (car (aref disp-vector i))
572 (propertize " " 'display '(space :align-to 5))
573 (or (cdr (aref disp-vector i)) "-- not encodable --")
574 "\n"))))
575
4adb7c09 576 (when composition
7fb0741b
KH
577 (insert "\nComposed")
578 (if (car composition)
579 (if (cadr composition)
580 (insert " with the surrounding characters \""
581 (car composition) "\" and \""
582 (cadr composition) "\"")
583 (insert " with the preceding character(s) \""
584 (car composition) "\""))
585 (if (cadr composition)
586 (insert " with the following character(s) \""
587 (cadr composition) "\"")))
3f8b1daa
KH
588 (if (and (vectorp (nth 2 composition))
589 (vectorp (aref (nth 2 composition) 0)))
7fb0741b 590 (progn
b2c6a479
KH
591 (insert " using this font:\n "
592 (aref (query-font (aref (aref (nth 2 composition) 0) 0))
593 0)
594 "\nby these glyphs:\n")
3f8b1daa
KH
595 (mapc (lambda (x) (insert (format " %S\n" x)))
596 (nth 2 composition)))
597 (insert " by the rule:\n\t("
598 (mapconcat (lambda (x)
599 (if (consp x) (format "%S" x)
600 (if (= x ?\t)
601 (single-key-description x)
602 (string ?? x))))
603 (nth 2 composition)
604 " ")
605 ")")
606 (insert "\nThe component character(s) are displayed by ")
607 (if (display-graphic-p (selected-frame))
608 (progn
609 (insert "these fonts (glyph codes):")
610 (dolist (elt component-chars)
611 (if (/= (car elt) ?\t)
612 (insert "\n " (car elt) ?:
613 (propertize " " 'display '(space :align-to 5))
614 (if (cdr elt)
e463f071 615 (format "%s (#x%s)" (cadr elt) (cddr elt))
3f8b1daa
KH
616 "-- no font --")))))
617 (insert "these terminal codes:")
618 (dolist (elt component-chars)
619 (insert "\n " (car elt) ":"
620 (propertize " " 'display '(space :align-to 4))
621 (or (cdr elt) "-- not encodable --"))))
622 (insert "\nSee the variable `reference-point-alist' for "
623 "the meaning of the rule.\n")))
3a73f428 624
3253c7c6
SM
625 (insert (if (not describe-char-unidata-list)
626 "\nCharacter code properties are not shown: "
627 "\nCharacter code properties: "))
3424774b
KH
628 (insert-text-button
629 "customize what to show"
630 'action (lambda (&rest ignore)
631 (customize-variable
632 'describe-char-unidata-list)))
f1f194de 633 (insert "\n")
3253c7c6 634 (dolist (elt (if (eq describe-char-unidata-list t)
95eede5c 635 (nreverse (mapcar 'car char-code-property-alist))
3253c7c6 636 describe-char-unidata-list))
f1f194de
KH
637 (let ((val (get-char-code-property char elt))
638 description)
639 (when val
640 (setq description (char-code-property-description elt val))
3253c7c6
SM
641 (insert (if description
642 (format " %s: %s (%s)\n" elt val description)
643 (format " %s: %s\n" elt val))))))
f1f194de 644
25a3c9d1 645 (if text-props-desc (insert text-props-desc))
2fd54bf8 646 (setq help-xref-stack-item (list 'help-insert-string (buffer-string)))
3db0e8bf 647 (toggle-read-only 1)))))
4adb7c09 648
781424c2 649(define-obsolete-function-alias 'describe-char-after 'describe-char "22.1")
831ccfa6 650
288395a7
CW
651(provide 'descr-text)
652
d8ac3d27 653;; arch-tag: fc55a498-f3e9-4312-b5bd-98cc02480af1
2a1e884e 654;;; descr-text.el ends here