GNU Info

Info Node: (elisp)Flow Control

(elisp)Flow Control


Next: Batch Mode Prev: Special Keysyms Up: System Interface
Enter node , (file) or (file)node

Flow Control
============

   This section attempts to answer the question "Why does Emacs use
flow-control characters in its command character set?"  For a second
view on this issue, read the comments on flow control in the
`emacs/INSTALL' file from the distribution; for help with Termcap
entries and DEC terminal concentrators, see `emacs/etc/TERMS'.

   At one time, most terminals did not need flow control, and none used
`C-s' and `C-q' for flow control.  Therefore, the choice of `C-s' and
`C-q' as command characters for searching and quoting was natural and
uncontroversial.  With so many commands needing key assignments, of
course we assigned meanings to nearly all ASCII control characters.

   Later, some terminals were introduced which required these characters
for flow control.  They were not very good terminals for full-screen
editing, so Emacs maintainers ignored them.  In later years, flow
control with `C-s' and `C-q' became widespread among terminals, but by
this time it was usually an option.  And the majority of Emacs users,
who can turn flow control off, did not want to switch to less mnemonic
key bindings for the sake of flow control.

   So which usage is "right"--Emacs's or that of some terminal and
concentrator manufacturers?  This question has no simple answer.

   One reason why we are reluctant to cater to the problems caused by
`C-s' and `C-q' is that they are gratuitous.  There are other
techniques (albeit less common in practice) for flow control that
preserve transparency of the character stream.  Note also that their use
for flow control is not an official standard.  Interestingly, on the
model 33 teletype with a paper tape punch (around 1970), `C-s' and
`C-q' were sent by the computer to turn the punch on and off!

   As window systems and PC terminal emulators replace character-only
terminals, the flow control problem is gradually disappearing.  For the
mean time, Emacs provides a convenient way of enabling flow control if
you want it: call the function `enable-flow-control'.

 - Command: enable-flow-control
     This function enables use of `C-s' and `C-q' for output flow
     control, and provides the characters `C-\' and `C-^' as aliases
     for them using `keyboard-translate-table' (Note: Translating
     Input).

   You can use the function `enable-flow-control-on' in your init file
to enable flow control automatically on certain terminal types.

 - Function: enable-flow-control-on &rest termtypes
     This function enables flow control, and the aliases `C-\' and
     `C-^', if the terminal type is one of TERMTYPES.  For example:

          (enable-flow-control-on "vt200" "vt300" "vt101" "vt131")

   Here is how `enable-flow-control' does its job:

  1. It sets CBREAK mode for terminal input, and tells the operating
     system to handle flow control, with `(set-input-mode nil t)'.

  2. It sets up `keyboard-translate-table' to translate `C-\' and `C-^'
     into `C-s' and `C-q'.  Except at its very lowest level, Emacs
     never knows that the characters typed were anything but `C-s' and
     `C-q', so you can in effect type them as `C-\' and `C-^' even when
     they are input for other commands.  Note: Translating Input.

   If the terminal is the source of the flow control characters, then
once you enable kernel flow control handling, you probably can make do
with less padding than normal for that terminal.  You can reduce the
amount of padding by customizing the Termcap entry.  You can also
reduce it by setting `baud-rate' to a smaller value so that Emacs uses
a smaller speed when calculating the padding needed.  Note: Terminal
Output.


automatically generated by info2www version 1.2.2.9