# HG changeset patch # User Kenichi Handa # Date 1021511834 0 # Node ID 3629e02a95c1c34c6b9b61b7f82ca2dff58a95fe # Parent 87327fa1517bd8ecc4e5cdbfaa4cef1505f366d0 (encoded-kbd-handle-8bit): Call encoded-kbd-self-insert-iso2022-8bit with argument 1. (encoded-kbd-self-insert-charset): New function. (encoded-kbd-setup-keymap): Handle a coding-system of type charset. (encoded-kbd-mode): Likewise. diff -r 87327fa1517b -r 3629e02a95c1 lisp/international/encoded-kb.el --- a/lisp/international/encoded-kb.el Wed May 15 23:34:17 2002 +0000 +++ b/lisp/international/encoded-kb.el Thu May 16 01:17:14 2002 +0000 @@ -166,7 +166,7 @@ (aset encoded-kbd-iso2022-invocations 2 3)) ((>= last-command-char ?\240) - (encoded-kbd-self-insert-iso2022-8bit)) + (encoded-kbd-self-insert-iso2022-8bit 1)) (t (error "Can't handle the character code %d" @@ -237,11 +237,38 @@ (setq unread-command-events (append result unread-command-events)))) +(defun encoded-kbd-self-insert-charset (arg) + (interactive "p") + (let* ((charset-list + (coding-system-get (keyboard-coding-system) :charset-list)) + (charset (car charset-list)) + ;; For the moment, we can assume that the length of CHARSET-LIST + ;; is 1, and the dimension of CHARSET is 1. + (c (decode-char charset last-command-char))) + (unless c + (error "Can't decode the code point %d by %s" + last-command-char charset)) + ;; As simply setting unread-command-events may result in + ;; infinite-loop for characters 160..255, this is a temporary + ;; workaround until we found a better solution. + (let ((last-command-char c)) + (self-insert-command arg)))) + (defun encoded-kbd-setup-keymap (coding) ;; At first, reset the keymap. (setcdr encoded-kbd-mode-map nil) ;; Then setup the keymap according to the keyboard coding system. (cond + ((eq encoded-kbd-coding 'charset) + (let* ((charset (car (coding-system-get coding :charset-list))) + (code-space (get-charset-property charset :code-space)) + (from (max (aref code-space 0) 128)) + (to (aref code-space 1))) + (while (<= from to) + (define-key encoded-kbd-mode-map + (vector from) 'encoded-kbd-self-insert-charset) + (setq from (1+ from))))) + ((eq encoded-kbd-coding 'sjis) (let ((i 128)) (while (< i 256) @@ -346,6 +373,17 @@ 'use-8th-bit (nth 3 saved-input-mode)) (setq encoded-kbd-coding 'ccl)) + ((and (eq (coding-system-type coding) 'charset) + (let* ((charset-list (coding-system-get coding + :charset-list)) + (charset (car charset-list))) + (and (= (length charset-list) 1) + (= (charset-dimension charset) 1)))) + (set-input-mode + (nth 0 saved-input-mode) (nth 1 saved-input-mode) + 'use-8th-bit (nth 3 saved-input-mode)) + (setq encoded-kbd-coding 'charset)) + (t (setq encoded-kbd-mode nil) (error "Coding-system `%s' is not supported in Encoded-kbd mode"