aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenichi Handa2004-10-15 07:26:15 +0000
committerKenichi Handa2004-10-15 07:26:15 +0000
commite4eabe74a4c58caeea6b46504632a2520ccede19 (patch)
treeef139dc026e3298d4f89cf50a0f6153b5a3db1bf
parentc2ff978a2c6b2281dbbb89a62ca7658880caa6d7 (diff)
downloademacs-e4eabe74a4c58caeea6b46504632a2520ccede19.tar.gz
emacs-e4eabe74a4c58caeea6b46504632a2520ccede19.zip
(encoded-kbd-decode-code-list): New
function. (encoded-kbd-self-insert-charset): Support multibyte charsets. (encoded-kbd-setup-keymap): Likewise.
-rw-r--r--lisp/international/encoded-kb.el67
1 files changed, 52 insertions, 15 deletions
diff --git a/lisp/international/encoded-kb.el b/lisp/international/encoded-kb.el
index f9020fed4e5..ad80baecf76 100644
--- a/lisp/international/encoded-kb.el
+++ b/lisp/international/encoded-kb.el
@@ -177,14 +177,46 @@ The following key sequence may cause multilingual text insertion."
177 (setq str (format "%s%c" str (read-char-exclusive)))) 177 (setq str (format "%s%c" str (read-char-exclusive))))
178 (vector (aref result 0)))) 178 (vector (aref result 0))))
179 179
180
181;; Decode list of codes in CODE-LIST by CHARSET and return the decoded
182;; characters. If CODE-LIST is too short for the dimension of
183;; CHARSET, read new codes and append them to the tail of CODE-LIST.
184;; Return nil if CODE-LIST can't be decoded.
185
186(defun encoded-kbd-decode-code-list (charset code-list)
187 (let ((dimension (charset-dimension charset))
188 code)
189 (while (> dimension (length code-list))
190 (nconc code-list (list (read-char-exclusive))))
191 (setq code (car code-list))
192 (if (= dimension 1)
193 (decode-char charset code)
194 (setq code-list (cdr code-list)
195 code (logior (lsh code 8) (car code-list)))
196 (if (= dimension 2)
197 (decode-char charset code)
198 (setq code-list (cdr code-list)
199 code (logior (lsh code 8) (car code-list)))
200 (if (= dimension 3)
201 (decode-char charset code)
202 ;; As Emacs can't handle full 32-bit integer, we must give a
203 ;; cons of higher and lower 16-bit codes to decode-char.
204 (setq code (cons (lsh code -8)
205 (logior (lsh (car code-list) 8) (cadr code-list))))
206 (decode-char charset code))))))
207
180(defun encoded-kbd-self-insert-charset (ignore) 208(defun encoded-kbd-self-insert-charset (ignore)
181 (let* ((charset-list 209 (let ((charset-list
182 (coding-system-get (keyboard-coding-system) :charset-list)) 210 (coding-system-get (keyboard-coding-system) :charset-list))
183 (charset (car charset-list)) 211 (code-list (list (encoded-kbd-last-key)))
184 ;; For the moment, we can assume that the length of CHARSET-LIST 212 tail char)
185 ;; is 1, and the dimension of CHARSET is 1. 213 (while (and charset-list (not char))
186 (char (encoded-kbd-last-key))) 214 (setq char (encoded-kbd-decode-code-list (car charset-list) code-list)
187 (vector (or (decode-char charset char) char)))) 215 charset-list (cdr charset-list)))
216 (if char
217 (vector char)
218 (setq unread-command-events (cdr code-list))
219 (vector (car code-list)))))
188 220
189(defun encoded-kbd-self-insert-utf-8 (arg) 221(defun encoded-kbd-self-insert-utf-8 (arg)
190 (interactive "p") 222 (interactive "p")
@@ -217,14 +249,19 @@ The following key sequence may cause multilingual text insertion."
217 8) 249 8)
218 250
219 ((eq (coding-system-type coding) 'charset) 251 ((eq (coding-system-type coding) 'charset)
220 (let* ((charset (car (coding-system-get coding :charset-list))) 252 (dolist (elt (mapcar
221 (code-space (get-charset-property charset :code-space)) 253 #'(lambda (x)
222 (from (max (aref code-space 0) 128)) 254 (let ((dim (charset-dimension x))
223 (to (aref code-space 1))) 255 (code-space (get-charset-property x :code-space)))
224 (while (<= from to) 256 (cons (aref code-space (* (1- dim) 2))
225 (define-key key-translation-map 257 (aref code-space (1+ (* (1- dim) 2))))))
226 (vector from) 'encoded-kbd-self-insert-charset) 258 (coding-system-get coding :charset-list)))
227 (setq from (1+ from)))) 259 (let ((from (max (car elt) 128))
260 (to (cdr elt)))
261 (while (<= from to)
262 (define-key key-translation-map
263 (vector from) 'encoded-kbd-self-insert-charset)
264 (setq from (1+ from)))))
228 8) 265 8)
229 266
230 ((eq (coding-system-type coding) 'iso-2022) 267 ((eq (coding-system-type coding) 'iso-2022)