[comp.emacs] Passing ^S, was "What's wrong with flow control?"

quiroz@rochester.ARPA (Cesar Quiroz) (12/03/86)

Expires:

Sender:

Followup-To:



    In the recent round of derogatory comments about flow-control
mechanisms, rwells@PROPHET hinted to the possibility of hiding the
ugliness by remapping your physical keyboard, so you type CTRL-S,
but the terminal sends out something else.  Later, gnu@hoptoad took
exception to the usefulness of the approach, by claiming that not
all the associations of character and function are in the keymaps (I
guess he is not referring to GNUemacs, although the search
characters are not in keymaps, but that is yet another issue).
References at the end.

    The point that needs to be stressed is that rwells's mechanism can
be complemented: your Emacs can read the "something else" as ^S
again.  It then avoids having to touch the keymaps (or the
assignments of special variables or anything hardwired in the code
itself).

    The proposed solution depends on your good luck to a certain
extent: it is not a cure to the problem, but just a possible
workaround.  I will summarize here one case I had to deal with, I
hope it will suggest others how to solve their particular problems.
Also, I will explain it from the viewpoint of GNUemacs, I assume
other Emacses have their own ways to cope with this.

    My horror story: I am typing this on a perfectly decent and
smart Guru terminal, connected to a perfectly smart Vax over a
totally broken switching mechanism.  As I have access to other
terminals, it is not acceptable for me to remember that in this
particular Guru I have to type something different from ^S.

    So I do the following: On login, if I am coming from a dialup at
9600, the .login asks me if this is a Guru.  If so, it downloads
escape sequences that do all sorts of magic, in particular they
remap CTRL-S to transmit ^].  Then, I fix the
keyboard-translate-table (my .emacs asks for confirmation) so that
^] will be seen by the rest of Emacs as ^S.  In this way, I don't
have to change any keybindings (whether keymaps or not) nor I have
to reprogram myself to type strange things in different terminals.
The cost is the loss of ^] (big deal) and the need to confirm things
to my .login and my .emacs.

 keyboard -> data-switching -> kbd-xlate-table -> keymaps -> Real Emacs
CTRL-S  ^]  ^]           ^]    ^]           ^S     ... happinesss

    I hope this will be enough to convey the idea.  More details on
request, of course.

=Cesar

From article <1385@hoptoad.uucp> (gnu@hoptoad.uucp (John Gilmore)):
%In article <8612020023.AA05566@ucbvax.Berkeley.EDU>, rwells@PROPHET.BBN.COM writes:
%>               Your terminal or terminal emulator could have a mode in
%> which it translates keyboard entry of Control-S and Control-Q into
%> something else - either multi-character escape sequences or other
%> control characters.  You then initialize emacs to recognize these
%> translated sequences as equivalent to real ^S/^Q...
%
%Therein lies a problem.  Only a few of the Emacs dependencies on
%^S and ^Q are in the nice keymaps; the rest are hardwired into Lisp
%or MockLisp code.  E.g. in incremental search in Gosmacs, the mlisp
%macro reads the keyboard, checks for ^R or ^S (to change the direction
%of search) and then does the search for that character.  Changing
%^S to M-S in the keymaps won't make M-S work properly inside incr-search.
%Quote characters like ^Q tend to be embedded even worse.

-- 
Cesar Augusto  Quiroz Gonzalez
Department of Computer Science     {allegra|seismo}!rochester!quiroz
University of Rochester            or
Rochester,  NY 14627               quiroz@ROCHESTER

jr@cc5.bbn.com (John Robinson) (12/03/86)

>> If so, it downloads
>> escape sequences that do all sorts of magic, in particular they
>> remap CTRL-S to transmit ^].  Then, I fix the
>> keyboard-translate-table (my .emacs asks for confirmation) so that
>> ^] will be seen by the rest of Emacs as ^S.  In this way, I don't
>> have to change any keybindings (whether keymaps or not) nor I have
>> to reprogram myself to type strange things in different terminals.
>> The cost is the loss of ^] (big deal) and the need to confirm things
>> to my .login and my .emacs.

This works fine if the number of characters to avoid is small.
Ultimately, however, your character set shrinks so that some control
key you are fond of using has to become unavailable.

Robert Wells' suggestion to use multi-character substitutions would
solve this, but for the purposes of isearch and friends, you would
want the inversion to happen through the keyboard translate table,
which currently is just a one-for-one character substitution.  Has
anyone tried to make this a general keymap (I know there's a
performance hit here probably)?

Really you want the translation to happen in Unix's terminal driver,
of course.  Here we are really talking about a protocol between the
two ends of the terminal "line" (including port selectors, "clever"
modems and whatever).  The proper place for the support of this is at
the process serving that line.  So this suggests the need for a better
"line discipline" variant that supports the keyboard remapping.  With
this, emacs need never know.

/jr