changeset 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 ebfb2856c8e6
children cb3cae14fe7e
files lisp/international/encoded-kb.el lisp/international/mule.el
diffstat 2 files changed, 45 insertions(+), 51 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/international/encoded-kb.el	Sun Jun 26 21:12:57 2005 +0000
+++ b/lisp/international/encoded-kb.el	Mon Jun 27 00:39:09 2005 +0000
@@ -251,59 +251,54 @@
    (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.
+(defun encoded-kbd-setup-display (display)
+  "Set up a `key-translation-map' for `keyboard-coding-system' on DISPLAY.
 
-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
+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 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)))
+	(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)
 
--- a/lisp/international/mule.el	Sun Jun 26 21:12:57 2005 +0000
+++ b/lisp/international/mule.el	Mon Jun 27 00:39:09 2005 +0000
@@ -1232,9 +1232,8 @@
 
 (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 @@
       (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.