From xemacs-m  Tue Jun  3 12:03:38 1997
Received: from jagor.srce.hr (hniksic@jagor.srce.hr [161.53.2.130])
	by xemacs.org (8.8.5/8.8.5) with ESMTP id MAA22633
	for <xemacs-beta@xemacs.org>; Tue, 3 Jun 1997 12:03:36 -0500 (CDT)
Received: (from hniksic@localhost)
          by jagor.srce.hr (8.8.5/8.8.4)
	  id TAA26356; Tue, 3 Jun 1997 19:03:26 +0200 (MET DST)
To: Gary.Foster@Corp.Sun.COM (Gary D. Foster)
Cc: XEmacs Developers <xemacs-beta@xemacs.org>
Subject: Re: tty-erase-char
References: <kigiuzv97u6.fsf_-_@jagor.srce.hr> <bcik9kbdcg8.fsf@corp.Sun.COM>
X-Attribution: Hrv
X-Face: Mie8:rOV<\c/~z{s.X4A{!?vY7{drJ([U]0O=W/<W*SMo/Mv:58:*_y~ki>xDi&N7XG
        KV^$k0m3Oe/)'e%3=$PCR&3ITUXH,cK>]bci&<qQ>Ff%x_>1`T(+M2Gg/fgndU%k*ft
        [(7._6e0n-V%|%'[c|q:;}td$#INd+;?!-V=c8Pqf}3J
From: Hrvoje Niksic <hniksic@srce.hr>
Date: 03 Jun 1997 19:03:25 +0200
In-Reply-To: Gary.Foster@Corp.Sun.COM's message of 03 Jun 1997 06:48:39 -0700
Message-ID: <kigiuzvd3fm.fsf@jagor.srce.hr>
Lines: 100
X-Mailer: Gnus v5.4.52/XEmacs 20.2

Gary.Foster@Corp.Sun.COM (Gary D. Foster) writes:

> > If there are no cries against, I volunteer to implement this --
> > only the value will be console-local.
> I think this is actually pretty cool.  Should make fixing the other
> stuff a lot easier.  I say "Go fer it, d00d".

Y0 MAN!  Peace and all.

A patch is worth a thousand words.

PATCH == Please Accept This Clever Hack.

A patch in the hand worth two in the bush.

An undertested patch is better than an untested patch.

Jokes aside, the patch is very simple, and I think it's correct.  I've 
tested it with MULE only, but it should work in a non-mule
environment.

There is a new console-local variable `tty-erase-char' to show the
STTY setting for ERASE.  For non-TTY consoles, or the consoles on
which the data was not found, it is set to nil.  Otherwise, it is a
char.

It should make life easier to the implementors of C-h vs. C-? garbage.

An implementation detail: this setting may be better off to
CONSOLE_TTY_DATA slots, but I'm not sure how to export it to Lisp in
that case.  We may even have both a representation in conslots and in
data structure, but it looked like an overkill.  Better to just
initialize one value.

--- src/console.c.orig	Tue Jun  3 17:22:46 1997
+++ src/console.c	Tue Jun  3 18:48:01 1997
@@ -1284,6 +1284,7 @@
     console_local_flags.default_minibuffer_frame = always_local_resettable;
     console_local_flags.overriding_terminal_local_map =
       always_local_resettable;
+    console_local_flags.tty_erase_char = always_local_resettable;
     
     console_local_flags.function_key_map = make_int (1);
     
@@ -1318,6 +1319,14 @@
 \[#<keypress-event control-X> #<keypress-event f1>].  If [f1]
 were a prefix key, typing `ESC O P x' would return
 \[#<keypress-event f1> #<keypress-event x>].
+*/ );
+
+  /* ### Should this somehow go to TTY data?  How do we make it
+     accessible from Lisp, then?  */
+  DEFVAR_CONSOLE_LOCAL ("tty-erase-char", tty_erase_char /*
+The ERASE character as set by the user with stty.
+When this value cannot be determined or would be meaningless (on non-TTY
+consoles, for example), it is set to nil.
 */ );
 
   /* While this should be CONST it can't be because some things
--- src/conslots.h.orig	Tue Jun  3 17:30:14 1997
+++ src/conslots.h	Tue Jun  3 17:33:43 1997
@@ -81,6 +81,9 @@
     /* Last anonymous kbd macro defined.  */
     MARKED_SLOT (last_kbd_macro);
 
+    /* ERASE character from stty settings.  */
+    MARKED_SLOT (tty_erase_char);
+
     /* Minibufferless frames on this console use this frame's minibuffer.  */
     MARKED_SLOT (default_minibuffer_frame);
 
--- src/sysdep.c.orig	Tue Jun  3 17:34:12 1997
+++ src/sysdep.c	Tue Jun  3 17:42:57 1997
@@ -1505,7 +1505,11 @@
   EMACS_GET_TTY (input_fd, &CONSOLE_TTY_DATA (con)->old_tty);
   tty = CONSOLE_TTY_DATA (con)->old_tty;
 
+  con->tty_erase_char = Qnil;
+
 #if defined (HAVE_TERMIO) || defined (HAVE_TERMIOS)
+  /* after all those years... */
+  con->tty_erase_char = make_char (tty.main.c_cc[VERASE]);
 #ifdef DGUX
   /* This allows meta to be sent on 8th bit.  */
   tty.main.c_iflag &= ~INPCK;	/* don't check input for parity */
@@ -1620,6 +1624,7 @@
 #endif /* AIX */
 #else /* if not HAVE_TERMIO */
 #ifndef MSDOS
+  con->tty_erase_char = make_char (tty.main.sg_erase);
   tty.main.sg_flags &= ~(ECHO | CRMOD | XTABS);
   if (TTY_FLAGS (con).meta_key)
     tty.main.sg_flags |= ANYP;


-- 
Hrvoje Niksic <hniksic@srce.hr> | Student at FER Zagreb, Croatia
--------------------------------+--------------------------------
"Silence!" cries Freydag. "I did not call thee in for a consultation!" 
"They are my innards! I will not have them misread by a poseur!"

