From xemacs-m  Mon Aug 25 05:12:46 1997
Received: from mercury.Sun.COM (mercury.Sun.COM [192.9.25.1])
	by xemacs.org (8.8.5/8.8.5) with SMTP id FAA11825
	for <xemacs-beta@xemacs.org>; Mon, 25 Aug 1997 05:12:45 -0500 (CDT)
Received: from Eng.Sun.COM ([129.146.1.25]) by mercury.Sun.COM (SMI-8.6/mail.byaddr) with SMTP id DAA02614; Mon, 25 Aug 1997 03:12:09 -0700
Received: from kindra.eng.sun.com by Eng.Sun.COM (SMI-8.6/SMI-5.3)
	id DAA26382; Mon, 25 Aug 1997 03:12:07 -0700
Received: from xemacs.eng.sun.com by kindra.eng.sun.com (SMI-8.6/SMI-SVR4)
	id DAA15891; Mon, 25 Aug 1997 03:12:06 -0700
Received: by xemacs.eng.sun.com (SMI-8.6/SMI-SVR4)
	id DAA17531; Mon, 25 Aug 1997 03:12:04 -0700
Date: Mon, 25 Aug 1997 03:12:04 -0700
Message-Id: <199708251012.DAA17531@xemacs.eng.sun.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
From: Martin Buchholz <mrb@Eng.Sun.COM>
To: Jan Vroonhof <vroonhof@math.ethz.ch>
Cc: Jamie Zawinski <jwz@netscape.com>, xemacs-beta@xemacs.org
Subject: Re: Sorry I lost your mail..
In-Reply-To: <byoh6msirf.fsf@midget.math.ethz.ch>
References: <byu3gio17a.fsf@midget.math.ethz.ch>
	<33FF859C.58B699F5@netscape.com>
	<byoh6msirf.fsf@midget.math.ethz.ch>
X-Mailer: VM 6.33 under 20.3 "Vienna" XEmacs  Lucid (beta14)
Reply-To: Martin Buchholz <mrb@Eng.Sun.COM>

>>>>> "Jan" == Jan Vroonhof <vroonhof@math.ethz.ch> writes:

Let's work together to get this right.  Maybe I should have just let
you do this key hacking, but it's a long tradition with me to get
mired in the key mapping problems...

Are there REALLY any systems that have dead keys and no multi-key in
the real world?

As my previous msg said, I think loading x-compose.el in 19.16 would
be OK, assuming it was wrapped in (x-keysym-on-keyboard-p "Multi_key").

I'm a little confused about some of these keys.  If the user has a
cedilla key, is this supposed to be a dead key or a self-insert key?
Or only a dead key when used with multi-key?  Xlib seems to regard
cedilla as always self-inserting.

I have tried to fix keymap autoloading in 20.3.  It appears to be working.

Is it really important to handle modifiers with the compose keys?
I was thinking no one would care.

In general, I would like to reduce keybindings for keys the user is
unable to type.  If C-h b lists many non-typable keys, that is not
very nice.  This is why all the dead keys should be wrapped inside
(x-keysym-on-keyboard-p) before any action on them is taken.

Code for your perusal follows:

;;; x-compose-autoloads.el --- European style compose key processing for X windows
;; Copyright (C) 1992, 1993, 1997 Free Software Foundation, Inc.
;; Copyright (C) 1997 Sun Microsystems Inc.

;; Author: Martin Buchholz
;; Keywords: terminals X windows compose key multi-key

;; This file is part of XEmacs.

;; XEmacs is free software; you can redistribute it and/or modify it
;; under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.

;; XEmacs is distributed in the hope that it will be useful, but
;; WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
;; General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with XEmacs; see the file COPYING.  If not, write to the
;; Free Software Foundation, 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.

;;; Commentary:

;; Compose key processing is provided in 3 steps, to avoid penalizing
;; users who don't care about the functionality provided:

;; x-init.el checks for the multi-key keysym, loading
;; x-compose-autoloads.el if it exists.

;; x-compose-autoloads.el creates keymap autoloads for all the keymaps
;; in x-compose.el, and populate which then gets loaded if one of the composition
;; keys actually gets pressed.  The user can also hand-load these
;; files if this mechanism breaks down.

;;; Code:

(eval-when-compile

  (defvar compose-map)
  
  (defmacro x-define-dead-key (key map)
    `(when (x-keysym-on-keyboard-p ,(symbol-name key))
       (define-key function-key-map [,key] ',map))))

(autoload 'compose-map            "x-compose" nil t 'keymap)
(autoload 'compose-acute-map      "x-compose" nil t 'keymap)
(autoload 'compose-grave-map      "x-compose" nil t 'keymap)
(autoload 'compose-cedilla-map    "x-compose" nil t 'keymap)
(autoload 'compose-diaeresis-map  "x-compose" nil t 'keymap)
(autoload 'compose-circumflex-map "x-compose" nil t 'keymap)
(autoload 'compose-tilde-map      "x-compose" nil t 'keymap)

(when (x-keysym-on-keyboard-p "Multi_key")
  (define-key function-key-map [multi-key] 'compose-map))

;; The dead keys might really be called just about anything, depending
;; on the vendor.  MIT thinks that the prefixes are "SunFA_", "D", and
;; "hpmute_" for Sun, DEC, and HP respectively.  However, OpenWindows 3
;; thinks that the prefixes are "SunXK_FA_", "DXK_", and "hpXK_mute_".
;; And HP (who don't mention Sun and DEC at all) use "XK_mute_".
;; Go figure.

;; Presumably if someone is running OpenWindows, they won't be using
;; the DEC or HP keysyms, but if they are defined then that is possible,
;; so in that case we accept them all.

;; If things seem not to be working, you might want to check your
;; /usr/lib/X11/XKeysymDB file to see if your vendor has an equally
;; mixed up view of what these keys should be called.

;; Canonical names:
(x-define-dead-key acute		compose-acute-map)
(x-define-dead-key grave		compose-grave-map)
(x-define-dead-key cedilla		compose-cedilla-map)
(x-define-dead-key diaeresis		compose-diaeresis-map)
(x-define-dead-key circumflex		compose-circumflex-map)
(x-define-dead-key tilde		compose-tilde-map)
(x-define-dead-key degree		compose-ring-map)

;; Sun according to MIT:
(x-define-dead-key SunFA_Acute		compose-acute-map)
(x-define-dead-key SunFA_Grave		compose-grave-map)
(x-define-dead-key SunFA_Cedilla	compose-cedilla-map)
(x-define-dead-key SunFA_Diaeresis	compose-diaeresis-map)
(x-define-dead-key SunFA_Circum		compose-circumflex-map)
(x-define-dead-key SunFA_Tilde		compose-tilde-map)

;; Sun according to OpenWindows 2:
(x-define-dead-key Dead_Grave		compose-grave-map)
(x-define-dead-key Dead_Circum		compose-circumflex-map)
(x-define-dead-key Dead_Tilde		compose-tilde-map)

;; Sun according to OpenWindows 3:
(x-define-dead-key SunXK_FA_Acute	compose-acute-map)
(x-define-dead-key SunXK_FA_Grave	compose-grave-map)
(x-define-dead-key SunXK_FA_Cedilla	compose-cedilla-map)
(x-define-dead-key SunXK_FA_Diaeresis	compose-diaeresis-map)
(x-define-dead-key SunXK_FA_Circum	compose-circumflex-map)
(x-define-dead-key SunXK_FA_Tilde	compose-tilde-map)

;; DEC according to MIT:
(x-define-dead-key Dacute_accent	compose-acute-map)
(x-define-dead-key Dgrave_accent	compose-grave-map)
(x-define-dead-key Dcedilla_accent	compose-cedilla-map)
(x-define-dead-key Dcircumflex_accent	compose-circumflex-map)
(x-define-dead-key Dtilde		compose-tilde-map)
(x-define-dead-key Dring_accent		compose-ring-map)

;; DEC according to OpenWindows 3:
(x-define-dead-key DXK_acute_accent	compose-acute-map)
(x-define-dead-key DXK_grave_accent	compose-grave-map)
(x-define-dead-key DXK_cedilla_accent	compose-cedilla-map)
(x-define-dead-key DXK_circumflex_accent compose-circumflex-map)
(x-define-dead-key DXK_tilde		compose-tilde-map)
(x-define-dead-key DXK_ring_accent	compose-ring-map)

;; HP according to MIT:
(x-define-dead-key hpmute_acute		compose-acute-map)
(x-define-dead-key hpmute_grave		compose-grave-map)
(x-define-dead-key hpmute_diaeresis	compose-diaeresis-map)
(x-define-dead-key hpmute_asciicircum	compose-circumflex-map)
(x-define-dead-key hpmute_asciitilde	compose-tilde-map)

;; HP according to OpenWindows 3:
(x-define-dead-key hpXK_mute_acute	compose-acute-map)
(x-define-dead-key hpXK_mute_grave	compose-grave-map)
(x-define-dead-key hpXK_mute_diaeresis	compose-diaeresis-map)
(x-define-dead-key hpXK_mute_asciicircum compose-circumflex-map)
(x-define-dead-key hpXK_mute_asciitilde	compose-tilde-map)

;; HP according to HP-UX 8.0:
(x-define-dead-key XK_mute_acute	compose-acute-map)
(x-define-dead-key XK_mute_grave	compose-grave-map)
(x-define-dead-key XK_mute_diaeresis	compose-diaeresis-map)
(x-define-dead-key XK_mute_asciicircum	compose-circumflex-map)
(x-define-dead-key XK_mute_asciitilde	compose-tilde-map)

;; Xfree seems to use lower case and a hyphen
(x-define-dead-key dead-acute		compose-acute-map)
(x-define-dead-key dead-grave		compose-grave-map)
(x-define-dead-key dead-cedilla		compose-cedilla-map)
(x-define-dead-key dead-diaeresis	compose-diaeresis-map)
(x-define-dead-key dead-circum		compose-circumflex-map)
(x-define-dead-key dead-tilde		compose-tilde-map)

;;  and AIX uses underscore, sigh....
(x-define-dead-key dead_acute		compose-acute-map)
(x-define-dead-key dead_grave		compose-grave-map)
(x-define-dead-key dead_cedilla		compose-cedilla-map)
(x-define-dead-key dead_diaeresis	compose-diaeresis-map)
(x-define-dead-key dead_circum		compose-circumflex-map)
(x-define-dead-key dead_tilde		compose-tilde-map)

(provide 'x-compose-autoloads)


Jan> This mail contains my belated mutterings with regards to x-compose.el.
Jan> Due to to the way I got these messages the quotes won't be proberply
Jan> attributed.

Jan> I hope to make the case below why x-compose.el should be loaded upon
Jan> x-init. At least on non mule Emacsen like 19.16 and 20.x/latin1. 

Jan> A quick summary of the argument:
Jan>  -  x-compose just adds to some some keymaps. It doesn't take that
Jan>     much space and it does not break anything if your X doesn't
Jan>     generate  a Multi_Key or Dead_anyhting keysym.
Jan>  - loading it can be inhibited
Jan>  - It has its deficiencies but on none mule Emacsen there isn't any
Jan>    alternative
Jan>  - autoloading doesn't work and is probably silly anyway because there
Jan>    so many keys involved.

>> > I vote AGAINST making x-compose.el the standard behavior in 19.16:
>> > - key composition capability may (should?) already be provided by Xlib.

Jan> However on quite a number (this is THE faq in comp.emacs.xemacs) of
Jan> system it doesn't. Note that on some installations XEmacs is the
Jan> _only_ application where you cannot type a tilde because it gets
Jan> dead_tilde, but where standard Emacs and other X applications do work.

>> > - x-compose.el implementation is not yet stable.

Jan> x-compose.el has been upgraded to use function-key-map and I have
Jan> added a few keysyms. If anything it was too stable before.  

>> If Xlib does compose processing, then loading x-compose.el will have
>> no effect -- because if Xlib does compose processing, Emacs will never
>> see the Multi_key keysym at all.

Jan> So it doesn't hurt.

>> If XFree86 does not work this way, it's likely a bug, since the X
>> documentation implies this is the way it should work.  It should have
>> also worked in Solaris 2.5 (X11R5-based), but did not, due to a bug.

Jan> Which means there must be a work-around. Solaris 2.5.x will be around
Jan> for some time to come.... So will the various configuration of XFree86
Jan> and AIX.

>>> >> The XEmacs key remapping design is not yet completely satisfactory.
>> 
jwz> Why?
>> 
>> There are 3 key-remapping mechanisms:

Jan> Note that biggest problem with the current remapping and x-compose.el
Jan> is that it is highly nontrivial to also handle modifiers correctly.
Jan> Although with x-compose.el <dead_tilde SPC> becomes '~' <control
Jan> dead_tilde SPC> does NOT become 'C-~' etc.  (Does xlib based compose
Jan> processing handle this correctly?) 

>> Right. x-compose.el should at least be wrapped within 
>> (x-keysym-on-keyboard-p "Multi_key")
>> I'll implement this change for the next beta.

Jan> Remember to put the wrapper only around the multi_key part!
Jan> X-compose.el also supports dead keys!

>> OK. The right way is to autoload everything in x-compose.el whenever a 
>> Multi_key event arrives.

Jan> That would be if Multi_Key support were the only thing it did (or if
Jan> dead keys had consistent namings). However currently x-compose.el
Jan> supports about 60 diffferent dead_key keysims.

Jan> Do 61 autoload cookies really occuppy much less space than the current
Jan> keymaps?

Jan> Jan
 

