From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: YAMAMOTO Mitsuharu Newsgroups: gmane.emacs.devel Subject: keyboard-coding-system in Carbon Emacs Date: Wed, 06 Apr 2005 12:26:57 +0900 Organization: Faculty of Science, Chiba University Message-ID: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII X-Trace: sea.gmane.org 1112758864 7609 80.91.229.2 (6 Apr 2005 03:41:04 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 6 Apr 2005 03:41:04 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Apr 06 05:41:01 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1DJ1PT-0006Ih-AQ for ged-emacs-devel@m.gmane.org; Wed, 06 Apr 2005 05:40:58 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DJ0yR-0008KT-3H for ged-emacs-devel@m.gmane.org; Tue, 05 Apr 2005 23:12:59 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1DJ0wx-000833-Fm for emacs-devel@gnu.org; Tue, 05 Apr 2005 23:11:28 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DJ0ww-00081U-IA for emacs-devel@gnu.org; Tue, 05 Apr 2005 23:11:26 -0400 Original-Received: from [133.82.132.2] (helo=mathmail.math.s.chiba-u.ac.jp) by monty-python.gnu.org with esmtp (Exim 4.34) id 1DJ1CI-0006nf-3z for emacs-devel@gnu.org; Tue, 05 Apr 2005 23:27:19 -0400 Original-Received: from church.math.s.chiba-u.ac.jp (church [133.82.132.36]) by mathmail.math.s.chiba-u.ac.jp (Postfix) with ESMTP id 765D01A6395 for ; Wed, 6 Apr 2005 12:26:57 +0900 (JST) Original-To: emacs-devel@gnu.org User-Agent: Wanderlust/2.14.0 (Africa) SEMI/1.14.6 (Maruoka) FLIM/1.14.6 (Marutamachi) APEL/10.6 Emacs/22.0.50 (sparc-sun-solaris2.8) MULE/5.0 (SAKAKI) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:35609 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:35609 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) ! ;;;; Keysyms ! ;; Define constant values to be set to mac-keyboard-text-encoding ! (defconst kTextEncodingMacRoman 0) ! (defconst kTextEncodingISOLatin1 513 "0x201") ! (defconst kTextEncodingISOLatin2 514 "0x202") ;;;; Selections and cut buffers --- 1085,1110 ---- (put 'escape 'ascii-character ?\e) ! ;;;; 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) ;;;; 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