aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenichi Handa2004-04-14 06:14:18 +0000
committerKenichi Handa2004-04-14 06:14:18 +0000
commit7fb0741b2ff17fcff7c4f80cf5b232e35eb2a15c (patch)
treeb97c01355079be1f3144342f6cad740b0a323ad7
parent186a08a87d7ff72c56f7039551217ba27d43040d (diff)
downloademacs-7fb0741b2ff17fcff7c4f80cf5b232e35eb2a15c.tar.gz
emacs-7fb0741b2ff17fcff7c4f80cf5b232e35eb2a15c.zip
(describe-property-list): Sync to HEAD.
-rw-r--r--lisp/descr-text.el168
1 files changed, 127 insertions, 41 deletions
diff --git a/lisp/descr-text.el b/lisp/descr-text.el
index 47e18751c95..8ed2a2824bf 100644
--- a/lisp/descr-text.el
+++ b/lisp/descr-text.el
@@ -1,6 +1,6 @@
1;;; descr-text.el --- describe text mode 1;;; descr-text.el --- describe text mode
2 2
3;; Copyright (c) 1994, 1995, 1996, 2001, 02, 03 Free Software Foundation, Inc. 3;; Copyright (c) 1994, 95, 96, 2001, 02, 03, 04 Free Software Foundation, Inc.
4 4
5;; Author: Boris Goldowsky <boris@gnu.org> 5;; Author: Boris Goldowsky <boris@gnu.org>
6;; Keywords: faces 6;; Keywords: faces
@@ -99,8 +99,9 @@ if that value is non-nil."
99(defun describe-property-list (properties) 99(defun describe-property-list (properties)
100 "Insert a description of PROPERTIES in the current buffer. 100 "Insert a description of PROPERTIES in the current buffer.
101PROPERTIES should be a list of overlay or text properties. 101PROPERTIES should be a list of overlay or text properties.
102The `category' property is made into a widget button that call 102The `category', `face' and `font-lock-face' properties are made
103`describe-text-category' when pushed." 103into widget buttons that call `describe-text-category' or
104`describe-face' when pushed."
104 ;; Sort the properties by the size of their value. 105 ;; Sort the properties by the size of their value.
105 (dolist (elt (sort (let ((ret nil) 106 (dolist (elt (sort (let ((ret nil)
106 (key nil) 107 (key nil)
@@ -110,7 +111,7 @@ The `category' property is made into a widget button that call
110 (setq key (pop properties) 111 (setq key (pop properties)
111 val (pop properties) 112 val (pop properties)
112 len 0) 113 len 0)
113 (unless (or (eq key 'category) 114 (unless (or (memq key '(category face font-lock-face))
114 (widgetp val)) 115 (widgetp val))
115 (setq val (pp-to-string val) 116 (setq val (pp-to-string val)
116 len (length val))) 117 len (length val)))
@@ -128,6 +129,11 @@ The `category' property is made into a widget button that call
128 :notify `(lambda (&rest ignore) 129 :notify `(lambda (&rest ignore)
129 (describe-text-category ',value)) 130 (describe-text-category ',value))
130 (format "%S" value))) 131 (format "%S" value)))
132 ((memq key '(face font-lock-face))
133 (widget-create 'link
134 :notify `(lambda (&rest ignore)
135 (describe-face ',value))
136 (format "%S" value)))
131 ((widgetp value) 137 ((widgetp value)
132 (describe-text-widget value)) 138 (describe-text-widget value))
133 (t 139 (t
@@ -338,7 +344,7 @@ otherwise."
338;;; (string-to-number (nth 2 fields)) 344;;; (string-to-number (nth 2 fields))
339;;; '((0 . "Spacing") 345;;; '((0 . "Spacing")
340;;; (1 . "Overlays and interior") 346;;; (1 . "Overlays and interior")
341;;; (7 . "Nuktas") 347;;; (7 . "Nuktas")
342;;; (8 . "Hiragana/Katakana voicing marks") 348;;; (8 . "Hiragana/Katakana voicing marks")
343;;; (9 . "Viramas") 349;;; (9 . "Viramas")
344;;; (10 . "Start of fixed position classes") 350;;; (10 . "Start of fixed position classes")
@@ -434,6 +440,19 @@ otherwise."
434;;; (string-to-number 440;;; (string-to-number
435;;; (nth 13 fields) 16)) 441;;; (nth 13 fields) 16))
436;;; ??))))))))))) 442;;; ??)))))))))))
443
444;; Return information about how CHAR is displayed at the buffer
445;; position POS. If the selected frame is on a graphic display,
446;; return a cons (FONTNAME . GLYPH-CODE). Otherwise, return a string
447;; describing the terminal codes for the character.
448(defun describe-char-display (pos char)
449 (if (display-graphic-p (selected-frame))
450 (internal-char-font pos char)
451 (let* ((coding (terminal-coding-system))
452 (encoded (encode-coding-char char coding)))
453 (if encoded
454 (encoded-string-description encoded coding)))))
455
437 456
438;;;###autoload 457;;;###autoload
439(defun describe-char (pos) 458(defun describe-char (pos)
@@ -449,8 +468,11 @@ as well as widgets, buttons, overlays, and text properties."
449 (charset (get-char-property pos 'charset)) 468 (charset (get-char-property pos 'charset))
450 (buffer (current-buffer)) 469 (buffer (current-buffer))
451 (composition (find-composition pos nil nil t)) 470 (composition (find-composition pos nil nil t))
452 (composed (if composition (buffer-substring (car composition) 471 (component-chars nil)
453 (nth 1 composition)))) 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)))
454 (multibyte-p enable-multibyte-characters) 476 (multibyte-p enable-multibyte-characters)
455 code item-list max-width) 477 code item-list max-width)
456 (or (and (charsetp charset) (encode-char char charset)) 478 (or (and (charsetp charset) (encode-char char charset))
@@ -504,15 +526,46 @@ as well as widgets, buttons, overlays, and text properties."
504 (format "(encoded by coding system %S)" coding)) 526 (format "(encoded by coding system %S)" coding))
505 (list "not encodable by coding system" 527 (list "not encodable by coding system"
506 (symbol-name coding))))) 528 (symbol-name coding)))))
507 ,(if (display-graphic-p (selected-frame)) 529 ("display"
508 (list "font" (or (internal-char-font pos) 530 ,(cond
509 "-- none --")) 531 (disp-vector
510 (list "terminal code" 532 (setq disp-vector (copy-sequence disp-vector))
511 (let* ((coding (terminal-coding-system)) 533 (dotimes (i (length disp-vector))
512 (encoded (encode-coding-char char coding))) 534 (setq char (aref disp-vector i))
513 (if encoded 535 (aset disp-vector i
514 (encoded-string-description encoded coding) 536 (cons char (describe-char-display pos char))))
515 "not encodable")))) 537 (format "by display table entry [%s] (see below)"
538 (mapconcat #'(lambda (x) (format "?%c" (car x)))
539 disp-vector " ")))
540 (composition
541 (let ((from (car composition))
542 (to (nth 1 composition))
543 (next (1+ pos))
544 (components (nth 2 composition))
545 ch)
546 (setcar composition
547 (and (< from pos) (buffer-substring from pos)))
548 (setcar (cdr composition)
549 (and (< next to) (buffer-substring next to)))
550 (dotimes (i (length components))
551 (if (integerp (setq ch (aref components i)))
552 (push (cons ch (describe-char-display pos ch))
553 component-chars)))
554 (setq component-chars (nreverse component-chars))
555 (format "composed to form \"%s\" (see below)"
556 (buffer-substring from to))))
557 (t
558 (let ((display (describe-char-display pos char)))
559 (if (display-graphic-p (selected-frame))
560 (if display
561 (concat
562 "by this font (glyph code)\n"
563 (format " %s (0x%02X)"
564 (car display) (cdr display)))
565 "no font available")
566 (if display
567 (format "terminal code %s" display)
568 "not encodable for terminal"))))))
516 ,@(let ((unicodedata (unicode-data char))) 569 ,@(let ((unicodedata (unicode-data char)))
517 (if unicodedata 570 (if unicodedata
518 (cons (list "Unicode data" " ") unicodedata)))))) 571 (cons (list "Unicode data" " ") unicodedata))))))
@@ -534,36 +587,68 @@ as well as widgets, buttons, overlays, and text properties."
534 (when (>= (+ (current-column) 587 (when (>= (+ (current-column)
535 (or (string-match "\n" clm) 588 (or (string-match "\n" clm)
536 (string-width clm)) 1) 589 (string-width clm)) 1)
537 (frame-width)) 590 (window-width))
538 (insert "\n") 591 (insert "\n")
539 (indent-to (1+ max-width))) 592 (indent-to (1+ max-width)))
540 (insert " " clm)) 593 (insert " " clm))
541 (insert "\n")))) 594 (insert "\n"))))
595
596 (when disp-vector
597 (insert
598 "\nThe display table entry is displayed by ")
599 (if (display-graphic-p (selected-frame))
600 (progn
601 (insert "these fonts (glyph codes):\n")
602 (dotimes (i (length disp-vector))
603 (insert (car (aref disp-vector i)) ?:
604 (propertize " " 'display '(space :align-to 5))
605 (if (cdr (aref disp-vector i))
606 (format "%s (0x%02X)" (cadr (aref disp-vector i))
607 (cddr (aref disp-vector i)))
608 "-- no font --")
609 "\n ")))
610 (insert "these terminal codes:\n")
611 (dotimes (i (length disp-vector))
612 (insert (car (aref disp-vector i))
613 (propertize " " 'display '(space :align-to 5))
614 (or (cdr (aref disp-vector i)) "-- not encodable --")
615 "\n"))))
616
542 (when composition 617 (when composition
543 (insert "\nComposed with the " 618 (insert "\nComposed")
544 (cond 619 (if (car composition)
545 ((eq pos (car composition)) "following ") 620 (if (cadr composition)
546 ((eq (1+ pos) (cadr composition)) "preceding ") 621 (insert " with the surrounding characters \""
547 (t "")) 622 (car composition) "\" and \""
548 "character(s) `" 623 (cadr composition) "\"")
549 (cond 624 (insert " with the preceding character(s) \""
550 ((eq pos (car composition)) (substring composed 1)) 625 (car composition) "\""))
551 ((eq (1+ pos) (cadr composition)) (substring composed 0 -1)) 626 (if (cadr composition)
552 (t (concat (substring composed 0 (- pos (car composition))) 627 (insert " with the following character(s) \""
553 "' and `" 628 (cadr composition) "\"")))
554 (substring composed (- (1+ pos) (car composition)))))) 629 (insert " by the rule:\n\t("
555 630 (mapconcat (lambda (x)
556 "' to form `" composed "'") 631 (format (if (consp x) "%S" "?%c") x))
557 (if (nth 3 composition) 632 (nth 2 composition)
558 (insert ".\n") 633 " ")
559 (insert "\nby the rule (" 634 ")")
560 (mapconcat (lambda (x) 635 (insert "\nThe component character(s) are displayed by ")
561 (format (if (consp x) "%S" "?%c") x)) 636 (if (display-graphic-p (selected-frame))
562 (nth 2 composition) 637 (progn
563 " ") 638 (insert "these fonts (glyph codes):")
564 ").\n" 639 (dolist (elt component-chars)
565 "See the variable `reference-point-alist' for " 640 (insert "\n " (car elt) ?:
566 "the meaning of the rule.\n"))) 641 (propertize " " 'display '(space :align-to 5))
642 (if (cdr elt)
643 (format "%s (0x%02X)" (cadr elt) (cddr elt))
644 "-- no font --"))))
645 (insert "these terminal codes:")
646 (dolist (elt component-chars)
647 (insert "\n " (car elt) ":"
648 (propertize " " 'display '(space :align-to 5))
649 (or (cdr elt) "-- not encodable --"))))
650 (insert "\nSee the variable `reference-point-alist' for "
651 "the meaning of the rule.\n"))
567 652
568 (let ((output (current-buffer))) 653 (let ((output (current-buffer)))
569 (with-current-buffer buffer 654 (with-current-buffer buffer
@@ -575,4 +660,5 @@ as well as widgets, buttons, overlays, and text properties."
575 660
576(provide 'descr-text) 661(provide 'descr-text)
577 662
663;;; arch-tag: fc55a498-f3e9-4312-b5bd-98cc02480af1
578;;; descr-text.el ends here 664;;; descr-text.el ends here