aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenichi Handa1999-02-25 13:25:07 +0000
committerKenichi Handa1999-02-25 13:25:07 +0000
commitc6fcc5180a0670790490685a00a9c69340f96c0a (patch)
treee3474ad0393e877ff95bcf86433e9af753194c8c
parent06789559b28c8f60d5db46b1306c4c152b7e5536 (diff)
downloademacs-c6fcc5180a0670790490685a00a9c69340f96c0a.tar.gz
emacs-c6fcc5180a0670790490685a00a9c69340f96c0a.zip
* simple.el (what-cursor-position): To show the character's
encoding, use encoded-string-description instead of information of chaset-origin-alist.
-rw-r--r--lisp/simple.el94
1 files changed, 34 insertions, 60 deletions
diff --git a/lisp/simple.el b/lisp/simple.el
index ce4effbe709..10ece473180 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -487,16 +487,18 @@ and the greater of them is not at the start of a line."
487(defun what-cursor-position (&optional detail) 487(defun what-cursor-position (&optional detail)
488 "Print info on cursor position (on screen and within buffer). 488 "Print info on cursor position (on screen and within buffer).
489Also describe the character after point, and give its character code 489Also describe the character after point, and give its character code
490in octal, decimal and hex. For a non-ASCII multibyte character, 490in octal, decimal and hex.
491also give its encoding in the buffer's selected coding system, 491
492if any. 492For a non-ASCII multibyte character, also give its encoding in the
493buffer's selected coding system if the coding system encodes the
494character safely. If the character is encoded into one byte, that
495code is shown in hex. If the character is encoded into more than one
496byte, just \"...\" is shown.
493 497
494With prefix argument, print additional details about that character, 498With prefix argument, print additional details about that character,
495instead of the cursor position. This includes the character set name, 499instead of the cursor position. This includes the character set name,
496the codes that identify the character within that character set, 500the codes that identify the character within that character set. In
497and the corresponding external character components. 501addition, the encoding is fully shown."
498
499Each language environment may show different external character components."
500 (interactive "P") 502 (interactive "P")
501 (let* ((char (following-char)) 503 (let* ((char (following-char))
502 (beg (point-min)) 504 (beg (point-min))
@@ -517,66 +519,38 @@ Each language environment may show different external character components."
517 pos total percent beg end col hscroll) 519 pos total percent beg end col hscroll)
518 (message "point=%d of %d(%d%%) column %d %s" 520 (message "point=%d of %d(%d%%) column %d %s"
519 pos total percent col hscroll)) 521 pos total percent col hscroll))
520 (let ((charset (char-charset char)) 522 (let ((coding buffer-file-coding-system)
521 (coding-system buffer-file-coding-system) 523 encoded encoding-msg)
522 slot external encoding-msg) 524 (if (or (not coding)
523 ;; To decided an external character code, we use 525 (eq (coding-system-type coding) t))
524 ;; charset-origin-alist property of buffer-file-coding-system. 526 (setq coding default-buffer-file-coding-system))
525 ;; But, if buffer-file-coding-system is nil of undecided, use 527 (setq encoded (and (>= char 128) (encode-coding-char char coding)))
526 ;; that property of default-buffer-file-coding-system. If
527 ;; that property value is nil, we don't show external
528 ;; character code.
529 (if (or (not coding-system)
530 (eq (coding-system-type coding-system) t))
531 (setq coding-system default-buffer-file-coding-system))
532 (if (and coding-system
533 (setq slot
534 (coding-system-get coding-system 'charset-origin-alist))
535 (setq slot (assq charset slot)))
536 (let ((encoder (nth 2 slot)))
537 (setq external
538 (list (nth 1 slot)
539 (cond ((functionp encoder)
540 (funcall encoder char))
541 ((char-table-p encoder)
542 (aref encoder char))
543 ((and (symbolp encoder)
544 (char-table-p
545 (get encoder 'translation-table)))
546 (aref (get encoder 'translation-table) char))
547 (t
548 (error "Invalid property in %s"
549 coding-system)))))))
550 (setq encoding-msg 528 (setq encoding-msg
551 (if external 529 (if encoded
552 (format "(0%o, %d, 0x%x, ext 0x%x)" 530 (format "(0%o, %d, 0x%x, ext %s)"
553 char char char (nth 1 external)) 531 char char char
532 (if (and (not detail)
533 (> (length encoded) 1))
534 "..."
535 (concat
536 (encoded-string-description encoded coding)
537 (if (cmpcharp char) "..." ""))))
554 (format "(0%o, %d, 0x%x)" char char char))) 538 (format "(0%o, %d, 0x%x)" char char char)))
555 (if detail 539 (if detail
556 ;; We show the detailed information of CHAR. 540 ;; We show the detailed information of CHAR.
557 (let (internal) 541 (let ((internal
558 (if (eq charset 'composition) 542 (if (cmpcharp char)
559 ;; For a composite character, we show the components 543 ;; For a composite character, we show the
560 ;; only. 544 ;; components only.
561 (setq internal (concat "(composition of \"" 545 (concat "(composed \""
562 (decompose-composite-char char) 546 (decompose-composite-char char)
563 "\")") 547 "\")")
564 external nil) 548 (split-char char))))
565 (setq internal (split-char char)) 549 (message "Char: %s %s %s"
566 (unless external
567 (setq external (cons (charset-short-name charset)
568 (copy-sequence (cdr internal))))
569 (if (= (charset-iso-graphic-plane charset) 1)
570 (progn
571 (setcar (cdr external) (+ (nth 1 external) 128))
572 (if (nth 2 external)
573 (setcar (nthcdr 2 external)
574 (+ (nth 2 external) 128)))))))
575 (message "Char: %s %s %s %s"
576 (if (< char 256) 550 (if (< char 256)
577 (single-key-description char) 551 (single-key-description char)
578 (char-to-string char)) 552 (char-to-string char))
579 encoding-msg internal (or external ""))) 553 encoding-msg internal))
580 (if (or (/= beg 1) (/= end (1+ total))) 554 (if (or (/= beg 1) (/= end (1+ total)))
581 (message "Char: %s %s point=%d of %d(%d%%) <%d - %d> column %d %s" 555 (message "Char: %s %s point=%d of %d(%d%%) <%d - %d> column %d %s"
582 (if (< char 256) 556 (if (< char 256)