From xemacs-m  Tue Jun 10 17:57:58 1997
Received: from CNRI.Reston.VA.US (CNRI.Reston.VA.US [132.151.1.1])
	by xemacs.org (8.8.5/8.8.5) with SMTP id RAA04621
	for <xemacs-beta@xemacs.org>; Tue, 10 Jun 1997 17:57:58 -0500 (CDT)
Received: from newcnri.cnri.reston.va.us by CNRI.Reston.VA.US id aa12996;
          10 Jun 97 18:59 EDT
Received: from anthem.CNRI.Reston.Va.US by newcnri.CNRI.Reston.Va.US (SMI-8.6/SMI-SVR4)
	id SAA06562; Tue, 10 Jun 1997 18:59:39 -0400
Received: by anthem.CNRI.Reston.Va.US (SMI-8.6/SMI-SVR4)
	id SAA26565; Tue, 10 Jun 1997 18:58:57 -0400
Date: Tue, 10 Jun 1997 18:58:57 -0400
Message-Id: <199706102258.SAA26565@anthem.CNRI.Reston.Va.US>
From: "Barry A. Warsaw" <bwarsaw@CNRI.Reston.VA.US>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
To: "Gary D. Foster" <Gary.Foster@corp.sun.com>
Cc: Hrvoje Niksic <hniksic@srce.hr>,
        XEmacs Developers <xemacs-beta@xemacs.org>
Subject: BackSpace and Delete -- am I getting it? ;-)
References: <bcipvu2pbof.fsf@corp.Sun.COM>
	<kiglo4qjjgt.fsf@jagor.srce.hr>
	<bciiuzuqjae.fsf@corp.Sun.COM>
X-Mailer: VM 6.32 under 20.3 XEmacs Lucid (beta4)
Reply-To: CCMODE Maintainer <cc-mode-help@python.org>
X-Attribution: BAW
X-Oblique-Strategy: Discover the recipes you are using and abandon them
X-Url: http://www.python.org/~bwarsaw


I've spent the last hour or so reading most of the messages that have
been posted on this subject, played with XEmacs 20.3b4 under both X
and tty (xterm), mucked with my XTerm translations, perused events.c,
and generally learned much more about all this crud than I ever wanted 
;-).  Let me expose how little I really understand (or how long it
took my groggy grey matter to get here)!

It seems to me there are bunch of issues being mixed up, which isn't
surprising to me since this is almost always the case when threads
like this never die.

One issue is what read-key-sequence returns when a user types a
physical key on their physical keyboard.  Forget for the moment all
the myriad intermediates, such as XTerm translations, xmodmap'ings,
function-key-map, etc.  I hit a key, and read-key-sequence returns
some XEmacs-ish event.  E.g. I hit my big key labeled "Backspace" and
r-k-s returns

    [#<keypress-event backspace>]

E.g. I hit my small key to the right of Enter, labeled "Delete" and
r-k-s returns

    [#<keypress-event delete>]

Diggit.  Right now I'm primarily concerned with The Right Thing To Do
For CC Mode.  Currently I have this binding:

      (define-key c-mode-base-map "\177"      'c-electric-delete)

Now, the part that's been tripping me up is that <big-test-mode>
in XEmacs 19, "\177" is the way to spell BOTH keypress-events
backspace AND delete, *but* in XEmacs 20, this spells ONLY
keypress-event delete </big-test-mode>.  I think this is why Gary's
cc-mode.el patch confused me so much; I couldn't see how
c-electric-delete could possibly differentiate between backspace and
delete events, and the story is, under XEmacs 20 *it doesn't*.

In fact, in a 20.3b4 C mode buffer, C-h c <Key-Labeled-Backspace>
returns
==> BS runs the command delete-backward-char.

while C-h c <Key-Labeled-Delete> returns
==> DEL runs the command c-electric-delete

(Which isn't right).  I think this tells me what I need to know.  Here
is how I want CC Mode to behave:

#<keypress-event backspace> should always delete in the backwards
direction, hungrily when c-hungry-delete-key is t, or by calling
c-delete-function when c-hungry-delete-key is nil.

#<keypress-event delete> should delete in the forward or backward
direction, depending on the value of delete-erases-forward.  Now
whether this will optionally delete hungrily in the forward direction
is up in the air.  It currently does not, but it wouldn't be hard to
add.  I'm not sure such a feature is very useful (I've personally
never wanted it).

If I do add this feature, then I need to add a new function called
c-electric-backspace and variable c-backspace-function, which have the 
current semantics and values.  Then I change c-electric-delete to do
hungry optional-forward-direction deletion and set c-delete-function
to 'backspace-or-delete.

But my inclination is to not add this feature, and only change CC Mode
so that it does *not* bind "\177" at all (which should leave
#<keypress-event delete> running backspace-or-delete).  But I should
bind [backspace] to c-electric-delete as so:

  (define-key c-mode-base-map [backspace]      'c-electric-delete)

Oh dang, it occurs to me that if delete-erases-forward is nil, then
#<keypress-event delete> *should* hungrily delete backwards, so maybe
I have to add all that machinery anyway. ;-/

The tricky bit is that the spelling "\177" means different things in
XEmacs 19 and 20 (I haven't even tried Emacs 19.34 and decendents!),
and may even mean yet another thing in later 20.3 betas (?)  so how to
handle this?  Maybe I don't and it doesn't really matter because if I
only bind [backspace] to 'c-electric-delete, then in XEmacs 19,
#<keypress-event delete> will get bound to delete-backward-char, and
users can add the [delete] binding if they want.  Let's not even talk
about Emacs 18, which I don't support and don't have, but seem to
remember this spelling was relevent for.

That's my take on the matter.  Please show me where I'm still
confused.  My brain is mush and I have band practice.  I don't even
want to talk about what happens on the far side of read-key-sequence
(yet ;-).

-Barry

