From xemacs-m  Fri May 16 20:03:14 1997
Received: from cerise.sensei.co.uk (glynn@muvies.demon.co.uk [158.152.66.14])
	by xemacs.org (8.8.5/8.8.5) with ESMTP id UAA25235
	for <xemacs-beta@xemacs.org>; Fri, 16 May 1997 20:03:11 -0500 (CDT)
Received: (from glynn@localhost) by cerise.sensei.co.uk (8.8.2/8.8.2) id CAA08601; Sat, 17 May 1997 02:01:43 +0100
Date: Sat, 17 May 1997 02:01:43 +0100
Message-Id: <199705170101.CAA08601@cerise.sensei.co.uk>
From: Glynn Clements <glynn@sensei.co.uk>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
To: Gary.Foster@Corp.Sun.COM (Gary D. Foster)
Cc: Hrvoje Niksic <hniksic@srce.hr>,
        XEmacs Developers <xemacs-beta@xemacs.org>
Subject: Re: DEL patch, as promised.
In-Reply-To: <bci67wj2dqa.fsf@corp.Sun.COM>
References: <bciaflv2kuv.fsf@corp.Sun.COM>
	<kigiv0jrthb.fsf@jagor.srce.hr>
	<bci67wj2dqa.fsf@corp.Sun.COM>
X-Mailer: VM 6.31 under 20.2 XEmacs Lucid


Gary D. Foster wrote:

> If you WANT to write your own electric-delete function, you go ahead
> and do so just as you normally would have done before.  NOTHING
> changes at all.  The only thing that changes is that instead of doing
> a "define-key" or whatever to bind it, you use the hook to bind it.

Err, it would be nice to stick with define-key, if at all possible.

> If you DON'T want to write your own delete function, you leave it the
> hell alone.  It's amazing how many packages contained:
> 
> (define-key foo-mode-map "\177" backward-delete-char-untabify)

So much for portability.

> > I think I prefer the translation hacks.  On the other hand, I may have
> > somehow misunderstood your change.
> 
> Well, be that as it may... the translation hacks are just
> that... hacks.  It's time to stop hacking at it and fix it for real.

Amen. Amen. Amen. Amen.

> Please *try* out what I've posted and give it a good shakedown before
> passing judgement.  I've given it a lot of thought and a lot of
> consideration and I'd take it very kindly if you'd at least give it a
> good solid perusal and give me real, honest feedback.  It's time we
> separated the emotions from the issues and got on with fixing it.

I tried the delete patch; it worked until I loaded a C file, then
stopped working in all modes. Up until that point it was fine though.

> Bottom line is that I *believe* (although I may be wrong) that you
> could apply the patch and continue to do business as usual and not
> notice a single thing different about any behaviors on *your* setup,
> while someone who chooses differently can simply enable the option
> from the tool bar and also be satisfied.  If that's *not* the case, I
> will gladly accept all feedback and jump up and down on the code until
> that *IS* the case.

One idea that occurred to me is to create (virtual?) keysyms for
`forward-delete' and `backward-delete', and to systematically
eliminate all references to `delete' or `backspace'.

`Delete' is just too ambiguous a term; it could mean the key with
`Delete' printed on it, the key which generates DEL (which is the <-
key on my system), or something else altogether.

`Backspace' is at least more clear; anyone binding a forward-deletion
command to a keysym called `backspace' is probably going to bind
`kill-emacs' to the spacebar. However you don't seem to be able to
generate the `backspace' keysym on a tty at present.

Also in an attempt to figure out why I can't bind BS and Delete
seperately on a tty, I stumbled across the `character_to_event'
function in events.c. This contains the following snippet:

  if (c < ' ') c += '@', m |= MOD_CONTROL;
  if (m & MOD_CONTROL)
    {
      switch (c)
	{
	case 'I': k = QKtab;	  m &= ~MOD_CONTROL; break;
	case 'J': k = QKlinefeed; m &= ~MOD_CONTROL; break;
	case 'M': k = QKreturn;	  m &= ~MOD_CONTROL; break;
	case '[': k = QKescape;	  m &= ~MOD_CONTROL; break;
# if 0
	  /* This is probably too controversial... */
	case 'H': k = QKbackspace; m &= ~MOD_CONTROL; break;
# endif
	}
      if (c >= 'A' && c <= 'Z') c -= 'A'-'a';
    }
  else if (c == 127)
    k = QKdelete;

Which is probably why XEmacs on a tty can't distinguish between the
backspace key and the delete key, once the lisp/term/whatever.el has
translated \e[3~ into `delete'.

I would argue that:

1. the 127 in the above code should be replaced with with the tty's
VERASE character, obtained via tcgetattr(2).

2. the VERASE character should not be translated into delete (which is
mapped to a completely different key by just about everything in
lisp/term/*.el), but into backspace.

3. functions which do backwards deletion should be bound to the
whatever the VERASE character happens to be.

4. the H case should be permanently removed.

It then remains to fix everything that depends on the existing
behaviour. If I had a clue what needed fixing, I'd do it myself.

I was also thinking that it might be a better idea to replace this
code with entries in `function-key-map', rather than being hardwired
into the binary.

-- 
Glynn Clements <glynn@sensei.co.uk>

