comparison lisp/mule/mule-cmds.el @ 4468:a78d697ccd2c

Import and extend GNU's descr-text.el, supporting prefix argument for C-x = 2008-05-25 Aidan Kehoe <kehoea@parhasard.net> * descr-text.el: New. Taken from GNU's GPLV2 version of 2007-02-14, with modifications for XEmacs support and extensions for Unihan.txt support and db/dbm caches. * simple.el (what-cursor-position): Support an optional prefix argument, as does GNU, calling #'describe-char to giving more detail on the character at point, notably from UnicodeData and (in our case, optionally) Unihan.txt. * syntax.el (syntax-after): Make this available for the sake of #'describe-char. * mule/mule-cmds.el (iso-2022-control-alist): Make this available, for the sake of #'encoded-string-description and #'describe-char. * mule/mule-cmds.el (encoded-string-description): Make this available, for the sake of #'describe-char. * unicode.el (unicode-error-default-translation-table): Make this a char table of type generic, not of type char. Makes it possible to have the relevant logic in #'describe-char reasonably clear; also, and this is undocumented, makes it much easier to implement #'frob-unicode-errors-region. I should document this, and revise #'frob-unicode-errors-region.
author Aidan Kehoe <kehoea@parhasard.net>
date Sun, 25 May 2008 21:11:35 +0200
parents 0194a744d2d3
children b75b075a9041
comparison
equal deleted inserted replaced
4467:23ef20edf6ba 4468:a78d697ccd2c
899 899
900 900
901 ;; Pretty description of encoded string 901 ;; Pretty description of encoded string
902 902
903 ;; Alist of ISO 2022 control code vs the corresponding mnemonic string. 903 ;; Alist of ISO 2022 control code vs the corresponding mnemonic string.
904 ;; (defvar iso-2022-control-alist 904 (defvar iso-2022-control-alist
905 ;; '((?\x1b . "ESC") 905 '((?\x1b . "ESC")
906 ;; (?\x0e . "SO") 906 (?\x0e . "SO")
907 ;; (?\x0f . "SI") 907 (?\x0f . "SI")
908 ;; (?\x8e . "SS2") 908 (?\x8e . "SS2")
909 ;; (?\x8f . "SS3") 909 (?\x8f . "SS3")
910 ;; (?\x9b . "CSI"))) 910 (?\x9b . "CSI")))
911 911
912 ;; (defun encoded-string-description (str coding-system) 912 (defun encoded-string-description (str coding-system)
913 ;; "Return a pretty description of STR that is encoded by CODING-SYSTEM." 913 "Return a pretty description of STR that is encoded by CODING-SYSTEM."
914 ;; (setq str (string-as-unibyte str)) 914 ; (setq str (string-as-unibyte str))
915 ;; (let ((char (aref str 0)) 915 (mapconcat
916 ;; desc) 916 (if (and coding-system (eq (coding-system-type coding-system) 'iso2022))
917 ;; (when (< char 128) 917 ;; Try to get a pretty description for ISO 2022 escape sequences.
918 ;; (setq desc (or (cdr (assq char iso-2022-control-alist)) 918 (function (lambda (x) (or (cdr (assq x iso-2022-control-alist))
919 ;; (char-to-string char))) 919 (format "#x%02X" x))))
920 ;; (let ((i 1) 920 (function (lambda (x) (format "#x%02X" x))))
921 ;; (len (length str))) 921 str " "))
922 ;; (while (< i len)
923 ;; (setq char (aref str i))
924 ;; (if (>= char 128)
925 ;; (setq desc nil i len)
926 ;; (setq desc (concat desc " "
927 ;; (or (cdr (assq char iso-2022-control-alist))
928 ;; (char-to-string char)))
929 ;; i (1+ i))))))
930 ;; (or desc
931 ;; (mapconcat (function (lambda (x) (format "0x%02x" x))) str " "))))
932 922
933 ;; (defun encode-coding-char (char coding-system) 923 ;; (defun encode-coding-char (char coding-system)
934 ;; "Encode CHAR by CODING-SYSTEM and return the resulting string. 924 ;; "Encode CHAR by CODING-SYSTEM and return the resulting string.
935 ;; If CODING-SYSTEM can't safely encode CHAR, return nil." 925 ;; If CODING-SYSTEM can't safely encode CHAR, return nil."
936 ;; (if (cmpcharp char) 926 ;; (if (cmpcharp char)