diff options
| author | Kenichi Handa | 2004-05-10 12:07:12 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2004-05-10 12:07:12 +0000 |
| commit | ed441285d52c3d29b81223c017bbc45ef05a9e45 (patch) | |
| tree | e35d11aff637f6916af1f2218a6d720c46bf2a10 | |
| parent | 9a28b92124888df59a88e299662856dc232aebb8 (diff) | |
| download | emacs-ed441285d52c3d29b81223c017bbc45ef05a9e45.tar.gz emacs-ed441285d52c3d29b81223c017bbc45ef05a9e45.zip | |
(describe-char): Fix previous change. Don't make
a unibyte character to multibyte in the *Help* buffer.
| -rw-r--r-- | lisp/descr-text.el | 226 |
1 files changed, 113 insertions, 113 deletions
diff --git a/lisp/descr-text.el b/lisp/descr-text.el index 4b6605aa426..6b4f18ff718 100644 --- a/lisp/descr-text.el +++ b/lisp/descr-text.el | |||
| @@ -465,7 +465,6 @@ as well as widgets, buttons, overlays, and text properties." | |||
| 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))) | ||
| 469 | (charset (char-charset char)) | 468 | (charset (char-charset char)) |
| 470 | (buffer (current-buffer)) | 469 | (buffer (current-buffer)) |
| 471 | (composition (find-composition pos nil nil t)) | 470 | (composition (find-composition pos nil nil t)) |
| @@ -478,125 +477,114 @@ as well as widgets, buttons, overlays, and text properties." | |||
| 478 | (overlays (mapcar #'(lambda (o) (overlay-properties o)) | 477 | (overlays (mapcar #'(lambda (o) (overlay-properties o)) |
| 479 | (overlays-at pos))) | 478 | (overlays-at pos))) |
| 480 | item-list max-width unicode) | 479 | item-list max-width unicode) |
| 481 | (if (eq charset 'unknown) | 480 | |
| 482 | (setq item-list '("character")) | 481 | (if (or (< char 256) |
| 483 | 482 | (memq 'mule-utf-8 (find-coding-systems-region pos (1+ pos))) | |
| 484 | (if (or (< char 256) | 483 | (get-char-property pos 'untranslated-utf-8)) |
| 485 | (memq 'mule-utf-8 (find-coding-systems-region pos (1+ pos))) | 484 | (setq unicode (or (get-char-property pos 'untranslated-utf-8) |
| 486 | (get-char-property pos 'untranslated-utf-8)) | 485 | (encode-char char 'ucs)))) |
| 487 | (setq unicode (or (get-char-property pos 'untranslated-utf-8) | 486 | (setq item-list |
| 488 | (encode-char char 'ucs)))) | 487 | `(("character" |
| 489 | (setq item-list | 488 | ,(format "%s (0%o, %d, 0x%x%s)" |
| 490 | `(("character") | 489 | (apply 'propertize (if (not multibyte-p) |
| 491 | ("charset" | 490 | (single-key-description char) |
| 492 | ,(symbol-name charset) | 491 | (if (< char 128) |
| 493 | ,(format "(%s)" (charset-description charset))) | 492 | (single-key-description char) |
| 494 | ("code point" | 493 | (string-to-multibyte |
| 495 | ,(let ((split (split-char char))) | 494 | (char-to-string char)))) |
| 496 | (if (= (charset-dimension charset) 1) | 495 | (text-properties-at pos)) |
| 497 | (format "%d" (nth 1 split)) | 496 | char char char |
| 498 | (format "%d %d" (nth 1 split) (nth 2 split))))) | 497 | (if unicode |
| 499 | ("syntax" | 498 | (format ", U+%04X" unicode) |
| 500 | ,(let ((syntax (syntax-after pos))) | 499 | ""))) |
| 501 | (with-temp-buffer | 500 | ("charset" |
| 502 | (internal-describe-syntax-value syntax) | 501 | ,(symbol-name charset) |
| 503 | (buffer-string)))) | 502 | ,(format "(%s)" (charset-description charset))) |
| 504 | ("category" | 503 | ("code point" |
| 505 | ,@(let ((category-set (char-category-set char))) | 504 | ,(let ((split (split-char char))) |
| 506 | (if (not category-set) | 505 | (if (= (charset-dimension charset) 1) |
| 507 | '("-- none --") | 506 | (format "%d" (nth 1 split)) |
| 508 | (mapcar #'(lambda (x) (format "%c:%s " | 507 | (format "%d %d" (nth 1 split) (nth 2 split))))) |
| 509 | x (category-docstring x))) | 508 | ("syntax" |
| 510 | (category-set-mnemonics category-set))))) | 509 | ,(let ((syntax (syntax-after pos))) |
| 511 | ,@(let ((props (aref char-code-property-table char)) | 510 | (with-temp-buffer |
| 512 | ps) | 511 | (internal-describe-syntax-value syntax) |
| 513 | (when props | 512 | (buffer-string)))) |
| 514 | (while props | 513 | ("category" |
| 515 | (push (format "%s:" (pop props)) ps) | 514 | ,@(let ((category-set (char-category-set char))) |
| 516 | (push (format "%s;" (pop props)) ps)) | 515 | (if (not category-set) |
| 517 | (list (cons "Properties" (nreverse ps))))) | 516 | '("-- none --") |
| 518 | ("buffer code" | 517 | (mapcar #'(lambda (x) (format "%c:%s " |
| 519 | ,(encoded-string-description | 518 | x (category-docstring x))) |
| 520 | (string-as-unibyte (char-to-string char)) nil)) | 519 | (category-set-mnemonics category-set))))) |
| 521 | ("file code" | 520 | ,@(let ((props (aref char-code-property-table char)) |
| 522 | ,@(let* ((coding buffer-file-coding-system) | 521 | ps) |
| 523 | (encoded (encode-coding-char char coding))) | 522 | (when props |
| 524 | (if encoded | 523 | (while props |
| 525 | (list (encoded-string-description encoded coding) | 524 | (push (format "%s:" (pop props)) ps) |
| 526 | (format "(encoded by coding system %S)" coding)) | 525 | (push (format "%s;" (pop props)) ps)) |
| 527 | (list "not encodable by coding system" | 526 | (list (cons "Properties" (nreverse ps))))) |
| 528 | (symbol-name coding))))) | 527 | ("buffer code" |
| 529 | ("display" | 528 | ,(encoded-string-description |
| 530 | ,(cond | 529 | (string-as-unibyte (char-to-string char)) nil)) |
| 531 | (disp-vector | 530 | ("file code" |
| 532 | (setq disp-vector (copy-sequence disp-vector)) | 531 | ,@(let* ((coding buffer-file-coding-system) |
| 533 | (dotimes (i (length disp-vector)) | 532 | (encoded (encode-coding-char char coding))) |
| 534 | (setq char (aref disp-vector i)) | 533 | (if encoded |
| 535 | (aset disp-vector i | 534 | (list (encoded-string-description encoded coding) |
| 536 | (cons char (describe-char-display pos char)))) | 535 | (format "(encoded by coding system %S)" coding)) |
| 537 | (format "by display table entry [%s] (see below)" | 536 | (list "not encodable by coding system" |
| 538 | (mapconcat #'(lambda (x) (format "?%c" (car x))) | 537 | (symbol-name coding))))) |
| 539 | disp-vector " "))) | 538 | ("display" |
| 540 | (composition | 539 | ,(cond |
| 541 | (let ((from (car composition)) | 540 | (disp-vector |
| 542 | (to (nth 1 composition)) | 541 | (setq disp-vector (copy-sequence disp-vector)) |
| 543 | (next (1+ pos)) | 542 | (dotimes (i (length disp-vector)) |
| 544 | (components (nth 2 composition)) | 543 | (setq char (aref disp-vector i)) |
| 545 | ch) | 544 | (aset disp-vector i |
| 546 | (setcar composition | 545 | (cons char (describe-char-display pos char)))) |
| 547 | (and (< from pos) (buffer-substring from pos))) | 546 | (format "by display table entry [%s] (see below)" |
| 548 | (setcar (cdr composition) | 547 | (mapconcat #'(lambda (x) (format "?%c" (car x))) |
| 549 | (and (< next to) (buffer-substring next to))) | 548 | disp-vector " "))) |
| 550 | (dotimes (i (length components)) | 549 | (composition |
| 551 | (if (integerp (setq ch (aref components i))) | 550 | (let ((from (car composition)) |
| 552 | (push (cons ch (describe-char-display pos ch)) | 551 | (to (nth 1 composition)) |
| 553 | component-chars))) | 552 | (next (1+ pos)) |
| 554 | (setq component-chars (nreverse component-chars)) | 553 | (components (nth 2 composition)) |
| 555 | (format "composed to form \"%s\" (see below)" | 554 | ch) |
| 556 | (buffer-substring from to)))) | 555 | (setcar composition |
| 557 | (t | 556 | (and (< from pos) (buffer-substring from pos))) |
| 558 | (let ((display (describe-char-display pos char))) | 557 | (setcar (cdr composition) |
| 559 | (if (display-graphic-p (selected-frame)) | 558 | (and (< next to) (buffer-substring next to))) |
| 560 | (if display | 559 | (dotimes (i (length components)) |
| 561 | (concat | 560 | (if (integerp (setq ch (aref components i))) |
| 562 | "by this font (glyph code)\n" | 561 | (push (cons ch (describe-char-display pos ch)) |
| 563 | (format " %s (0x%02X)" | 562 | component-chars))) |
| 564 | (car display) (cdr display))) | 563 | (setq component-chars (nreverse component-chars)) |
| 565 | "no font available") | 564 | (format "composed to form \"%s\" (see below)" |
| 565 | (buffer-substring from to)))) | ||
| 566 | (t | ||
| 567 | (let ((display (describe-char-display pos char))) | ||
| 568 | (if (display-graphic-p (selected-frame)) | ||
| 566 | (if display | 569 | (if display |
| 567 | (format "terminal code %s" display) | 570 | (concat |
| 568 | "not encodable for terminal")))))) | 571 | "by this font (glyph code)\n" |
| 569 | ,@(let ((unicodedata (and unicode | 572 | (format " %s (0x%02X)" |
| 570 | (describe-char-unicode-data unicode)))) | 573 | (car display) (cdr display))) |
| 571 | (if unicodedata | 574 | "no font available") |
| 572 | (cons (list "Unicode data" " ") unicodedata)))))) | 575 | (if display |
| 576 | (format "terminal code %s" display) | ||
| 577 | "not encodable for terminal")))))) | ||
| 578 | ,@(let ((unicodedata (and unicode | ||
| 579 | (describe-char-unicode-data unicode)))) | ||
| 580 | (if unicodedata | ||
| 581 | (cons (list "Unicode data" " ") unicodedata))))) | ||
| 573 | (setq max-width (apply #'max (mapcar #'(lambda (x) (length (car x))) | 582 | (setq max-width (apply #'max (mapcar #'(lambda (x) (length (car x))) |
| 574 | item-list))) | 583 | item-list))) |
| 575 | (pop item-list) | ||
| 576 | |||
| 577 | (with-output-to-temp-buffer "*Help*" | 584 | (with-output-to-temp-buffer "*Help*" |
| 578 | (with-current-buffer standard-output | 585 | (with-current-buffer standard-output |
| 579 | (set-buffer-multibyte multibyte-p) | 586 | (set-buffer-multibyte multibyte-p) |
| 580 | (let ((formatter (format "%%%ds:" max-width))) | 587 | (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) | ||
| 600 | (dolist (elt item-list) | 588 | (dolist (elt item-list) |
| 601 | (when (cadr elt) | 589 | (when (cadr elt) |
| 602 | (insert (format formatter (car elt))) | 590 | (insert (format formatter (car elt))) |
| @@ -610,6 +598,18 @@ as well as widgets, buttons, overlays, and text properties." | |||
| 610 | (insert " " clm)) | 598 | (insert " " clm)) |
| 611 | (insert "\n")))) | 599 | (insert "\n")))) |
| 612 | 600 | ||
| 601 | (save-excursion | ||
| 602 | (goto-char (point-min)) | ||
| 603 | (search-forward "character: ") | ||
| 604 | (setq pos (point))) | ||
| 605 | (if overlays | ||
| 606 | (mapc #'(lambda (props) | ||
| 607 | (let ((o (make-overlay pos (1+ pos)))) | ||
| 608 | (while props | ||
| 609 | (overlay-put o (car props) (nth 1 props)) | ||
| 610 | (setq props (cddr props))))) | ||
| 611 | overlays)) | ||
| 612 | |||
| 613 | (when disp-vector | 613 | (when disp-vector |
| 614 | (insert | 614 | (insert |
| 615 | "\nThe display table entry is displayed by ") | 615 | "\nThe display table entry is displayed by ") |