comparison lisp/descr-text.el @ 55305:b1c52f4076c4

(describe-char): Copy the character with text properties and overlays into the first line, and call describe-text-properties on it.
author Kenichi Handa <handa@m17n.org>
date Sun, 02 May 2004 01:49:08 +0000
parents eec7e5483b20
children 79abf8a72f5a
comparison
equal deleted inserted replaced
55304:a052e022db03 55305:b1c52f4076c4
463 as well as widgets, buttons, overlays, and text properties." 463 as well as widgets, buttons, overlays, and text properties."
464 (interactive "d") 464 (interactive "d")
465 (if (>= pos (point-max)) 465 (if (>= pos (point-max))
466 (error "No character follows specified position")) 466 (error "No character follows specified position"))
467 (let* ((char (char-after pos)) 467 (let* ((char (char-after pos))
468 (char-string (buffer-substring pos (1+ pos)))
468 (charset (char-charset char)) 469 (charset (char-charset char))
469 (buffer (current-buffer)) 470 (buffer (current-buffer))
470 (composition (find-composition pos nil nil t)) 471 (composition (find-composition pos nil nil t))
471 (component-chars nil) 472 (component-chars nil)
472 (display-table (or (window-display-table) 473 (display-table (or (window-display-table)
473 buffer-display-table 474 buffer-display-table
474 standard-display-table)) 475 standard-display-table))
475 (disp-vector (and display-table (aref display-table char))) 476 (disp-vector (and display-table (aref display-table char)))
476 (multibyte-p enable-multibyte-characters) 477 (multibyte-p enable-multibyte-characters)
477 text-prop-description 478 (overlays (mapcar #'(lambda (o) (overlay-properties o))
479 (overlays-at pos)))
478 item-list max-width unicode) 480 item-list max-width unicode)
479 (if (eq charset 'unknown) 481 (if (eq charset 'unknown)
480 (setq item-list 482 (setq item-list '("character"))
481 `(("character"
482 ,(format "%s (0%o, %d, 0x%x) -- invalid character code"
483 (if (< char 256)
484 (single-key-description char)
485 (char-to-string char))
486 char char char))))
487 483
488 (if (or (< char 256) 484 (if (or (< char 256)
489 (memq 'mule-utf-8 (find-coding-systems-region pos (1+ pos))) 485 (memq 'mule-utf-8 (find-coding-systems-region pos (1+ pos)))
490 (get-char-property pos 'untranslated-utf-8)) 486 (get-char-property pos 'untranslated-utf-8))
491 (setq unicode (or (get-char-property pos 'untranslated-utf-8) 487 (setq unicode (or (get-char-property pos 'untranslated-utf-8)
492 (encode-char char 'ucs)))) 488 (encode-char char 'ucs))))
493 (setq item-list 489 (setq item-list
494 `(("character" 490 `(("character")
495 ,(format "%s (0%o, %d, 0x%x%s)" (if (< char 256)
496 (single-key-description char)
497 (char-to-string char))
498 char char char
499 (if unicode
500 (format ", U+%04X" unicode)
501 "")))
502 ("charset" 491 ("charset"
503 ,(symbol-name charset) 492 ,(symbol-name charset)
504 ,(format "(%s)" (charset-description charset))) 493 ,(format "(%s)" (charset-description charset)))
505 ("code point" 494 ("code point"
506 ,(let ((split (split-char char))) 495 ,(let ((split (split-char char)))
581 (describe-char-unicode-data unicode)))) 570 (describe-char-unicode-data unicode))))
582 (if unicodedata 571 (if unicodedata
583 (cons (list "Unicode data" " ") unicodedata)))))) 572 (cons (list "Unicode data" " ") unicodedata))))))
584 (setq max-width (apply #'max (mapcar #'(lambda (x) (length (car x))) 573 (setq max-width (apply #'max (mapcar #'(lambda (x) (length (car x)))
585 item-list))) 574 item-list)))
586 (setq text-prop-description 575 (pop item-list)
587 (with-temp-buffer
588 (let ((buf (current-buffer)))
589 (save-excursion
590 (set-buffer buffer)
591 (describe-text-properties pos buf)))
592 (buffer-string)))
593 576
594 (with-output-to-temp-buffer "*Help*" 577 (with-output-to-temp-buffer "*Help*"
595 (with-current-buffer standard-output 578 (with-current-buffer standard-output
596 (set-buffer-multibyte multibyte-p) 579 (set-buffer-multibyte multibyte-p)
597 (let ((formatter (format "%%%ds:" max-width))) 580 (let ((formatter (format "%%%ds:" max-width)))
581 (insert (format formatter "character") " ")
582 (setq pos (point))
583 (insert char-string
584 (format " (`%s', 0%o, %d, 0x%x"
585 (if (< char 256)
586 (single-key-description char)
587 (char-to-string char))
588 char char char)
589 (if (eq charset 'unknown)
590 ") -- invalid character code\n"
591 (if unicode
592 (format ", U+%04X)\n" unicode)
593 ")\n")))
594 (mapc #'(lambda (props)
595 (let ((o (make-overlay pos (1+ pos))))
596 (while props
597 (overlay-put o (car props) (nth 1 props))
598 (setq props (cddr props)))))
599 overlays)
598 (dolist (elt item-list) 600 (dolist (elt item-list)
599 (when (cadr elt) 601 (when (cadr elt)
600 (insert (format formatter (car elt))) 602 (insert (format formatter (car elt)))
601 (dolist (clm (cdr elt)) 603 (dolist (clm (cdr elt))
602 (when (>= (+ (current-column) 604 (when (>= (+ (current-column)
663 (propertize " " 'display '(space :align-to 5)) 665 (propertize " " 'display '(space :align-to 5))
664 (or (cdr elt) "-- not encodable --")))) 666 (or (cdr elt) "-- not encodable --"))))
665 (insert "\nSee the variable `reference-point-alist' for " 667 (insert "\nSee the variable `reference-point-alist' for "
666 "the meaning of the rule.\n")) 668 "the meaning of the rule.\n"))
667 669
668 (insert text-prop-description) 670 (describe-text-properties pos (current-buffer))
669 (describe-text-mode))))) 671 (describe-text-mode)))))
670 672
671 (defalias 'describe-char-after 'describe-char) 673 (defalias 'describe-char-after 'describe-char)
672 (make-obsolete 'describe-char-after 'describe-char "21.5") 674 (make-obsolete 'describe-char-after 'describe-char "21.5")
673 675