unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* keyboard-coding-system in Carbon Emacs
@ 2005-04-06  3:26 YAMAMOTO Mitsuharu
  2005-04-08  5:18 ` YAMAMOTO Mitsuharu
  0 siblings, 1 reply; 3+ messages in thread
From: YAMAMOTO Mitsuharu @ 2005-04-06  3:26 UTC (permalink / raw)


I think the default value of keyboard-coding-system in Carbon Emacs
has been source of annoyance.  Users have to set an appropriate value
to input non-ASCII characters using external input methods or
combinations with the option key.

The patch below is an attempt to solve such a problem by dynamically
changing the value of keyboard-coding-system by detecting keyboard
layout changes.  Because I can test this only in limited environments,
I'd like to ask Carbon Emacs users, especially non-US keyboard users,
to test this patch in various environments.  It makes the variable
`mac-keyboard-text-encoding' and related constants (kTextEncoding...)
obsolete, so please comment out the setting of this variable if you
have one in your ~/.emacs before testing.

				     YAMAMOTO Mitsuharu
				mituharu@math.s.chiba-u.ac.jp

Index: lisp/term/mac-win.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/term/mac-win.el,v
retrieving revision 1.36
diff -c -r1.36 mac-win.el
*** lisp/term/mac-win.el	6 Apr 2005 02:15:29 -0000	1.36
--- lisp/term/mac-win.el	6 Apr 2005 03:23:05 -0000
***************
*** 1085,1097 ****
  (put 'escape 'ascii-character ?\e)
  
  \f
! ;;;; Keysyms
  
! ;; Define constant values to be set to mac-keyboard-text-encoding
! (defconst kTextEncodingMacRoman 0)
! (defconst kTextEncodingISOLatin1 513 "0x201")
! (defconst kTextEncodingISOLatin2 514 "0x202")
  
  \f
  ;;;; Selections and cut buffers
  
--- 1085,1110 ----
  (put 'escape 'ascii-character ?\e)
  
  \f
! ;;;; Keyboard layout/language change events
! (defconst mac-script-code-coding-systems
!   '((0 . mac-roman)			; smRoman
!     (1 . sjis)				; smJapanese
!     (2 . big5)				; smTradChinese
!     (3 . euc-kr)			; smKorean
!     (25 . cn-gb)			; smSimpChinese
!     )
!   "Alist of Mac script codes vs Emacs coding systems.")
  
! (defun mac-set-keyboard-coding-system (event)
!   (interactive "e")
!   (let ((coding-system
! 	 (cdr (assq (nth 1 (cadr event)) mac-script-code-coding-systems))))
!     (set-keyboard-coding-system (or coding-system 'mac-roman))
!     ;; MacJapanese maps reverse solidus to ?\x80.
!     (if (eq coding-system 'sjis)
! 	(define-key key-translation-map [?\x80] "\\"))))
  
+ (global-set-key [language-change] 'mac-set-keyboard-coding-system)
  \f
  ;;;; Selections and cut buffers
  
Index: src/keyboard.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/keyboard.c,v
retrieving revision 1.817
diff -c -r1.817 keyboard.c
*** src/keyboard.c	31 Mar 2005 10:11:14 -0000	1.817
--- src/keyboard.c	6 Apr 2005 03:23:05 -0000
***************
*** 530,536 ****
  /* Symbols to denote kinds of events.  */
  Lisp_Object Qfunction_key;
  Lisp_Object Qmouse_click;
! #ifdef WINDOWSNT
  Lisp_Object Qlanguage_change;
  #endif
  Lisp_Object Qdrag_n_drop;
--- 530,536 ----
  /* Symbols to denote kinds of events.  */
  Lisp_Object Qfunction_key;
  Lisp_Object Qmouse_click;
! #if defined (WINDOWSNT) || defined (MAC_OS)
  Lisp_Object Qlanguage_change;
  #endif
  Lisp_Object Qdrag_n_drop;
***************
*** 4028,4038 ****
  	    x_activate_menubar (XFRAME (event->frame_or_window));
  	}
  #endif
! #ifdef WINDOWSNT
        else if (event->kind == LANGUAGE_CHANGE_EVENT)
  	{
  	  /* Make an event (language-change (FRAME CHARSET LCID)).  */
  	  obj = Fcons (event->frame_or_window, Qnil);
  	  obj = Fcons (Qlanguage_change, Fcons (obj, Qnil));
  	  kbd_fetch_ptr = event + 1;
  	}
--- 4028,4044 ----
  	    x_activate_menubar (XFRAME (event->frame_or_window));
  	}
  #endif
! #if defined (WINDOWSNT) || defined (MAC_OS)
        else if (event->kind == LANGUAGE_CHANGE_EVENT)
  	{
+ #ifdef MAC_OS
+ 	  /* Make an event (language-change (FRAME KEY_SCRIPT)).  */
+ 	  obj = Fcons (make_number (event->code), Qnil);
+ 	  obj = Fcons (event->frame_or_window, obj);
+ #else
  	  /* Make an event (language-change (FRAME CHARSET LCID)).  */
  	  obj = Fcons (event->frame_or_window, Qnil);
+ #endif
  	  obj = Fcons (Qlanguage_change, Fcons (obj, Qnil));
  	  kbd_fetch_ptr = event + 1;
  	}
***************
*** 10837,10843 ****
    staticpro (&Qfunction_key);
    Qmouse_click = intern ("mouse-click");
    staticpro (&Qmouse_click);
! #ifdef WINDOWSNT
    Qlanguage_change = intern ("language-change");
    staticpro (&Qlanguage_change);
  #endif
--- 10843,10849 ----
    staticpro (&Qfunction_key);
    Qmouse_click = intern ("mouse-click");
    staticpro (&Qmouse_click);
! #if defined (WINDOWSNT) || defined (MAC_OS)
    Qlanguage_change = intern ("language-change");
    staticpro (&Qlanguage_change);
  #endif
Index: src/macterm.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/macterm.c,v
retrieving revision 1.106
diff -c -r1.106 macterm.c
*** src/macterm.c	16 Mar 2005 08:08:06 -0000	1.106
--- src/macterm.c	6 Apr 2005 03:23:05 -0000
***************
*** 7148,7155 ****
--- 7148,7157 ----
  
  /* convert input from Mac keyboard (assumed to be in Mac Roman coding)
     to this text encoding */
+ #if 0
  int mac_keyboard_text_encoding;
  int current_mac_keyboard_text_encoding = kTextEncodingMacRoman;
+ #endif
  
  /* Set in term/mac-win.el to indicate that event loop can now generate
     drag and drop events.  */
***************
*** 8964,8969 ****
--- 8966,8991 ----
  		break;
  	      }
  #endif
+ 	    {
+ 	      static SInt16 last_key_script = -1;
+ 	      SInt16 current_key_script = GetScriptManagerVariable (smKeyScript);
+ 
+ 	      if (last_key_script != current_key_script)
+ 		{
+ 		  struct input_event event;
+ 		  
+ 		  EVENT_INIT (event);
+ 		  event.kind = LANGUAGE_CHANGE_EVENT;
+ 		  event.arg = Qnil;
+ 		  XSETFRAME (event.frame_or_window,
+ 			     mac_window_to_frame (front_emacs_window ()));
+ 		  event.timestamp = er.when * (1000 / 60);
+ 		  event.code = current_key_script;
+ 		  kbd_buffer_store_event_hold (&event, hold_quit);
+ 		  count++;
+ 		}
+ 	      last_key_script = current_key_script;
+ 	    }
  
  	    ObscureCursor ();
  
***************
*** 9016,9021 ****
--- 9038,9044 ----
  	      }
  	  }
  
+ #if 0
  	  /* If variable mac-convert-keyboard-input-to-latin-1 is
  	     non-nil, convert non-ASCII characters typed at the Mac
  	     keyboard (presumed to be in the Mac Roman encoding) to
***************
*** 9079,9084 ****
--- 9102,9108 ----
  		    }
  		}
  	    }
+ #endif
  
  #if USE_CARBON_EVENTS
  	  inev.modifiers = mac_event_to_emacs_modifiers (eventRef);
***************
*** 9893,9898 ****
--- 9917,9923 ----
  may anti-alias the text.  */);
    Vmac_use_core_graphics = Qnil;
  
+ #if 0
    DEFVAR_INT ("mac-keyboard-text-encoding", &mac_keyboard_text_encoding,
      doc: /* One of the Text Encoding Base constant values defined in the
  Basic Text Constants section of Inside Macintosh - Text Encoding
***************
*** 9907,9912 ****
--- 9932,9938 ----
  command, this enables the Mac keyboard to be used to enter non-ASCII
  characters directly.  */);
    mac_keyboard_text_encoding = kTextEncodingMacRoman;
+ #endif
  }
  
  /* arch-tag: f2259165-4454-4c04-a029-a133c8af7b5b
Index: src/termhooks.h
===================================================================
RCS file: /cvsroot/emacs/emacs/src/termhooks.h,v
retrieving revision 1.67
diff -c -r1.67 termhooks.h
*** src/termhooks.h	27 Feb 2004 23:48:49 -0000	1.67
--- src/termhooks.h	6 Apr 2005 03:23:06 -0000
***************
*** 252,261 ****
  				   the wheel event occurred in.
  				   .timestamp gives a timestamp (in
  				   milliseconds) for the event.  */
! #ifdef WINDOWSNT
!   LANGUAGE_CHANGE_EVENT,	/* A LANGUAGE_CHANGE_EVENT is generated
! 				   on WINDOWSNT when the keyboard layout
! 				   or input language is changed by the
  				   user.  */
  #endif
    SCROLL_BAR_CLICK_EVENT,	/* .code gives the number of the mouse button
--- 252,262 ----
  				   the wheel event occurred in.
  				   .timestamp gives a timestamp (in
  				   milliseconds) for the event.  */
! #if defined (WINDOWSNT) || defined (MAC_OS)
!   LANGUAGE_CHANGE_EVENT,	/* A LANGUAGE_CHANGE_EVENT is
! 				   generated on WINDOWSNT or Mac OS
! 				   when the keyboard layout or input
! 				   language is changed by the
  				   user.  */
  #endif
    SCROLL_BAR_CLICK_EVENT,	/* .code gives the number of the mouse button

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: keyboard-coding-system in Carbon Emacs
  2005-04-06  3:26 keyboard-coding-system in Carbon Emacs YAMAMOTO Mitsuharu
@ 2005-04-08  5:18 ` YAMAMOTO Mitsuharu
  2005-04-09  3:38   ` Richard Stallman
  0 siblings, 1 reply; 3+ messages in thread
From: YAMAMOTO Mitsuharu @ 2005-04-08  5:18 UTC (permalink / raw)


>>>>> On Wed, 06 Apr 2005 12:26:57 +0900, YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> said:

> The patch below is an attempt to solve such a problem by dynamically
> changing the value of keyboard-coding-system by detecting keyboard
> layout changes.

In the previous patch, I used global-set-key to bind a handler
function for the `language-change' event.  But it seems to work best
if it is bound in special-event-map so that the event may not be
ignored by read-char-exclusive or explicitly read by
read-key-sequence.  Is it OK to use special-event-map for this
purpose?

Below is the revised patch.  Input methods whose script is either
Roman, Japanese, Traditional Chinese, Korean, Cyrillic, Simplified
Chinese, or Central European (in order of Mac script code) should
work, but not for Unicode.  Scripts of input methods are displayed at
the `Script' column in System Preferences -> International -> Input
Menu.

				     YAMAMOTO Mitsuharu
				mituharu@math.s.chiba-u.ac.jp

Index: lisp/term/mac-win.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/term/mac-win.el,v
retrieving revision 1.36
diff -c -r1.36 mac-win.el
*** lisp/term/mac-win.el	6 Apr 2005 02:15:29 -0000	1.36
--- lisp/term/mac-win.el	8 Apr 2005 04:43:31 -0000
***************
*** 1085,1097 ****
  (put 'escape 'ascii-character ?\e)
  
  \f
! ;;;; Keysyms
  
! ;; Define constant values to be set to mac-keyboard-text-encoding
! (defconst kTextEncodingMacRoman 0)
! (defconst kTextEncodingISOLatin1 513 "0x201")
! (defconst kTextEncodingISOLatin2 514 "0x202")
  
  \f
  ;;;; Selections and cut buffers
  
--- 1085,1113 ----
  (put 'escape 'ascii-character ?\e)
  
  \f
! ;;;; Keyboard layout/language change events
! (defconst mac-script-code-coding-systems
!   '((0 . mac-roman)			; smRoman
!     (1 . sjis)				; smJapanese
!     (2 . big5)				; smTradChinese
!     (3 . euc-kr)			; smKorean
!     (7 . mac-cyrillic)			; smCyrillic
!     (25 . cn-gb)			; smSimpChinese
!     (29 . mac-centraleurroman)		; smCentralEuroRoman
!     )
!   "Alist of Mac script codes vs Emacs coding systems.")
  
! ;;;; Keyboard layout/language change events
! (defun mac-handle-language-change (event)
!   (interactive "e")
!   (let ((coding-system
! 	 (cdr (assq (car (cadr event)) mac-script-code-coding-systems))))
!     (set-keyboard-coding-system (or coding-system 'mac-roman))
!     ;; MacJapanese maps reverse solidus to ?\x80.
!     (if (eq coding-system 'sjis)
! 	(define-key key-translation-map [?\x80] "\\"))))
  
+ (define-key special-event-map [language-change] 'mac-handle-language-change)
  \f
  ;;;; Selections and cut buffers
  
***************
*** 1139,1159 ****
  
  (setq frame-creation-function 'x-create-frame-with-faces)
  
! (define-ccl-program ccl-encode-mac-roman-font
!   `(0
!     (if (r0 != ,(charset-id 'ascii))
! 	(if (r0 <= ?\x8f)
! 	    (translate-character mac-roman-encoder r0 r1)
! 	  ((r1 <<= 7)
! 	   (r1 |= r2)
! 	   (translate-character mac-roman-encoder r0 r1)))))
!   "CCL program for Mac Roman font")
! 
! (let
!     ((encoding-vector (make-vector 256 nil))
!      (i 0)
!      (vec	;; mac-centraleurroman (128..255) -> UCS mapping
!       [	#x00C4	;; 128:LATIN CAPITAL LETTER A WITH DIAERESIS
  	#x0100	;; 129:LATIN CAPITAL LETTER A WITH MACRON
  	#x0101	;; 130:LATIN SMALL LETTER A WITH MACRON
  	#x00C9	;; 131:LATIN CAPITAL LETTER E WITH ACUTE
--- 1155,1168 ----
  
  (setq frame-creation-function 'x-create-frame-with-faces)
  
! (cp-make-coding-system
!  mac-centraleurroman
!  (apply
!   'vector
!   (mapcar
!    (lambda (c) (decode-char 'ucs c))
!    ;; mac-centraleurroman (128..255) -> UCS mapping
!    [	#x00C4	;; 128:LATIN CAPITAL LETTER A WITH DIAERESIS
  	#x0100	;; 129:LATIN CAPITAL LETTER A WITH MACRON
  	#x0101	;; 130:LATIN SMALL LETTER A WITH MACRON
  	#x00C9	;; 131:LATIN CAPITAL LETTER E WITH ACUTE
***************
*** 1281,1306 ****
  	#x017C	;; 253:LATIN SMALL LETTER Z WITH DOT ABOVE
  	#x0122	;; 254:LATIN CAPITAL LETTER G WITH CEDILLA
  	#x02C7	;; 255:CARON
! 	])
!      translation-table)
!   (while (< i 128)
!     (aset encoding-vector i i)
!     (setq i (1+ i)))
!   (while (< i 256)
!     (aset encoding-vector i
! 	  (decode-char 'ucs (aref vec (- i 128))))
!     (setq i (1+ i)))
!   (setq translation-table
! 	(make-translation-table-from-vector encoding-vector))
! ;;  (define-translation-table 'mac-centraleurroman-decoder translation-table)
!   (define-translation-table 'mac-centraleurroman-encoder
!     (char-table-extra-slot translation-table 0)))
! 
! (let
!     ((encoding-vector (make-vector 256 nil))
!      (i 0)
!      (vec	;; mac-cyrillic (128..255) -> UCS mapping
!       [	#x0410	;; 128:CYRILLIC CAPITAL LETTER A
  	#x0411	;; 129:CYRILLIC CAPITAL LETTER BE
  	#x0412	;; 130:CYRILLIC CAPITAL LETTER VE
  	#x0413	;; 131:CYRILLIC CAPITAL LETTER GHE
--- 1290,1307 ----
  	#x017C	;; 253:LATIN SMALL LETTER Z WITH DOT ABOVE
  	#x0122	;; 254:LATIN CAPITAL LETTER G WITH CEDILLA
  	#x02C7	;; 255:CARON
! 	]))
!  "Mac Central European Roman Encoding (MIME:x-mac-centraleurroman).")
! (coding-system-put 'mac-centraleurroman 'mime-charset 'x-mac-centraleurroman)
! 
! (cp-make-coding-system
!  mac-cyrillic
!  (apply
!   'vector
!   (mapcar
!    (lambda (c) (decode-char 'ucs c))
!    ;; mac-cyrillic (128..255) -> UCS mapping
!    [	#x0410	;; 128:CYRILLIC CAPITAL LETTER A
  	#x0411	;; 129:CYRILLIC CAPITAL LETTER BE
  	#x0412	;; 130:CYRILLIC CAPITAL LETTER VE
  	#x0413	;; 131:CYRILLIC CAPITAL LETTER GHE
***************
*** 1428,1454 ****
  	#x044D	;; 253:CYRILLIC SMALL LETTER E
  	#x044E	;; 254:CYRILLIC SMALL LETTER YU
  	#x20AC	;; 255:EURO SIGN
! 	])
!      translation-table)
!   (while (< i 128)
!     (aset encoding-vector i i)
!     (setq i (1+ i)))
!   (while (< i 256)
!     (aset encoding-vector i
! 	  (decode-char 'ucs (aref vec (- i 128))))
!     (setq i (1+ i)))
!   (setq translation-table
! 	(make-translation-table-from-vector encoding-vector))
! ;;  (define-translation-table 'mac-cyrillic-decoder translation-table)
!   (define-translation-table 'mac-cyrillic-encoder
!     (char-table-extra-slot translation-table 0)))
  
  (defvar mac-font-encoder-list
    '(("mac-roman" mac-roman-encoder
       ccl-encode-mac-roman-font "%s")
!     ("mac-centraleurroman" mac-centraleurroman-encoder
       ccl-encode-mac-centraleurroman-font "%s ce")
!     ("mac-cyrillic" mac-cyrillic-encoder
       ccl-encode-mac-cyrillic-font "%s cy")))
  
  (let ((encoder-list
--- 1429,1444 ----
  	#x044D	;; 253:CYRILLIC SMALL LETTER E
  	#x044E	;; 254:CYRILLIC SMALL LETTER YU
  	#x20AC	;; 255:EURO SIGN
! 	]))
!  "Mac Cyrillic Encoding (MIME:x-mac-cyrillic).")
! (coding-system-put 'mac-cyrillic 'mime-charset 'x-mac-cyrillic)
  
  (defvar mac-font-encoder-list
    '(("mac-roman" mac-roman-encoder
       ccl-encode-mac-roman-font "%s")
!     ("mac-centraleurroman" encode-mac-centraleurroman
       ccl-encode-mac-centraleurroman-font "%s ce")
!     ("mac-cyrillic" encode-mac-cyrillic
       ccl-encode-mac-cyrillic-font "%s cy")))
  
  (let ((encoder-list
***************
*** 1468,1491 ****
  	    (if mac-encoded
  		(aset table c mac-encoded))))))))
  
  (define-ccl-program ccl-encode-mac-centraleurroman-font
    `(0
      (if (r0 != ,(charset-id 'ascii))
  	(if (r0 <= ?\x8f)
! 	    (translate-character mac-centraleurroman-encoder r0 r1)
  	  ((r1 <<= 7)
  	   (r1 |= r2)
! 	   (translate-character mac-centraleurroman-encoder r0 r1)))))
    "CCL program for Mac Central European Roman font")
  
  (define-ccl-program ccl-encode-mac-cyrillic-font
    `(0
      (if (r0 != ,(charset-id 'ascii))
  	(if (r0 <= ?\x8f)
! 	    (translate-character mac-cyrillic-encoder r0 r1)
  	  ((r1 <<= 7)
  	   (r1 |= r2)
! 	   (translate-character mac-cyrillic-encoder r0 r1)))))
    "CCL program for Mac Cyrillic font")
  
  
--- 1458,1491 ----
  	    (if mac-encoded
  		(aset table c mac-encoded))))))))
  
+ (define-ccl-program ccl-encode-mac-roman-font
+   `(0
+     (if (r0 != ,(charset-id 'ascii))
+ 	(if (r0 <= ?\x8f)
+ 	    (translate-character mac-roman-encoder r0 r1)
+ 	  ((r1 <<= 7)
+ 	   (r1 |= r2)
+ 	   (translate-character mac-roman-encoder r0 r1)))))
+   "CCL program for Mac Roman font")
+ 
  (define-ccl-program ccl-encode-mac-centraleurroman-font
    `(0
      (if (r0 != ,(charset-id 'ascii))
  	(if (r0 <= ?\x8f)
! 	    (translate-character encode-mac-centraleurroman r0 r1)
  	  ((r1 <<= 7)
  	   (r1 |= r2)
! 	   (translate-character encode-mac-centraleurroman r0 r1)))))
    "CCL program for Mac Central European Roman font")
  
  (define-ccl-program ccl-encode-mac-cyrillic-font
    `(0
      (if (r0 != ,(charset-id 'ascii))
  	(if (r0 <= ?\x8f)
! 	    (translate-character encode-mac-cyrillic r0 r1)
  	  ((r1 <<= 7)
  	   (r1 |= r2)
! 	   (translate-character encode-mac-cyrillic r0 r1)))))
    "CCL program for Mac Cyrillic font")
  
  
Index: src/keyboard.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/keyboard.c,v
retrieving revision 1.817
diff -c -r1.817 keyboard.c
*** src/keyboard.c	31 Mar 2005 10:11:14 -0000	1.817
--- src/keyboard.c	8 Apr 2005 04:43:31 -0000
***************
*** 530,536 ****
  /* Symbols to denote kinds of events.  */
  Lisp_Object Qfunction_key;
  Lisp_Object Qmouse_click;
! #ifdef WINDOWSNT
  Lisp_Object Qlanguage_change;
  #endif
  Lisp_Object Qdrag_n_drop;
--- 530,536 ----
  /* Symbols to denote kinds of events.  */
  Lisp_Object Qfunction_key;
  Lisp_Object Qmouse_click;
! #if defined (WINDOWSNT) || defined (MAC_OS)
  Lisp_Object Qlanguage_change;
  #endif
  Lisp_Object Qdrag_n_drop;
***************
*** 4028,4038 ****
  	    x_activate_menubar (XFRAME (event->frame_or_window));
  	}
  #endif
! #ifdef WINDOWSNT
        else if (event->kind == LANGUAGE_CHANGE_EVENT)
  	{
  	  /* Make an event (language-change (FRAME CHARSET LCID)).  */
  	  obj = Fcons (event->frame_or_window, Qnil);
  	  obj = Fcons (Qlanguage_change, Fcons (obj, Qnil));
  	  kbd_fetch_ptr = event + 1;
  	}
--- 4028,4043 ----
  	    x_activate_menubar (XFRAME (event->frame_or_window));
  	}
  #endif
! #if defined (WINDOWSNT) || defined (MAC_OS)
        else if (event->kind == LANGUAGE_CHANGE_EVENT)
  	{
+ #ifdef MAC_OS
+ 	  /* Make an event (language-change (KEY_SCRIPT)).  */
+ 	  obj = Fcons (make_number (event->code), Qnil);
+ #else
  	  /* Make an event (language-change (FRAME CHARSET LCID)).  */
  	  obj = Fcons (event->frame_or_window, Qnil);
+ #endif
  	  obj = Fcons (Qlanguage_change, Fcons (obj, Qnil));
  	  kbd_fetch_ptr = event + 1;
  	}
***************
*** 10837,10843 ****
    staticpro (&Qfunction_key);
    Qmouse_click = intern ("mouse-click");
    staticpro (&Qmouse_click);
! #ifdef WINDOWSNT
    Qlanguage_change = intern ("language-change");
    staticpro (&Qlanguage_change);
  #endif
--- 10842,10848 ----
    staticpro (&Qfunction_key);
    Qmouse_click = intern ("mouse-click");
    staticpro (&Qmouse_click);
! #if defined (WINDOWSNT) || defined (MAC_OS)
    Qlanguage_change = intern ("language-change");
    staticpro (&Qlanguage_change);
  #endif
Index: src/macterm.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/macterm.c,v
retrieving revision 1.106
diff -c -r1.106 macterm.c
*** src/macterm.c	16 Mar 2005 08:08:06 -0000	1.106
--- src/macterm.c	8 Apr 2005 04:43:32 -0000
***************
*** 7148,7155 ****
--- 7148,7157 ----
  
  /* convert input from Mac keyboard (assumed to be in Mac Roman coding)
     to this text encoding */
+ #if 0
  int mac_keyboard_text_encoding;
  int current_mac_keyboard_text_encoding = kTextEncodingMacRoman;
+ #endif
  
  /* Set in term/mac-win.el to indicate that event loop can now generate
     drag and drop events.  */
***************
*** 8964,8969 ****
--- 8966,8991 ----
  		break;
  	      }
  #endif
+ 	    {
+ 	      static SInt16 last_key_script = -1;
+ 	      SInt16 current_key_script = GetScriptManagerVariable (smKeyScript);
+ 
+ 	      if (last_key_script != current_key_script)
+ 		{
+ 		  struct input_event event;
+ 		  
+ 		  EVENT_INIT (event);
+ 		  event.kind = LANGUAGE_CHANGE_EVENT;
+ 		  event.arg = Qnil;
+ 		  XSETFRAME (event.frame_or_window,
+ 			     mac_window_to_frame (front_emacs_window ()));
+ 		  event.timestamp = er.when * (1000 / 60);
+ 		  event.code = current_key_script;
+ 		  kbd_buffer_store_event_hold (&event, hold_quit);
+ 		  count++;
+ 		}
+ 	      last_key_script = current_key_script;
+ 	    }
  
  	    ObscureCursor ();
  
***************
*** 9016,9021 ****
--- 9038,9044 ----
  	      }
  	  }
  
+ #if 0
  	  /* If variable mac-convert-keyboard-input-to-latin-1 is
  	     non-nil, convert non-ASCII characters typed at the Mac
  	     keyboard (presumed to be in the Mac Roman encoding) to
***************
*** 9079,9084 ****
--- 9102,9108 ----
  		    }
  		}
  	    }
+ #endif
  
  #if USE_CARBON_EVENTS
  	  inev.modifiers = mac_event_to_emacs_modifiers (eventRef);
***************
*** 9893,9898 ****
--- 9917,9923 ----
  may anti-alias the text.  */);
    Vmac_use_core_graphics = Qnil;
  
+ #if 0
    DEFVAR_INT ("mac-keyboard-text-encoding", &mac_keyboard_text_encoding,
      doc: /* One of the Text Encoding Base constant values defined in the
  Basic Text Constants section of Inside Macintosh - Text Encoding
***************
*** 9907,9912 ****
--- 9932,9938 ----
  command, this enables the Mac keyboard to be used to enter non-ASCII
  characters directly.  */);
    mac_keyboard_text_encoding = kTextEncodingMacRoman;
+ #endif
  }
  
  /* arch-tag: f2259165-4454-4c04-a029-a133c8af7b5b
Index: src/termhooks.h
===================================================================
RCS file: /cvsroot/emacs/emacs/src/termhooks.h,v
retrieving revision 1.67
diff -c -r1.67 termhooks.h
*** src/termhooks.h	27 Feb 2004 23:48:49 -0000	1.67
--- src/termhooks.h	8 Apr 2005 04:43:32 -0000
***************
*** 252,261 ****
  				   the wheel event occurred in.
  				   .timestamp gives a timestamp (in
  				   milliseconds) for the event.  */
! #ifdef WINDOWSNT
!   LANGUAGE_CHANGE_EVENT,	/* A LANGUAGE_CHANGE_EVENT is generated
! 				   on WINDOWSNT when the keyboard layout
! 				   or input language is changed by the
  				   user.  */
  #endif
    SCROLL_BAR_CLICK_EVENT,	/* .code gives the number of the mouse button
--- 252,262 ----
  				   the wheel event occurred in.
  				   .timestamp gives a timestamp (in
  				   milliseconds) for the event.  */
! #if defined (WINDOWSNT) || defined (MAC_OS)
!   LANGUAGE_CHANGE_EVENT,	/* A LANGUAGE_CHANGE_EVENT is
! 				   generated on WINDOWSNT or Mac OS
! 				   when the keyboard layout or input
! 				   language is changed by the
  				   user.  */
  #endif
    SCROLL_BAR_CLICK_EVENT,	/* .code gives the number of the mouse button

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: keyboard-coding-system in Carbon Emacs
  2005-04-08  5:18 ` YAMAMOTO Mitsuharu
@ 2005-04-09  3:38   ` Richard Stallman
  0 siblings, 0 replies; 3+ messages in thread
From: Richard Stallman @ 2005-04-09  3:38 UTC (permalink / raw)
  Cc: emacs-devel

    In the previous patch, I used global-set-key to bind a handler
    function for the `language-change' event.  But it seems to work best
    if it is bound in special-event-map so that the event may not be
    ignored by read-char-exclusive or explicitly read by
    read-key-sequence.  Is it OK to use special-event-map for this
    purpose?

Yes.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-04-09  3:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-04-06  3:26 keyboard-coding-system in Carbon Emacs YAMAMOTO Mitsuharu
2005-04-08  5:18 ` YAMAMOTO Mitsuharu
2005-04-09  3:38   ` Richard Stallman

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).