changeset 88525:3629e02a95c1

(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.
author Kenichi Handa <handa@m17n.org>
date Thu, 16 May 2002 01:17:14 +0000
parents 87327fa1517b
children 6bac4ae1c326
files lisp/international/encoded-kb.el
diffstat 1 files changed, 39 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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"