unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Stefan Monnier" <monnier+gnu/emacs@rum.cs.yale.edu>
Cc: "Stefan Monnier" <monnier+gnu/emacs@rum.cs.yale.edu>,
	emacs-devel@gnu.org
Subject: Re: change in X character input processing
Date: Fri, 01 Nov 2002 14:53:39 -0500	[thread overview]
Message-ID: <200211011953.gA1Jred05539@rum.cs.yale.edu> (raw)
In-Reply-To: rzqwunxz97y.fsf@albion.dl.ac.uk


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;

  parent reply	other threads:[~2002-11-01 19:53 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-10-31 10:55 change in X character input processing Dave Love
2002-10-31 15:20 ` Stefan Monnier
2002-11-01 13:54   ` Dave Love
2002-11-01 15:54     ` Stefan Monnier
2002-11-01 19:53     ` Stefan Monnier [this message]
2002-11-02 13:51       ` Dave Love
2002-11-03  3:06         ` Stefan Monnier
2002-11-06 19:04           ` Dave Love
2002-11-06 19:19             ` Stefan Monnier
2002-11-07 10:34               ` Kim F. Storm
2002-11-11 20:08                 ` Dave Love
2002-11-11 19:59               ` Dave Love
2002-11-11 20:35                 ` Stefan Monnier
2002-10-31 15:31 ` Stefan Monnier
2002-11-01 13:58   ` Dave Love

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200211011953.gA1Jred05539@rum.cs.yale.edu \
    --to=monnier+gnu/emacs@rum.cs.yale.edu \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).