* cedet/mode-local.el (make-obsolete-overload): Add `when' argument.
[bpt/emacs.git] / lisp / descr-text.el
... / ...
CommitLineData
1;;; descr-text.el --- describe text mode
2
3;; Copyright (C) 1994, 1995, 1996, 2001, 2002, 2003, 2004,
4;; 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
5
6;; Author: Boris Goldowsky <boris@gnu.org>
7;; Maintainer: FSF
8;; Keywords: faces, i18n, Unicode, multilingual
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
14;; the Free Software Foundation, either version 3 of the License, or
15;; (at your option) 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. If not, see <http://www.gnu.org/licenses/>.
24
25;;; Commentary:
26
27;;; Describe-Text Mode.
28
29;;; Code:
30
31(eval-when-compile (require 'quail))
32(require 'help-fns)
33
34;;; Describe-Text Utilities.
35
36(defun describe-text-widget (widget)
37 "Insert text to describe WIDGET in the current buffer."
38 (insert-text-button
39 (symbol-name (if (symbolp widget) widget (car widget)))
40 'action `(lambda (&rest ignore)
41 (widget-browse ',widget))
42 'help-echo "mouse-2, RET: browse this widget")
43 (insert " ")
44 (insert-text-button
45 "(widget)Top" 'type 'help-info 'help-args '("(widget)Top")))
46
47(defun describe-text-sexp (sexp)
48 "Insert a short description of SEXP in the current buffer."
49 (let ((pp (condition-case signal
50 (pp-to-string sexp)
51 (error (prin1-to-string signal)))))
52 (when (string-match-p "\n\\'" pp)
53 (setq pp (substring pp 0 (1- (length pp)))))
54
55 (if (and (not (string-match-p "\n" pp))
56 (<= (length pp) (- (window-width) (current-column))))
57 (insert pp)
58 (insert-text-button
59 "[Show]" 'action `(lambda (&rest ignore)
60 (with-output-to-temp-buffer
61 "*Pp Eval Output*"
62 (princ ',pp)))
63 'help-echo "mouse-2, RET: pretty print value in another buffer"))))
64
65(defun describe-property-list (properties)
66 "Insert a description of PROPERTIES in the current buffer.
67PROPERTIES should be a list of overlay or text properties.
68The `category', `face' and `font-lock-face' properties are made
69into help buttons that call `describe-text-category' or
70`describe-face' when pushed."
71 ;; Sort the properties by the size of their value.
72 (dolist (elt (sort (let (ret)
73 (while properties
74 (push (list (pop properties) (pop properties)) ret))
75 ret)
76 (lambda (a b) (string< (prin1-to-string (nth 0 a) t)
77 (prin1-to-string (nth 0 b) t)))))
78 (let ((key (nth 0 elt))
79 (value (nth 1 elt)))
80 (insert (propertize (format " %-20s " key)
81 'face 'help-argument-name))
82 (cond ((eq key 'category)
83 (insert-text-button
84 (symbol-name value)
85 'action `(lambda (&rest ignore)
86 (describe-text-category ',value))
87 'follow-link t
88 'help-echo "mouse-2, RET: describe this category"))
89 ((memq key '(face font-lock-face mouse-face))
90 (insert-text-button
91 (format "%S" value)
92 'type 'help-face 'help-args (list value)))
93 ((widgetp value)
94 (describe-text-widget value))
95 (t
96 (describe-text-sexp value))))
97 (insert "\n")))
98\f
99;;; Describe-Text Commands.
100
101(defun describe-text-category (category)
102 "Describe a text property category."
103 (interactive "SCategory: ")
104 (help-setup-xref (list #'describe-text-category category)
105 (called-interactively-p 'interactive))
106 (save-excursion
107 (with-output-to-temp-buffer "*Help*"
108 (set-buffer standard-output)
109 (insert "Category " (format "%S" category) ":\n\n")
110 (describe-property-list (symbol-plist category))
111 (goto-char (point-min)))))
112
113;;;###autoload
114(defun describe-text-properties (pos &optional output-buffer)
115 "Describe widgets, buttons, overlays and text properties at POS.
116Interactively, describe them for the character after point.
117If optional second argument OUTPUT-BUFFER is non-nil,
118insert the output into that buffer, and don't initialize or clear it
119otherwise."
120 (interactive "d")
121 (if (>= pos (point-max))
122 (error "No character follows specified position"))
123 (if output-buffer
124 (describe-text-properties-1 pos output-buffer)
125 (if (not (or (text-properties-at pos) (overlays-at pos)))
126 (message "This is plain text.")
127 (let ((buffer (current-buffer))
128 (target-buffer "*Help*"))
129 (when (eq buffer (get-buffer target-buffer))
130 (setq target-buffer "*Help*<2>"))
131 (save-excursion
132 (with-output-to-temp-buffer target-buffer
133 (set-buffer standard-output)
134 (setq output-buffer (current-buffer))
135 (insert "Text content at position " (format "%d" pos) ":\n\n")
136 (with-current-buffer buffer
137 (describe-text-properties-1 pos output-buffer))
138 (goto-char (point-min))))))))
139
140(defun describe-text-properties-1 (pos output-buffer)
141 (let* ((properties (text-properties-at pos))
142 (overlays (overlays-at pos))
143 (wid-field (get-char-property pos 'field))
144 (wid-button (get-char-property pos 'button))
145 (wid-doc (get-char-property pos 'widget-doc))
146 ;; If button.el is not loaded, we have no buttons in the text.
147 (button (and (fboundp 'button-at) (button-at pos)))
148 (button-type (and button (button-type button)))
149 (button-label (and button (button-label button)))
150 (widget (or wid-field wid-button wid-doc)))
151 (with-current-buffer output-buffer
152 ;; Widgets
153 (when (widgetp widget)
154 (newline)
155 (insert (cond (wid-field "This is an editable text area")
156 (wid-button "This is an active area")
157 (wid-doc "This is documentation text")))
158 (insert " of a ")
159 (describe-text-widget widget)
160 (insert ".\n\n"))
161 ;; Buttons
162 (when (and button (not (widgetp wid-button)))
163 (newline)
164 (insert "Here is a `" (format "%S" button-type)
165 "' button labeled `" button-label "'.\n\n"))
166 ;; Overlays
167 (when overlays
168 (newline)
169 (if (eq (length overlays) 1)
170 (insert "There is an overlay here:\n")
171 (insert "There are " (format "%d" (length overlays))
172 " overlays here:\n"))
173 (dolist (overlay overlays)
174 (insert " From " (format "%d" (overlay-start overlay))
175 " to " (format "%d" (overlay-end overlay)) "\n")
176 (describe-property-list (overlay-properties overlay)))
177 (insert "\n"))
178 ;; Text properties
179 (when properties
180 (newline)
181 (insert "There are text properties here:\n")
182 (describe-property-list properties)))))
183\f
184(defcustom describe-char-unidata-list
185 '(name old-name general-category decomposition)
186 "List of Unicode-based character property names shown by `describe-char'."
187 :group 'mule
188 :version "23.1"
189 :type '(choice (const :tag "All properties" t)
190 (set
191 (const :tag "Unicode Name" name)
192 (const :tag "Unicode old name" old-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 ISO 10646 comment" iso-10646-comment)
203 (const :tag "Unicode simple uppercase mapping" uppercase)
204 (const :tag "Unicode simple lowercase mapping" lowercase)
205 (const :tag "Unicode simple titlecase mapping" titlecase))))
206
207(defcustom describe-char-unicodedata-file nil
208 "Location of Unicode data file.
209This is the UnicodeData.txt file from the Unicode Consortium, used for
210diagnostics. If it is non-nil `describe-char' will print data
211looked up from it. This facility is mostly of use to people doing
212multilingual development.
213
214This is a fairly large file, not typically present on GNU systems.
215At the time of writing it is at the URL
216`http://www.unicode.org/Public/UNIDATA/UnicodeData.txt'."
217 :group 'mule
218 :version "22.1"
219 :type '(choice (const :tag "None" nil)
220 file))
221
222(defun describe-char-unicode-data (char)
223 "Return a list of Unicode data for unicode CHAR.
224Each element is a list of a property description and the property value.
225The list is null if CHAR isn't found in `describe-char-unicodedata-file'.
226This function is semi-obsolete. Use `get-char-code-property'."
227 (when describe-char-unicodedata-file
228 (unless (file-exists-p describe-char-unicodedata-file)
229 (error "`unicodedata-file' %s not found" describe-char-unicodedata-file))
230 (with-current-buffer (get-buffer-create " *Unicode Data*")
231 (when (zerop (buffer-size))
232 ;; Don't use -literally in case of DOS line endings.
233 (insert-file-contents describe-char-unicodedata-file))
234 (goto-char (point-min))
235 (let ((hex (format "%04X" char))
236 found first last)
237 (if (re-search-forward (concat "^" hex) nil t)
238 (setq found t)
239 ;; It's not listed explicitly. Look for ranges, e.g. CJK
240 ;; ideographs, and check whether it's in one of them.
241 (while (and (re-search-forward "^\\([^;]+\\);[^;]+First>;" nil t)
242 (>= char (setq first
243 (string-to-number (match-string 1) 16)))
244 (progn
245 (forward-line 1)
246 (looking-at "^\\([^;]+\\);[^;]+Last>;")
247 (> char
248 (setq last
249 (string-to-number (match-string 1) 16))))))
250 (if (and (>= char first)
251 (<= char last))
252 (setq found t)))
253 (if found
254 (let ((fields (mapcar (lambda (elt)
255 (if (> (length elt) 0)
256 elt))
257 (cdr (split-string
258 (buffer-substring
259 (line-beginning-position)
260 (line-end-position))
261 ";")))))
262 ;; The length depends on whether the last field was empty.
263 (unless (or (= 13 (length fields))
264 (= 14 (length fields)))
265 (error "Invalid contents in %s" describe-char-unicodedata-file))
266 ;; The field names and values lists are slightly
267 ;; modified from Mule-UCS unidata.el.
268 (list
269 (list "Name" (let ((name (nth 0 fields)))
270 ;; Check for <..., First>, <..., Last>
271 (if (string-match "\\`\\(<[^,]+\\)," name)
272 (concat (match-string 1 name) ">")
273 name)))
274 (list "Category"
275 (let ((val (nth 1 fields)))
276 (or (char-code-property-description
277 'general-category (intern val))
278 val)))
279 (list "Combining class"
280 (let ((val (nth 1 fields)))
281 (or (char-code-property-description
282 'canonical-combining-class (intern val))
283 val)))
284 (list "Bidi category"
285 (let ((val (nth 1 fields)))
286 (or (char-code-property-description
287 'bidi-class (intern val))
288 val)))
289 (list
290 "Decomposition"
291 (if (nth 4 fields)
292 (let* ((parts (split-string (nth 4 fields)))
293 (info (car parts)))
294 (if (string-match "\\`<\\(.+\\)>\\'" info)
295 (setq info (match-string 1 info))
296 (setq info nil))
297 (if info (setq parts (cdr parts)))
298 (setq parts (mapconcat
299 (lambda (arg)
300 (string (string-to-number arg 16)))
301 parts " "))
302 (concat info parts))))
303 (list "Decimal digit value"
304 (nth 5 fields))
305 (list "Digit value"
306 (nth 6 fields))
307 (list "Numeric value"
308 (nth 7 fields))
309 (list "Mirrored"
310 (if (equal "Y" (nth 8 fields))
311 "yes"))
312 (list "Old name" (nth 9 fields))
313 (list "ISO 10646 comment" (nth 10 fields))
314 (list "Uppercase" (and (nth 11 fields)
315 (string (string-to-number
316 (nth 11 fields) 16))))
317 (list "Lowercase" (and (nth 12 fields)
318 (string (string-to-number
319 (nth 12 fields) 16))))
320 (list "Titlecase" (and (nth 13 fields)
321 (string (string-to-number
322 (nth 13 fields) 16)))))))))))
323
324;; Not defined on builds without X, but behind display-graphic-p.
325(declare-function internal-char-font "fontset.c" (position &optional ch))
326
327;; Return information about how CHAR is displayed at the buffer
328;; position POS. If the selected frame is on a graphic display,
329;; return a string "FONT-DRIVER:FONT-NAME (GLYPH-CODE)" where:
330;; FONT-DRIVER is the font-driver name,
331;; FONT-NAME is the font name,
332;; GLYPH-CODE is a hexadigit string representing the glyph-ID.
333;; Otherwise, return a string describing the terminal codes for the
334;; character.
335(defun describe-char-display (pos char)
336 (if (display-graphic-p (selected-frame))
337 (let ((char-font-info (internal-char-font pos char)))
338 (if char-font-info
339 (let ((type (font-get (car char-font-info) :type))
340 (name (font-xlfd-name (car char-font-info)))
341 (code (cdr char-font-info)))
342 (if (integerp code)
343 (format "%s:%s (#x%02X)" type name code)
344 (format "%s:%s (#x%04X%04X)"
345 type name (car code) (cdr code))))))
346 (let* ((charset (get-text-property pos 'charset))
347 (coding (or (terminal-coding-system) 'us-ascii))
348 (encoded (encode-coding-char char coding charset)))
349 (if encoded
350 (encoded-string-description encoded coding)))))
351
352\f
353;; Return a string of CH with composition for padding on both sides.
354;; It is displayed without overlapping with the left/right columns.
355(defsubst describe-char-padded-string (ch)
356 (compose-string (string ch) 0 1 (format "\t%c\t" ch)))
357
358;; Return a nicely formated list of categories; extended category
359;; description is added to the category name as a tooltip
360(defsubst describe-char-categories (category-set)
361 (let ((mnemonics (category-set-mnemonics category-set)))
362 (unless (eq mnemonics "")
363 (list (mapconcat
364 #'(lambda (x)
365 (let* ((c (category-docstring x))
366 (doc (if (string-match "\\`\\(.*?\\)\n\\(.*\\)\\'" c)
367 (propertize (match-string 1 c)
368 'help-echo (match-string 2 c))
369 c)))
370 (format "%c:%s" x doc)))
371 mnemonics ", ")))))
372
373;;;###autoload
374(defun describe-char (pos)
375 "Describe the character after POS (interactively, the character after point).
376The information includes character code, charset and code points in it,
377syntax, category, how the character is encoded in a file,
378character composition information (if relevant),
379as well as widgets, buttons, overlays, and text properties."
380 (interactive "d")
381 (if (>= pos (point-max))
382 (error "No character follows specified position"))
383 (let* ((char (char-after pos))
384 (eight-bit-p (and (not enable-multibyte-characters) (>= char 128)))
385 (charset (if eight-bit-p 'eight-bit
386 (or (get-text-property pos 'charset) (char-charset char))))
387 (composition (find-composition pos nil nil t))
388 (component-chars nil)
389 (display-table (or (window-display-table)
390 buffer-display-table
391 standard-display-table))
392 (disp-vector (and display-table (aref display-table char)))
393 (multibyte-p enable-multibyte-characters)
394 (overlays (mapcar #'(lambda (o) (overlay-properties o))
395 (overlays-at pos)))
396 (char-description (if (not multibyte-p)
397 (single-key-description char)
398 (if (< char 128)
399 (single-key-description char)
400 (string-to-multibyte
401 (char-to-string char)))))
402 (text-props-desc
403 (let ((tmp-buf (generate-new-buffer " *text-props*")))
404 (unwind-protect
405 (progn
406 (describe-text-properties pos tmp-buf)
407 (with-current-buffer tmp-buf (buffer-string)))
408 (kill-buffer tmp-buf))))
409 item-list max-width code)
410
411 (if multibyte-p
412 (or (setq code (encode-char char charset))
413 (setq charset (char-charset char)
414 code (encode-char char charset)))
415 (setq code char))
416 (when composition
417 ;; When the composition is trivial (i.e. composed only with the
418 ;; current character itself without any alternate characters),
419 ;; we don't show the composition information. Otherwise, store
420 ;; two descriptive strings in the first two elments of
421 ;; COMPOSITION.
422 (or (catch 'tag
423 (let ((from (car composition))
424 (to (nth 1 composition))
425 (next (1+ pos))
426 (components (nth 2 composition))
427 ch)
428 (if (and (vectorp components) (vectorp (aref components 0)))
429 (let ((idx (- pos from))
430 (nglyphs (lgstring-glyph-len components))
431 (i 0) j glyph glyph-from)
432 ;; COMPONENTS is a gstring. Find a grapheme
433 ;; cluster containing the current character.
434 (while (and (< i nglyphs)
435 (setq glyph (lgstring-glyph components i))
436 (< (lglyph-to glyph) idx))
437 (setq i (1+ i)))
438 (if (or (not glyph) (= i nglyphs))
439 ;; The composition is broken.
440 (throw 'tag nil))
441 (setq glyph-from (lglyph-from glyph)
442 to (+ from (lglyph-to glyph) 1)
443 from (+ from glyph-from)
444 j i)
445 (while (and (< j nglyphs)
446 (setq glyph (lgstring-glyph components j))
447 (= (lglyph-from glyph) glyph-from))
448 (setq j (1+ j)))
449 (if (and (= i (1- j))
450 (setq glyph (lgstring-glyph components i))
451 (= char (lglyph-char glyph)))
452 ;; The composition is trivial.
453 (throw 'tag nil))
454 (nconc composition (list i (1- j))))
455 (dotimes (i (length components))
456 (if (integerp (setq ch (aref components i)))
457 (push (cons ch (describe-char-display pos ch))
458 component-chars)))
459 (setq component-chars (nreverse component-chars)))
460 (if (< from pos)
461 (if (< (1+ pos) to)
462 (setcar composition
463 (concat
464 " with the surrounding characters \""
465 (mapconcat 'describe-char-padded-string
466 (buffer-substring from pos) "")
467 "\" and \""
468 (mapconcat 'describe-char-padded-string
469 (buffer-substring (1+ pos) to) "")
470 "\""))
471 (setcar composition
472 (concat
473 " with the preceding character(s) \""
474 (mapconcat 'describe-char-padded-string
475 (buffer-substring from pos) "")
476 "\"")))
477 (if (< (1+ pos) to)
478 (setcar composition
479 (concat
480 " with the following character(s) \""
481 (mapconcat 'describe-char-padded-string
482 (buffer-substring (1+ pos) to) "")
483 "\""))
484 (setcar composition nil)))
485 (setcar (cdr composition)
486 (format "composed to form \"%s\" (see below)"
487 (buffer-substring from to)))))
488 (setq composition nil)))
489
490 (setq item-list
491 `(("character"
492 ,(format "%s (%d, #o%o, #x%x)"
493 (apply 'propertize char-description
494 (text-properties-at pos))
495 char char char))
496 ("preferred charset"
497 ,`(insert-text-button
498 ,(symbol-name charset)
499 'type 'help-character-set 'help-args '(,charset))
500 ,(format "(%s)" (charset-description charset)))
501 ("code point"
502 ,(let ((str (if (integerp code)
503 (format (if (< code 256) "0x%02X" "0x%04X") code)
504 (format "0x%04X%04X" (car code) (cdr code)))))
505 (if (<= (charset-dimension charset) 2)
506 `(insert-text-button
507 ,str
508 'action (lambda (&rest ignore)
509 (list-charset-chars ',charset)
510 (with-selected-window
511 (get-buffer-window "*Character List*" 0)
512 (goto-char (point-min))
513 (forward-line 2) ;Skip the header.
514 (let ((case-fold-search nil))
515 (if (search-forward ,(char-to-string char)
516 nil t)
517 (goto-char (match-beginning 0))))))
518 'follow-link t
519 'help-echo
520 "mouse-2, RET: show this character in its character set")
521 str)))
522 ("syntax"
523 ,(let ((syntax (syntax-after pos)))
524 (with-temp-buffer
525 (internal-describe-syntax-value syntax)
526 (buffer-string))))
527 ("category"
528 ,@(if (not eight-bit-p)
529 (let ((category-set (char-category-set char)))
530 (if category-set
531 (describe-char-categories category-set)
532 '("-- none --")))))
533 ("to input"
534 ,@(if (not eight-bit-p)
535 (let ((key-list (and (eq input-method-function
536 'quail-input-method)
537 (quail-find-key char))))
538 (if (consp key-list)
539 (list "type"
540 (mapconcat #'(lambda (x) (concat "\"" x "\""))
541 key-list " or ")
542 "with"
543 `(insert-text-button
544 ,current-input-method
545 'type 'help-input-method
546 'help-args '(,current-input-method)))))))
547 ("buffer code"
548 ,(if multibyte-p
549 (encoded-string-description
550 (string-as-unibyte (char-to-string char)) nil)
551 (format "#x%02X" char)))
552 ("file code"
553 ,@(if multibyte-p
554 (let* ((coding buffer-file-coding-system)
555 (encoded (encode-coding-char char coding charset)))
556 (if encoded
557 (list (encoded-string-description encoded coding)
558 (format "(encoded by coding system %S)" coding))
559 (list "not encodable by coding system"
560 (symbol-name coding))))
561 (list (format "#x%02X" char))))
562 ("display"
563 ,(cond
564 (disp-vector
565 (setq disp-vector (copy-sequence disp-vector))
566 (dotimes (i (length disp-vector))
567 (aset disp-vector i
568 (cons (aref disp-vector i)
569 (describe-char-display
570 pos (glyph-char (aref disp-vector i))))))
571 (format "by display table entry [%s] (see below)"
572 (mapconcat
573 #'(lambda (x)
574 (format "?%c" (glyph-char (car x))))
575 disp-vector " ")))
576 (composition
577 (cadr composition))
578 (t
579 (let ((display (describe-char-display pos char)))
580 (if (display-graphic-p (selected-frame))
581 (if display
582 (concat "by this font (glyph code)\n " display)
583 "no font available")
584 (if display
585 (format "terminal code %s" display)
586 "not encodable for terminal"))))))
587 ,@(let ((face
588 (if (not (or disp-vector composition))
589 (cond
590 ((and show-trailing-whitespace
591 (save-excursion (goto-char pos)
592 (looking-at-p "[ \t]+$")))
593 'trailing-whitespace)
594 ((and nobreak-char-display char (eq char '#xa0))
595 'nobreak-space)
596 ((and nobreak-char-display char (eq char '#xad))
597 'escape-glyph)
598 ((and (< char 32) (not (memq char '(9 10))))
599 'escape-glyph)))))
600 (if face (list (list "hardcoded face"
601 `(insert-text-button
602 ,(symbol-name face)
603 'type 'help-face 'help-args '(,face))))))
604 ,@(if (not eight-bit-p)
605 (let ((unicodedata (describe-char-unicode-data char)))
606 (if unicodedata
607 (cons (list "Unicode data" " ") unicodedata))))))
608 (setq max-width (apply #'max (mapcar #'(lambda (x)
609 (if (cadr x) (length (car x)) 0))
610 item-list)))
611 (help-setup-xref nil (called-interactively-p 'interactive))
612 (with-help-window (help-buffer)
613 (with-current-buffer standard-output
614 (set-buffer-multibyte multibyte-p)
615 (let ((formatter (format "%%%ds:" max-width)))
616 (dolist (elt item-list)
617 (when (cadr elt)
618 (insert (format formatter (car elt)))
619 (dolist (clm (cdr elt))
620 (if (eq (car-safe clm) 'insert-text-button)
621 (progn (insert " ") (eval clm))
622 (when (>= (+ (current-column)
623 (or (string-match-p "\n" clm)
624 (string-width clm))
625 1)
626 (window-width))
627 (insert "\n")
628 (indent-to (1+ max-width)))
629 (insert " " clm)))
630 (insert "\n"))))
631
632 (when overlays
633 (save-excursion
634 (goto-char (point-min))
635 (re-search-forward "character:[ \t\n]+")
636 (let ((end (+ (point) (length char-description))))
637 (mapc #'(lambda (props)
638 (let ((o (make-overlay (point) end)))
639 (while props
640 (overlay-put o (car props) (nth 1 props))
641 (setq props (cddr props)))))
642 overlays))))
643
644 (when disp-vector
645 (insert
646 "\nThe display table entry is displayed by ")
647 (if (display-graphic-p (selected-frame))
648 (progn
649 (insert "these fonts (glyph codes):\n")
650 (dotimes (i (length disp-vector))
651 (insert (glyph-char (car (aref disp-vector i))) ?:
652 (propertize " " 'display '(space :align-to 5))
653 (or (cdr (aref disp-vector i)) "-- no font --")
654 "\n")
655 (let ((face (glyph-face (car (aref disp-vector i)))))
656 (when face
657 (insert (propertize " " 'display '(space :align-to 5))
658 "face: ")
659 (insert (concat "`" (symbol-name face) "'"))
660 (insert "\n")))))
661 (insert "these terminal codes:\n")
662 (dotimes (i (length disp-vector))
663 (insert (car (aref disp-vector i))
664 (propertize " " 'display '(space :align-to 5))
665 (or (cdr (aref disp-vector i)) "-- not encodable --")
666 "\n"))))
667
668 (when composition
669 (insert "\nComposed")
670 (if (car composition)
671 (insert (car composition)))
672 (if (and (vectorp (nth 2 composition))
673 (vectorp (aref (nth 2 composition) 0)))
674 (let* ((gstring (nth 2 composition))
675 (font (lgstring-font gstring))
676 (from (nth 3 composition))
677 (to (nth 4 composition))
678 glyph)
679 (if (fontp font)
680 (progn
681 (insert " using this font:\n "
682 (symbol-name (font-get font :type))
683 ?:
684 (aref (query-font font) 0)
685 "\nby these glyphs:\n")
686 (while (and (<= from to)
687 (setq glyph (lgstring-glyph gstring from)))
688 (insert (format " %S\n" glyph))
689 (setq from (1+ from))))
690 (insert " by these characters:\n")
691 (while (and (<= from to)
692 (setq glyph (lgstring-glyph gstring from)))
693 (insert (format " %c (#x%d)\n"
694 (lglyph-char glyph) (lglyph-char glyph)))
695 (setq from (1+ from)))))
696 (insert " by the rule:\n\t(")
697 (let ((first t))
698 (mapc (lambda (x)
699 (if first (setq first nil)
700 (insert " "))
701 (if (consp x) (insert (format "%S" x))
702 (if (= x ?\t) (insert (single-key-description x))
703 (insert ??)
704 (insert (describe-char-padded-string x)))))
705 (nth 2 composition)))
706 (insert ")\nThe component character(s) are displayed by ")
707 (if (display-graphic-p (selected-frame))
708 (progn
709 (insert "these fonts (glyph codes):")
710 (dolist (elt component-chars)
711 (if (/= (car elt) ?\t)
712 (insert "\n "
713 (describe-char-padded-string (car elt))
714 ?:
715 (propertize " " 'display '(space :align-to 5))
716 (or (cdr elt) "-- no font --")))))
717 (insert "these terminal codes:")
718 (dolist (elt component-chars)
719 (insert "\n " (car elt) ":"
720 (propertize " " 'display '(space :align-to 4))
721 (or (cdr elt) "-- not encodable --"))))
722 (insert "\nSee the variable `reference-point-alist' for "
723 "the meaning of the rule.\n")))
724
725 (unless eight-bit-p
726 (insert (if (not describe-char-unidata-list)
727 "\nCharacter code properties are not shown: "
728 "\nCharacter code properties: "))
729 (insert-text-button
730 "customize what to show"
731 'action (lambda (&rest ignore)
732 (customize-variable
733 'describe-char-unidata-list))
734 'follow-link t)
735 (insert "\n")
736 (dolist (elt (if (eq describe-char-unidata-list t)
737 (nreverse (mapcar 'car char-code-property-alist))
738 describe-char-unidata-list))
739 (let ((val (get-char-code-property char elt))
740 description)
741 (when val
742 (setq description (char-code-property-description elt val))
743 (insert (if description
744 (format " %s: %s (%s)\n" elt val description)
745 (format " %s: %s\n" elt val)))))))
746
747 (if text-props-desc (insert text-props-desc))
748 (setq help-xref-stack-item (list 'help-insert-string (buffer-string)))
749 (toggle-read-only 1)))))
750
751(define-obsolete-function-alias 'describe-char-after 'describe-char "22.1")
752
753(provide 'descr-text)
754
755;; arch-tag: fc55a498-f3e9-4312-b5bd-98cc02480af1
756;;; descr-text.el ends here