[net.emacs] Flow Control problems in GNU Emacs

christer@kuling.UUCP (04/17/86)

In article (>) <8604120758.AA17987@ucbvax.berkeley.edu> of Wed, 16-Apr-86 
00:32:28 GMT Skip Montanaro (montnaro%chenengo.tcpip@ge-crd.arpa.UUCP) writes:
>In article (>>) <2498@utcsri.UUCP> Gregory Smith responds to
><2216@watdcsu.UUCP> (>>>) shen5@watdcsu.UUCP (B. Lindsay Patten)

>>>Can anyone tell me how to set things up so that emacs will not interpret
>>>^S/^Q (XON/XOFF) as commands?  Of course I'ld be just as happy to reset
>>>these to something else if that would be easier.

Both Skip Montanaro and Gregory Smith suggests some ways to reduce the use of
^S/^Q for flowcontrol. If this doesn't work Skip Montanaro suggests this:

>The GNU functions to place in your ~/.emacs file are:
>
>(global-unset-key "\^S")
>(global-unset-key "\^Q")
>(global-set-key "\es" "isearch-forward")
>(global-set-key "\eq" "quoted-insert")

No, that's not the right way do do this. You can still get a ^S after typing a
prefixcharacter, it will not make emacs use ^S and ^Q for flowcontrol, and
this willl make emacs send a bell (^G) when it recieves ^S or ^Q.

You could define a function do-nothing as (defun do-nothing () (interactive))
and bind ^S and ^Q to it. You'll get emacs using flow-controll with the
function set-input-mode. 

The following is a definition of a xon-xoff-mode, that uses the
keyboard-translate-table. When the user types a character it will be
applied to the translation table before it is processed in any other way.
If you want to use ^s and ^q for flow-control, then you should define
the replacements, using the translate-table.

I have taken parts of this from a usenet text about 6 months ago.
---------------------------------Cut here---------------------------------
;kuling:/usr/alla/christer/emacs/xonxoff.el, Thu Apr 10 20:50:38 1986,
; Edit by: Christer Johansson (christer@kuling)
; Changed DOCSTRING of Xon-xoff-mode. Removed -*- line. 
;Edited: Tue Nov 19 1985 by christer@kuling (Christer Johansson)
; /usr/alla/christer/emacs/xonxoff.el Added variables C-{S,Q}-Replacement.
;Edited: Mon Nov 11 1985 by christer@kuling (Christer Johansson)
; /usr/alla/christer/emacs/xonxoff.el Works under ver. 16.60

;; Make the identity translation table.
(progn (setq keyboard-translate-table (make-string 128 0))
       (let ((i 0))
	 (while (< i 128)
	   (aset keyboard-translate-table i i)
	   (setq i (1+ i)))))

(defvar xon-xoff-mode t
  "Controls the xon-xoff mode.
If this variable is nil, xon-xoff-mode is off.")
       
(defun xon-xoff-mode (arg)
  "Xon-xoff mode's good if you want too use ^s and ^q for flow-control.
Turns Xon-xoff mode on if ARG > 0, off if ARG < 0.
With ARG = 0, Xon-xoff-mode toggles. 
If Xon-xoff-mode is on, all ^^ typed by the user will be translated to ^q
before they are interpreted in any way. Likewise ^\ will be translated to ^s.
If the options C-Q-Replacement and C-S-Replacement are set, there values will
be used instead of ^^ and ^\. ^q and ^s will be used for flow-controll in
xon-xoff-mode.
"
  (interactive "p")

  (setq xon-xoff-mode
	(if (and (zerop arg)
		 (boundp xon-xoff-mode))
	  (not xon-xoff-mode)
	  (> arg 0)))

  (set-input-mode nil xon-xoff-mode)

  (if xon-xoff-mode
      (progn (aset keyboard-translate-table
		   (if (boundp 'C-S-Replacement)
		       C-S-Replacement
		     ?\^\\)
		   ?\^s)
	     (aset keyboard-translate-table 
		   (if (boundp 'C-Q-Replacement)
		       C-Q-Replacement
		     ?\^^)
		   ?\^q))

    (aset keyboard-translate-table ?\^s ?\^s)
    (aset keyboard-translate-table ?\^q ?\^q)))

(xon-xoff-mode 1)
--------------------------------Cut here to--------------------------------
-- 
SMail: Christer Johansson  UUCP:  {seismo,seismo!mcvax}!enea!kuling!christer
       Sernandersv. 9:136  ARPA:  enea!kuling!christer@SEISMO.CSS.GOV
       S-752 63  Uppsala   Phone: Int. +46 - 18 46 31 54
           SWEDEN                 Nat. 018 - 46 31 54