Mailing List Archive

Support open source code!


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

tlug: Yatta! XEmacs Japanese input with kinput2 via XIM



--------------------------------------------------------
tlug note from "Stephen J. Turnbull" <turnbull@example.com>
--------------------------------------------------------
XEmacs and kinput2 disagree about the need to provide non-null areas
for unused subwindows.  The patch to XEmacs below corrects this, and I
successfully used kinput2 to input "korehanihongodesu." and henkan it
in XEmacs.  I have not tried simultaneous use with kterm, either via
XIM or kinput2 protocol.

I'm not sure how happy I am with the kinput2 implementation; kinput2's
`hiragana a' Status window is awkward.  If you use Canna or Wnn, you
don't really need it; the henkan server gives sufficient feedback.  (I
guess people who use other features such as JIS-code input and such
might want more mode info, but I'd rather not have it.)  Other than
that, I don't see that Egg fence-mode is that much of an improvement,
and I positively like the (potentially) large separate window for
selection that kinput2 offers near the spot.  The position of the
Status area can be changed, but you can't get rid of it.  There seem
to be three possible resource settings:

! Default: PreEdit over the spot with Status in minibuffer
Emacs*ximStyles: XIMPreeditPosition|XIMStatusArea
! PreEdit over the spot with Status immediately below the spot
Emacs*ximStyles: XIMPreeditPosition|XIMStatusNothing
! PreEdit and Status together in separate window
! (ie, child of root, not Emacs frame)
Emacs*ximStyles: XIMPreeditNone|XIMStatusNone

There may be others, but the several variations I tried all ended up
being equivalent to one of the above.  See xemacs-20.2/etc/Emacs.ad.
You might also want to fiddle with the foreground and background
colors and font settings.  (The defaults are yoo-gly.)

I have not done any fooling around to figure out what good resources
for starting and stopping henkan are; I just use kinput2's default of
shift-SPACE.  XEmacs does not seem to provide any; apparently once the 
IM is open, XEmacs passes all keyboard events to it.

This patch works in the Xlib implementation of XIM for XEmacs; it may
also work for the Motif implementation.  I don't plan to try it
anytime soon.

The necessary patch is in src/input-methods-xlib.c at line 157:

#ifdef DONT_PANDER_TO_KINPUT2
  XRectangle p_area = {0,0,0,0}, s_area={0,0,0,0};   /* original code */
#else /* use Steve's patch to make kinput2 happy */
  XRectangle p_area = {0,0,1,1}, s_area={0,0,1,1};
#endif

Technical details

Configurations:

XEmacs 20.2 + patch above
  ./configure  'i486-homebrew-linux' '--with-mule' '--with-xim' '--verbose'
  Configured for `i486-homebrew-linux'.
  Where should the build process find the source code?    /var/tmp/xemacs-20.2
  What installation prefix should install use?		  /usr/local
  What operating system and machine description files should XEmacs use?
        `s/linux.h' and `m/intel386.h'
  What compiler should XEmacs be built with?              gcc  -g -O 
  Should XEmacs use the GNU version of malloc?            yes
  Should XEmacs use the relocating allocator for buffers? yes
  What window system should XEmacs use?                   x11
  Where do we find X Windows header files?                /usr/X11R6/include
  Where do we find X Windows libraries?                   /usr/X11R6/lib
  Compiling in support for XAUTH.
  Compiling in support for XPM.
  Compiling in support for GIF image conversion.
  Compiling in support for Berkeley DB.
  Compiling in support for GNU DBM.
  Compiling in support for ncurses.
  Compiling in Mule (multi-lingual) support.
  Compiling in XIM (X11R5+ I18N input method) support.
    Using raw Xlib to provide XIM support.
  Using the Lucid menubar.
  Using the Lucid scrollbar.
  Using the Motif dialog boxes.

kinput2 v2 pl3 + no local patches
  #define USECANNA
  #undef USEWnn
  #undef USESJ3
  + configuration for local installation directories of Canna

Canna 3.5b2
  (I forget the configuration; if it seems to matter, ask me.)

Bug analysis:

The crashes I experienced are caused because kinput2 refused to give
XEmacs an X Input Context, so the XIC pointer was null.  XEmacs was
handing that null pointer to XmbLookupString
(xemacs-20.2/src/event-Xt.c:644) with the predictable disastrous
result.  This is a bug in XEmacs, which is assuming that once an input
method is opened, nothing can go wrong.

The problem with opening the input context is due to the fact that
XEmacs hands null rectangles to the input method for the Status and
PreEdit areas.  kinput2 doesn't like this, throws an error, and
returns a failure to XEmacs.  (XEmacs detects and reports this on
stderr, by the way, but then proceeds to try to use XIM anyway, as
described above.  There's an obvious patch for this, but I'm not
enough of an Emacs hacker to know whether the obvious patch makes
sense.  There's also the issue that in the long run this code must be
reorganized to allow use of multiple input methods and multiple input
contexts in Emacs; the current setup only works in the current Unix
locale, and does not allow, say, a locale-per-buffer or changing
locales on the fly in a buffer.)

Providing trivial rectangles for the PreEdit and Status areas solves
the crash and allow the IM to open.

I don't see on a quick reading what the XIM standard requires here.
Tentatively I'd say it's a bug in kinput2.
-- 
                            Stephen J. Turnbull
Institute of Policy and Planning Sciences                    Yaseppochi-Gumi
University of Tsukuba                      http://turnbull.sk.tsukuba.ac.jp/
Tel: +81 (298) 53-5091;  Fax: 55-3849              turnbull@example.com
-----------------------------------------------------------------
a word from the sponsor will appear below
-----------------------------------------------------------------
The TLUG mailing list is proudly sponsored by TWICS - Japan's First
Public-Access Internet System.  Now offering 20,000 yen/year flat
rate Internet access with no time charges.  Full line of corporate
Internet and intranet products are available.   info@example.com
Tel: 03-3351-5977   Fax: 03-3353-6096


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links