# HG changeset patch # User aidan # Date 1134848823 0 # Node ID 77f5a5135b3af3df432b68dfac21acce37b31d60 # Parent 66c42fc5d26bcdf1663576c95209b11a8d708a78 [xemacs-hg @ 2005-12-17 19:46:57 by aidan] Fix self-insert-command with X11 input methods. Addresses Zhang Wei's problem of 871x118lc4.fsf@gmail.com. diff -r 66c42fc5d26b -r 77f5a5135b3a lisp/ChangeLog --- a/lisp/ChangeLog Fri Dec 16 23:52:23 2005 +0000 +++ b/lisp/ChangeLog Sat Dec 17 19:47:03 2005 +0000 @@ -1,3 +1,15 @@ +2005-12-17 Aidan Kehoe + + * mule/mule-cmds.el (set-language-environment-coding-systems): + Initialise keyboard-coding-system, terminal-coding-system when + applying a language environment, together with the input and + output coding systems for any active TTY console. + * mule/mule-cmds.el (init-locale-at-early-startup): + If set-current-locale returns a `more-specified version' of the + current locale when passed a zero length argument, the magic used + to work out the current language environment from the C locale + will fail. Call current-locale instead. + 2005-12-17 Adrian Aichner * package-get.el (package-get-download-sites): Add Hong Kong diff -r 66c42fc5d26b -r 77f5a5135b3a lisp/mule/mule-cmds.el --- a/lisp/mule/mule-cmds.el Fri Dec 16 23:52:23 2005 +0000 +++ b/lisp/mule/mule-cmds.el Sat Dec 17 19:47:03 2005 +0000 @@ -1271,6 +1271,20 @@ (warn "Invalid native-coding-system %s in language environment %s" native language-name))) (define-coding-system-alias 'file-name 'native) + ;; Set the default keyboard and terminal coding systems to the native + ;; coding system of the language environment. + ;; + (setq keyboard-coding-system native + terminal-coding-system native) + + ;; And do the same for any TTYs. + (dolist (con (console-list)) + (when (eq 'tty (device-type (car (console-device-list con)))) + ;; Calling set-input-mode at the same time would be a sane thing + ;; to do here. I would prefer to default to accepting eight bit + ;; input and not using the top bit for Meta. + (set-console-tty-coding-system con native))) + ;; process output should not have EOL conversion. under MS Windows ;; and Cygwin, this screws things up (`cmd' is fine with just LF and ;; `bash' chokes on CR-LF). @@ -1327,7 +1341,7 @@ ;; locale but we should still use the right code page, etc. (declare-fboundp (mswindows-set-current-locale userdef))) ;; Unix: - (let ((locstring (set-current-locale ""))) + (let ((locstring (current-locale))) ;; assume C lib locale and LANG env var are set correctly. use ;; them to find the langenv. (setq langenv diff -r 66c42fc5d26b -r 77f5a5135b3a src/ChangeLog --- a/src/ChangeLog Fri Dec 16 23:52:23 2005 +0000 +++ b/src/ChangeLog Sat Dec 17 19:47:03 2005 +0000 @@ -1,3 +1,18 @@ +2005-12-17 Aidan Kehoe + + * console-x.c (x_perhaps_init_unseen_key_defaults): + If the key name is a single character, and the keysym is NoSymbol, + give it a default binding, if that is possible. This addresses the + problem Zhang Wei points out in <871x118lc4.fsf@gmail.com> + * event-Xt.c (x_to_emacs_keysym): + Print the characters of a keysym's name directly if it's printable + ASCII, or as an octal escape if it's not. + + Use keyboard-coding-system rather than undecided for decoding the + keysym name passed to us by an input method. + * file-coding.c (vars_of_file_coding): + Document that keyboard-coding-system is also used for X11. + 2005-11-29 Marcus Crestani * xemacs.def.in.in: Condition error_check_* symbols on diff -r 66c42fc5d26b -r 77f5a5135b3a src/console-x.c --- a/src/console-x.c Fri Dec 16 23:52:23 2005 +0000 +++ b/src/console-x.c Sat Dec 17 19:47:03 2005 +0000 @@ -349,6 +349,26 @@ xkeysym = XStringToKeysym(keysym_ext); if (NoSymbol == xkeysym) { + /* Keysym is NoSymbol; this may mean the key event passed to us came + from an input method, which stored the actual character intended to + be inserted in the key name, and didn't trouble itself to set the + keycode to anything useful. Thus, if the key name is a single + character, and the keysym is NoSymbol, give it a default binding, + if that is possible. */ + Lisp_Object keychar; + + if (1 != string_char_length(key_name)) + { + /* Don't let them pass us more than one character. */ + return Qnil; + } + keychar = make_char(itext_ichar(XSTRING_DATA(key_name))); + if (NILP (Flookup_key (Vcurrent_global_map, keychar, Qnil))) + { + Fdefine_key (Vcurrent_global_map, keychar, Qself_insert_command); + Fputhash (keychar, Qt, DEVICE_X_KEYSYM_MAP_HASH_TABLE (d)); + return Qt; + } return Qnil; } diff -r 66c42fc5d26b -r 77f5a5135b3a src/event-Xt.c --- a/src/event-Xt.c Fri Dec 16 23:52:23 2005 +0000 +++ b/src/event-Xt.c Sat Dec 17 19:47:03 2005 +0000 @@ -898,7 +898,16 @@ int j; stderr_out (" chars=\""); for (j=0; j= 0177) + { + stderr_out ("%c", bufptr[j]); + } + else + { + stderr_out ("\\%o", (unsigned)(bufptr[j])); + } + } stderr_out ("\""); } else if (bufptr[0] <= 32 || bufptr[0] >= 127) @@ -928,10 +937,18 @@ fb_instream = make_fixed_buffer_input_stream (bufptr, len); - /* #### Use get_coding_system_for_text_file (Vcomposed_input_coding_system, 0) */ + /* [[ Use get_coding_system_for_text_file + (Vcomposed_input_coding_system, 0) ]] + + Nope. If it is possible for the X libraries to have multiple IM + connections on different DISPLAYs active at once, this should be + a console-specific variable (like a TTY's coding system) but I've + seen no evidence that that is possible. Aidan Kehoe, + 2005-12-17. */ + instream = make_coding_input_stream - (XLSTREAM (fb_instream), Qundecided, CODING_DECODE, 0); + (XLSTREAM (fb_instream), Qkeyboard, CODING_DECODE, 0); istr = XLSTREAM (instream); diff -r 66c42fc5d26b -r 77f5a5135b3a src/file-coding.c --- a/src/file-coding.c Fri Dec 16 23:52:23 2005 +0000 +++ b/src/file-coding.c Sat Dec 17 19:47:03 2005 +0000 @@ -4600,8 +4600,14 @@ #endif DEFVAR_LISP ("keyboard-coding-system", &Vkeyboard_coding_system /* -Coding system used for TTY keyboard input. -Not used under a windowing system. +Default coding system used for TTY and X11 keyboard input. +Under X11, used only to interpet the character for a key event when that +event has a KeySym of NoSymbol but does have an associated string keysym, +something that's seen with input methods. + +If you need to set these things to different coding systems, call the +function `set-console-tty-coding-system' for the TTY and use this variable +for X11. */ ); Vkeyboard_coding_system = Qnil;