comparison lisp/international/encoded-kb.el @ 83321:f6ed7ae6fa8d

Replace encoded-kbd-mode with display-specific encoded-kbd-setup-display. (Doesn't work yet.) * lisp/international/encoded-kb.el (saved-key-translation-map): Remove. (encoded-kbd-mode): Remove. (encoded-kbd-setup-display): New function. * lisp/international/mule.el (set-keyboard-coding-system): Use it. git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-361
author Karoly Lorentey <lorentey@elte.hu>
date Mon, 27 Jun 2005 00:39:09 +0000
parents c36561fe0657
children 9e41c80c6389
comparison
equal deleted inserted replaced
83320:ebfb2856c8e6 83321:f6ed7ae6fa8d
249 8)) 249 8))
250 250
251 (t 251 (t
252 nil))) 252 nil)))
253 253
254 ;; key-translation-map at the time Encoded-kbd mode is turned on is
255 ;; saved here.
256 (defvar saved-key-translation-map nil)
257
258 ;; Input mode at the time Encoded-kbd mode is turned on is saved here. 254 ;; Input mode at the time Encoded-kbd mode is turned on is saved here.
255 ;; XXX This should be made display-local somehow.
259 (defvar saved-input-mode nil) 256 (defvar saved-input-mode nil)
260 257
261 (put 'encoded-kbd-mode 'permanent-local t)
262 ;;;###autoload 258 ;;;###autoload
263 (define-minor-mode encoded-kbd-mode 259 (defun encoded-kbd-setup-display (display)
264 "Toggle Encoded-kbd minor mode. 260 "Set up a `key-translation-map' for `keyboard-coding-system' on DISPLAY.
265 With arg, turn Encoded-kbd mode on if and only if arg is positive. 261
266 262 DISPLAY may be a display id, a frame, or nil for the selected frame's display."
267 You should not turn this mode on manually, instead use the command 263 (let ((frame (if (framep display) display (car (frames-on-display-list display)))))
268 \\[set-keyboard-coding-system] which turns on or off this mode 264 (when frame
269 automatically. 265 (with-selected-frame frame
270 266 (message (format "encoded-kbd-setup-display %s %s %s" display frame key-translation-map))
271 In Encoded-kbd mode, a text sent from keyboard is accepted 267 ;; Remove any previous encoded-kb keymap from key-translation-map.
272 as a multilingual text encoded in a coding system set by 268 (let ((m key-translation-map))
273 \\[set-keyboard-coding-system]." 269 (if (equal (keymap-prompt m) "encoded-kb")
274 :global t :group 'keyboard :group 'mule 270 (setq key-translation-map (keymap-parent m))
275 271 (while (keymap-parent m)
276 (if encoded-kbd-mode 272 (if (equal (keymap-prompt (keymap-parent m)) "encoded-kb")
277 ;; We are turning on Encoded-kbd mode. 273 (set-keymap-parent m (keymap-parent (keymap-parent m))))
278 (let ((coding (keyboard-coding-system)) 274 (setq m (keymap-parent m)))))
279 result) 275
280 (or saved-key-translation-map 276 (if (keyboard-coding-system)
281 (if (keymapp key-translation-map) 277 ;; We are turning on Encoded-kbd mode.
282 (setq saved-key-translation-map 278 (let ((coding (keyboard-coding-system))
283 (copy-keymap key-translation-map)) 279 (keymap (make-sparse-keymap "encoded-kb"))
284 (setq key-translation-map (make-sparse-keymap)))) 280 result)
285 (or saved-input-mode 281 (set-keymap-parent keymap key-translation-map)
286 (setq saved-input-mode 282 (setq key-translation-map keymap)
287 (current-input-mode))) 283 (or saved-input-mode
288 (setq result (and coding (encoded-kbd-setup-keymap coding))) 284 (setq saved-input-mode (current-input-mode)))
289 (if result 285 (setq result (and coding (encoded-kbd-setup-keymap coding)))
290 (if (eq result 8) 286 (if result
291 (set-input-mode 287 (if (eq result 8)
292 (nth 0 saved-input-mode) 288 (set-input-mode
293 (nth 1 saved-input-mode) 289 (nth 0 saved-input-mode)
294 'use-8th-bit 290 (nth 1 saved-input-mode)
295 (nth 3 saved-input-mode))) 291 'use-8th-bit
296 (setq encoded-kbd-mode nil 292 (nth 3 saved-input-mode)))
297 saved-key-translation-map nil 293 (setq saved-input-mode nil)
298 saved-input-mode nil) 294 (error "Unsupported coding system in Encoded-kbd mode: %S"
299 (error "Unsupported coding system in Encoded-kbd mode: %S" 295 coding)))
300 coding))) 296 ;; We are turning off Encoded-kbd mode.
301 297 (and saved-input-mode
302 ;; We are turning off Encoded-kbd mode. 298 (apply 'set-input-mode saved-input-mode))
303 (setq key-translation-map saved-key-translation-map 299 (setq saved-input-mode nil))
304 saved-key-translation-map nil) 300 (when (not (eq (selected-frame) frame))
305 (apply 'set-input-mode saved-input-mode) 301 (error "Anyátok picsája!"))))))
306 (setq saved-input-mode nil)))
307 302
308 (provide 'encoded-kb) 303 (provide 'encoded-kb)
309 304
310 ;;; arch-tag: 76f0f9b3-65e7-45c3-b692-59509a87ad44 305 ;;; arch-tag: 76f0f9b3-65e7-45c3-b692-59509a87ad44
311 ;;; encoded-kb.el ends here 306 ;;; encoded-kb.el ends here