# HG changeset patch # User Kenichi Handa # Date 1074132934 0 # Node ID f786eb22f54c402eb6d8eabbcea51306de250d09 # Parent 3756c51dab99021c9a837fedd809887d769932cf (encoded-kbd-self-insert-utf-8): New function. (encoded-kbd-setup-keymap): Add code for handling utf-8. (encoded-kbd-mode): Likewise. diff -r 3756c51dab99 -r f786eb22f54c lisp/international/encoded-kb.el --- a/lisp/international/encoded-kb.el Tue Jan 13 01:44:46 2004 +0000 +++ b/lisp/international/encoded-kb.el Thu Jan 15 02:15:34 2004 +0000 @@ -87,8 +87,8 @@ map) "Keymap for handling non-ASCII character set in Encoded-kbd mode.") -;; One of the symbols `sjis', `iso2022-7', `iso2022-8', or `big5' to -;; denote what kind of coding-system we are now handling in +;; One of the symbols `sjis', `iso2022-7', `iso2022-8', `big5', or +;; `utf-8' to denote what kind of coding-system we are now handling in ;; Encoded-kbd mode. (defvar encoded-kbd-coding nil) @@ -257,6 +257,23 @@ (let ((last-command-char c)) (self-insert-command arg)))) +(defun encoded-kbd-self-insert-utf-8 (arg) + (interactive "p") + (let (len ch) + (cond ((< last-command-char #xE0) + (setq len 1 ch (logand last-command-char #x1F))) + ((< last-command-char #xF0) + (setq len 2 ch (logand last-command-char #x0F))) + ((< last-command-char #xF8) + (setq len 3 ch (logand last-command-char #x07))) + (t + (setq len 4 ch 0))) + (while (> len 0) + (setq ch (logior (lsh ch 6) (logand (read-char-exclusive) #x3F)) + len (1- len))) + (let ((last-command-char ch)) + (self-insert-command arg)))) + (defun encoded-kbd-setup-keymap (coding) ;; At first, reset the keymap. (setcdr encoded-kbd-mode-map nil) @@ -315,6 +332,13 @@ (vector from) 'encoded-kbd-self-insert-ccl)) (setq from (1+ from)))))) + ((eq encoded-kbd-coding 'utf-8) + (let ((i #xC0)) + (while (< i 256) + (define-key encoded-kbd-mode-map + (vector i) 'encoded-kbd-self-insert-utf-8) + (setq i (1+ i))))) + (t (error "Invalid value in encoded-kbd-coding: %s" encoded-kbd-coding)))) @@ -387,6 +411,12 @@ 'use-8th-bit (nth 3 saved-input-mode)) (setq encoded-kbd-coding 'charset)) + ((eq (coding-system-type coding) 'utf-8) + (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 'utf-8)) + (t (setq encoded-kbd-mode nil) (error "Coding-system `%s' is not supported in Encoded-kbd mode"