From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: "Stefan Monnier" Newsgroups: gmane.emacs.devel Subject: Re: change in X character input processing Date: Fri, 01 Nov 2002 14:53:39 -0500 Sender: emacs-devel-admin@gnu.org Message-ID: <200211011953.gA1Jred05539@rum.cs.yale.edu> References: <200210311520.g9VFKQH28182@rum.cs.yale.edu> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1036180637 28947 80.91.224.249 (1 Nov 2002 19:57:17 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Fri, 1 Nov 2002 19:57:17 +0000 (UTC) Cc: "Stefan Monnier" , emacs-devel@gnu.org Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 187huo-0007We-00 for ; Fri, 01 Nov 2002 20:57:10 +0100 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 187i11-0008SO-00 for ; Fri, 01 Nov 2002 21:03:35 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10) id 187hrv-0001DW-00; Fri, 01 Nov 2002 14:54:11 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10) id 187hrV-00017z-00 for emacs-devel@gnu.org; Fri, 01 Nov 2002 14:53:45 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10) id 187hrS-00016v-00 for emacs-devel@gnu.org; Fri, 01 Nov 2002 14:53:44 -0500 Original-Received: from rum.cs.yale.edu ([128.36.229.169]) by monty-python.gnu.org with esmtp (Exim 4.10) id 187hrS-00016l-00 for emacs-devel@gnu.org; Fri, 01 Nov 2002 14:53:42 -0500 Original-Received: (from monnier@localhost) by rum.cs.yale.edu (8.11.6/8.11.6) id gA1Jred05539; Fri, 1 Nov 2002 14:53:40 -0500 X-Mailer: exmh version 2.4 06/23/2000 with nmh-1.0.4 Original-To: Dave Love Errors-To: emacs-devel-admin@gnu.org X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.0.11 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Emacs development discussions. List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.emacs.devel:9050 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:9050 The new code you installed works very differently from the one you had before. Now your x-keysym-table overrides the usual XmbLookupString+decode process This means that when you do LANG=fr_FR@euro emacs -q --no-site-file with your code an eacute will insert a latin-1 eacute whereas with the previous code it inserted a latin-9 eacute. I'm not sure we want to do that just now. I suggest we revert to the code you had before, so that the XmbLookupString+decode is used as before and x-keysym-table is only used if that failed (which is only the case if the key you hit translates into a char that doesn't exist in the coding-system corresponding to your locale, such as when you hit EuroSign in a latin-1 locale). The reason why I'd like to revert is that your code basically does a form of unify-on-keyboard-input and I'm not sure that we want to do that already since we don't have unify-on-decoding turned on by default. I.e. I suggest the patch below (against the version before your latest fix). See after my sig for the patch against the current version. *** src/xterm.c 30 Oct 2002 19:12:37 -0000 1.759 --- src/xterm.c 1 Nov 2002 19:47:22 -0000 *************** *** 10821,10850 **** if (temp_index == sizeof temp_buffer / sizeof (short)) temp_index = 0; temp_buffer[temp_index++] = keysym; ! /* First deal with keysyms which have ! defined translations to characters. */ ! if (keysym >= 32 && keysym < 128) ! /* Avoid explicitly decoding each ASCII ! character. */ { ! bufp->kind = ASCII_KEYSTROKE_EVENT; ! bufp->code = c; ! } ! else if (! EQ ((c = Fgethash (make_number (keysym), ! Vx_keysym_table, ! Qnil)), ! Qnil)) ! { ! bufp->kind = (SINGLE_BYTE_CHAR_P (c) ? ASCII_KEYSTROKE_EVENT : MULTIBYTE_CHAR_KEYSTROKE_EVENT); - bufp->code = c; } else { ! /* Not a character keysym. ! make_lispy_event will convert it to a ! symbolic key. */ bufp->kind = NON_ASCII_KEYSTROKE_EVENT; bufp->code = keysym; } --- 10822,10840 ---- if (temp_index == sizeof temp_buffer / sizeof (short)) temp_index = 0; temp_buffer[temp_index++] = keysym; ! if (NATNUMP (c = Fgethash (make_number (keysym), ! Vx_keysym_table, ! Qnil))) { ! bufp->code = XFASTINT (c); ! bufp->kind = (SINGLE_BYTE_CHAR_P (bufp->code) ? ASCII_KEYSTROKE_EVENT : MULTIBYTE_CHAR_KEYSTROKE_EVENT); } else { ! /* Not a character keysym. make_lispy_event ! will convert it to a symbolic key. */ bufp->kind = NON_ASCII_KEYSTROKE_EVENT; bufp->code = keysym; } As you can see all it does is remove the ASCII handling (because it basically can't happen here and because it uses variable `c' before it's initialized) and fixes some int/Lisp_Object mixup (and uses NATNUMP rather then EQ (..., Qnil)). Stefan Index: src/xterm.c =================================================================== RCS file: /cvsroot/emacs/emacs/src/xterm.c,v retrieving revision 1.760 diff -c -r1.760 xterm.c *** src/xterm.c 31 Oct 2002 17:59:30 -0000 1.760 --- src/xterm.c 1 Nov 2002 19:45:01 -0000 *************** *** 10738,10871 **** if (numchars > 1) { ! Lisp_Object c; ! ! /* First deal with keysyms which have defined ! translations to characters. */ ! if (keysym >= 32 && keysym < 128) ! /* Avoid explicitly decoding each ASCII character. */ ! { ! bufp->kind = ASCII_KEYSTROKE_EVENT; ! bufp->code = keysym; ! XSETFRAME (bufp->frame_or_window, f); ! bufp->arg = Qnil; ! bufp->modifiers ! = x_x_to_emacs_modifiers (FRAME_X_DISPLAY_INFO (f), ! modifiers); ! bufp->timestamp = event.xkey.time; ! bufp++; ! count++; ! numchars--; ! } ! /* Now non-ASCII. */ ! else if (! EQ ((c = Fgethash (make_number (keysym), ! Vx_keysym_table, Qnil)), ! Qnil)) ! { ! bufp->kind = (SINGLE_BYTE_CHAR_P (c) ! ? ASCII_KEYSTROKE_EVENT ! : MULTIBYTE_CHAR_KEYSTROKE_EVENT); ! bufp->code = c; ! XSETFRAME (bufp->frame_or_window, f); ! bufp->arg = Qnil; ! bufp->modifiers ! = x_x_to_emacs_modifiers (FRAME_X_DISPLAY_INFO (f), ! modifiers); ! bufp->timestamp = event.xkey.time; ! bufp++; ! count++; ! numchars--; ! } ! /* Random non-modifier sorts of keysyms. */ ! else if (((keysym >= XK_BackSpace && keysym <= XK_Escape) ! || keysym == XK_Delete #ifdef XK_ISO_Left_Tab ! || (keysym >= XK_ISO_Left_Tab ! && keysym <= XK_ISO_Enter) #endif ! || IsCursorKey (keysym) /* 0xff50 <= x < 0xff60 */ ! || IsMiscFunctionKey (keysym) /* 0xff60 <= x < VARIES */ #ifdef HPUX ! /* This recognizes the "extended function ! keys". It seems there's no cleaner way. ! Test IsModifierKey to avoid handling ! mode_switch incorrectly. */ ! || ((unsigned) (keysym) >= XK_Select ! && (unsigned)(keysym) < XK_KP_Space) #endif #ifdef XK_dead_circumflex ! || orig_keysym == XK_dead_circumflex #endif #ifdef XK_dead_grave ! || orig_keysym == XK_dead_grave #endif #ifdef XK_dead_tilde ! || orig_keysym == XK_dead_tilde #endif #ifdef XK_dead_diaeresis ! || orig_keysym == XK_dead_diaeresis #endif #ifdef XK_dead_macron ! || orig_keysym == XK_dead_macron #endif #ifdef XK_dead_degree ! || orig_keysym == XK_dead_degree #endif #ifdef XK_dead_acute ! || orig_keysym == XK_dead_acute #endif #ifdef XK_dead_cedilla ! || orig_keysym == XK_dead_cedilla #endif #ifdef XK_dead_breve ! || orig_keysym == XK_dead_breve #endif #ifdef XK_dead_ogonek ! || orig_keysym == XK_dead_ogonek #endif #ifdef XK_dead_caron ! || orig_keysym == XK_dead_caron #endif #ifdef XK_dead_doubleacute ! || orig_keysym == XK_dead_doubleacute #endif #ifdef XK_dead_abovedot ! || orig_keysym == XK_dead_abovedot #endif ! || IsKeypadKey (keysym) /* 0xff80 <= x < 0xffbe */ ! || IsFunctionKey (keysym) /* 0xffbe <= x < 0xffe1 */ ! /* Any "vendor-specific" key is ok. */ ! || (orig_keysym & (1 << 28)) ! || (keysym != NoSymbol && nbytes == 0)) ! && ! (IsModifierKey (orig_keysym) #ifndef HAVE_X11R5 #ifdef XK_Mode_switch ! || ((unsigned)(orig_keysym) == XK_Mode_switch) #endif #ifdef XK_Num_Lock ! || ((unsigned)(orig_keysym) == XK_Num_Lock) #endif #endif /* not HAVE_X11R5 */ ! /* The symbols from XK_ISO_Lock ! to XK_ISO_Last_Group_Lock ! don't have real modifiers but ! should be treated similarly to ! Mode_switch by Emacs. */ #if defined XK_ISO_Lock && defined XK_ISO_Last_Group_Lock ! || ((unsigned)(orig_keysym) ! >= XK_ISO_Lock ! && (unsigned)(orig_keysym) ! <= XK_ISO_Last_Group_Lock) #endif ! )) { if (temp_index == sizeof temp_buffer / sizeof (short)) temp_index = 0; temp_buffer[temp_index++] = keysym; ! /* make_lispy_event will convert this to a symbolic ! key. */ ! bufp->kind = NON_ASCII_KEYSTROKE_EVENT; ! bufp->code = keysym; XSETFRAME (bufp->frame_or_window, f); bufp->arg = Qnil; bufp->modifiers --- 10738,10843 ---- if (numchars > 1) { ! if (((keysym >= XK_BackSpace && keysym <= XK_Escape) ! || keysym == XK_Delete #ifdef XK_ISO_Left_Tab ! || (keysym >= XK_ISO_Left_Tab && keysym <= XK_ISO_Enter) #endif ! || (keysym >= XK_Kanji && keysym <= XK_Eisu_toggle) ! || IsCursorKey (keysym) /* 0xff50 <= x < 0xff60 */ ! || IsMiscFunctionKey (keysym) /* 0xff60 <= x < VARIES */ #ifdef HPUX ! /* This recognizes the "extended function keys". ! It seems there's no cleaner way. ! Test IsModifierKey to avoid handling mode_switch ! incorrectly. */ ! || ((unsigned) (keysym) >= XK_Select ! && (unsigned)(keysym) < XK_KP_Space) #endif #ifdef XK_dead_circumflex ! || orig_keysym == XK_dead_circumflex #endif #ifdef XK_dead_grave ! || orig_keysym == XK_dead_grave #endif #ifdef XK_dead_tilde ! || orig_keysym == XK_dead_tilde #endif #ifdef XK_dead_diaeresis ! || orig_keysym == XK_dead_diaeresis #endif #ifdef XK_dead_macron ! || orig_keysym == XK_dead_macron #endif #ifdef XK_dead_degree ! || orig_keysym == XK_dead_degree #endif #ifdef XK_dead_acute ! || orig_keysym == XK_dead_acute #endif #ifdef XK_dead_cedilla ! || orig_keysym == XK_dead_cedilla #endif #ifdef XK_dead_breve ! || orig_keysym == XK_dead_breve #endif #ifdef XK_dead_ogonek ! || orig_keysym == XK_dead_ogonek #endif #ifdef XK_dead_caron ! || orig_keysym == XK_dead_caron #endif #ifdef XK_dead_doubleacute ! || orig_keysym == XK_dead_doubleacute #endif #ifdef XK_dead_abovedot ! || orig_keysym == XK_dead_abovedot #endif ! || IsKeypadKey (keysym) /* 0xff80 <= x < 0xffbe */ ! || IsFunctionKey (keysym) /* 0xffbe <= x < 0xffe1 */ ! /* Any "vendor-specific" key is ok. */ ! || (orig_keysym & (1 << 28)) ! || (keysym != NoSymbol && nbytes == 0)) ! && ! (IsModifierKey (orig_keysym) #ifndef HAVE_X11R5 #ifdef XK_Mode_switch ! || ((unsigned)(orig_keysym) == XK_Mode_switch) #endif #ifdef XK_Num_Lock ! || ((unsigned)(orig_keysym) == XK_Num_Lock) #endif #endif /* not HAVE_X11R5 */ ! /* The symbols from XK_ISO_Lock to ! XK_ISO_Last_Group_Lock doesn't have real ! modifiers but should be treated similarly ! to Mode_switch by Emacs. */ #if defined XK_ISO_Lock && defined XK_ISO_Last_Group_Lock ! || ((unsigned)(orig_keysym) >= XK_ISO_Lock ! && (unsigned)(orig_keysym) <= XK_ISO_Last_Group_Lock) #endif ! )) { + Lisp_Object c; + if (temp_index == sizeof temp_buffer / sizeof (short)) temp_index = 0; temp_buffer[temp_index++] = keysym; ! if (NATNUMP (c = Fgethash (make_number (keysym), ! Vx_keysym_table, ! Qnil))) ! { ! bufp->code = XFASTINT (c); ! bufp->kind = (SINGLE_BYTE_CHAR_P (bufp->code) ! ? ASCII_KEYSTROKE_EVENT ! : MULTIBYTE_CHAR_KEYSTROKE_EVENT); ! } ! else ! { ! /* Not a character keysym. make_lispy_event ! will convert it to a symbolic key. */ ! bufp->kind = NON_ASCII_KEYSTROKE_EVENT; ! bufp->code = keysym; ! } XSETFRAME (bufp->frame_or_window, f); bufp->arg = Qnil; bufp->modifiers *************** *** 10877,10883 **** numchars--; } else if (numchars > nbytes) ! { /* Raw bytes, not keysym. */ register int i; register int c; int nchars, len; --- 10849,10855 ---- numchars--; } else if (numchars > nbytes) ! { register int i; register int c; int nchars, len;