From: Karoly Lorentey Date: Mon, 27 Jun 2005 00:39:09 +0000 (+0000) Subject: Replace encoded-kbd-mode with display-specific encoded-kbd-setup-display. (Doesn... X-Git-Tag: emacs-pretest-23.0.90~11236^2~141^2~239 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=40df3a9982975aba7fd04392507537129879d2d5;p=emacs.git 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 --- diff --git a/lisp/international/encoded-kb.el b/lisp/international/encoded-kb.el index 3da034a05ed..3e9de740581 100644 --- a/lisp/international/encoded-kb.el +++ b/lisp/international/encoded-kb.el @@ -251,59 +251,54 @@ The following key sequence may cause multilingual text insertion." (t nil))) -;; key-translation-map at the time Encoded-kbd mode is turned on is -;; saved here. -(defvar saved-key-translation-map nil) - ;; Input mode at the time Encoded-kbd mode is turned on is saved here. +;; XXX This should be made display-local somehow. (defvar saved-input-mode nil) -(put 'encoded-kbd-mode 'permanent-local t) ;;;###autoload -(define-minor-mode encoded-kbd-mode - "Toggle Encoded-kbd minor mode. -With arg, turn Encoded-kbd mode on if and only if arg is positive. - -You should not turn this mode on manually, instead use the command -\\[set-keyboard-coding-system] which turns on or off this mode -automatically. - -In Encoded-kbd mode, a text sent from keyboard is accepted -as a multilingual text encoded in a coding system set by -\\[set-keyboard-coding-system]." - :global t :group 'keyboard :group 'mule - - (if encoded-kbd-mode - ;; We are turning on Encoded-kbd mode. - (let ((coding (keyboard-coding-system)) - result) - (or saved-key-translation-map - (if (keymapp key-translation-map) - (setq saved-key-translation-map - (copy-keymap key-translation-map)) - (setq key-translation-map (make-sparse-keymap)))) - (or saved-input-mode - (setq saved-input-mode - (current-input-mode))) - (setq result (and coding (encoded-kbd-setup-keymap coding))) - (if result - (if (eq result 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-mode nil - saved-key-translation-map nil - saved-input-mode nil) - (error "Unsupported coding system in Encoded-kbd mode: %S" - coding))) - - ;; We are turning off Encoded-kbd mode. - (setq key-translation-map saved-key-translation-map - saved-key-translation-map nil) - (apply 'set-input-mode saved-input-mode) - (setq saved-input-mode nil))) +(defun encoded-kbd-setup-display (display) + "Set up a `key-translation-map' for `keyboard-coding-system' on DISPLAY. + +DISPLAY may be a display id, a frame, or nil for the selected frame's display." + (let ((frame (if (framep display) display (car (frames-on-display-list display))))) + (when frame + (with-selected-frame frame + (message (format "encoded-kbd-setup-display %s %s %s" display frame key-translation-map)) + ;; Remove any previous encoded-kb keymap from key-translation-map. + (let ((m key-translation-map)) + (if (equal (keymap-prompt m) "encoded-kb") + (setq key-translation-map (keymap-parent m)) + (while (keymap-parent m) + (if (equal (keymap-prompt (keymap-parent m)) "encoded-kb") + (set-keymap-parent m (keymap-parent (keymap-parent m)))) + (setq m (keymap-parent m))))) + + (if (keyboard-coding-system) + ;; We are turning on Encoded-kbd mode. + (let ((coding (keyboard-coding-system)) + (keymap (make-sparse-keymap "encoded-kb")) + result) + (set-keymap-parent keymap key-translation-map) + (setq key-translation-map keymap) + (or saved-input-mode + (setq saved-input-mode (current-input-mode))) + (setq result (and coding (encoded-kbd-setup-keymap coding))) + (if result + (if (eq result 8) + (set-input-mode + (nth 0 saved-input-mode) + (nth 1 saved-input-mode) + 'use-8th-bit + (nth 3 saved-input-mode))) + (setq saved-input-mode nil) + (error "Unsupported coding system in Encoded-kbd mode: %S" + coding))) + ;; We are turning off Encoded-kbd mode. + (and saved-input-mode + (apply 'set-input-mode saved-input-mode)) + (setq saved-input-mode nil)) + (when (not (eq (selected-frame) frame)) + (error "Anyátok picsája!")))))) (provide 'encoded-kb) diff --git a/lisp/international/mule.el b/lisp/international/mule.el index 74c4b96c3d4..dbb8df39a7e 100644 --- a/lisp/international/mule.el +++ b/lisp/international/mule.el @@ -1232,9 +1232,8 @@ See also the command `set-keyboard-coding-system'.") (defun set-keyboard-coding-system (coding-system &optional display) "Set coding system for keyboard input on DISPLAY to CODING-SYSTEM. -In addition, this command enables Encoded-kbd minor mode. -\(If CODING-SYSTEM is nil, Encoded-kbd mode is turned off -- see -`encoded-kbd-mode'.) +In addition, this command calls `encoded-kbd-setup-display' to set up the +translation of keyboard input events to the specified coding system. For a list of possible values of CODING-SYSTEM, use \\[list-coding-systems]. The default is determined by the selected language environment @@ -1257,7 +1256,7 @@ The setting has no effect on graphical displays." (setq default-keyboard-coding-system coding-system)) (set-keyboard-coding-system-internal coding-system display) (setq keyboard-coding-system coding-system) - (encoded-kbd-mode (if coding-system 1 0))) + (encoded-kbd-setup-display display)) (defcustom keyboard-coding-system nil "Specify coding system for keyboard input.