[comp.emacs] Help wanted with vt102 to Sun4 dialup problem

lee@infotec.UUCP (Lee Van Dyke) (06/15/91)

Has anyone experienced problems with 18.57 when calling in
from a modem and loading the vt100.el file. I reset the 
terminal to vt100 after I unset the termcaps and when the
emacs screen comes up the I search: control q, .. keeps
magically appearing.


-- 
Lee Van Dyke              UUCP: ...sun!sunkist!infotec!lee
Infotec                                      or
Costa Mesa, CA                  ...zardoz!infotec!lee
(714) 241-8254

kgallagh@digi.lonestar.org (Kevin Gallagher) (06/17/91)

In article <814@infotec.UUCP> lee@infotec.UUCP () writes:
>Has anyone experienced problems with 18.57 when calling in
>from a modem and loading the vt100.el file. I reset the 
>terminal to vt100 after I unset the termcaps and when the
>emacs screen comes up the I search: control q, .. keeps
>magically appearing.

If you are using a genuine VT series terminal, then you have flow control
problems.  The VT terminal is issuing automatic XON/XOFF characters (C-s/C-q)
in an attempt to slow down the output from the host.

If you are using a VT100 emulator on a PC, most emulators let the modem
hardware handle flow control and don't themselves support Auto XON/XOFF.
If this is the case, then it is likely that something in between you and the
modem is using XON/XOFF flow control between it and the host.  If changing
this situation is beyond your control and influence, then the attached elisp
file, flow-control.el should help.

Read the file header for instructions on how to install and use it.

Good Luck!

==============================  CUT  HERE  =================================
;;; File:  flow-control.el, v 1.0
;;;
;;;               -------   -------------   ---------------------
;;;               F l o w   C o n t r o l   A d j u s t m e n t s
;;;               -------   -------------   ---------------------
;;;
;;;
;;; Copyright (C) 1990 Free Software Foundation, Inc.
;;; Copyright (C) 1991 Kevin Gallagher
;;;
;;; GNU Emacs is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY.  No author or distributor accepts
;;; RESPONSIBILITY TO anyone for the consequences of using it or for
;;; whether it serves any particular purpose or works at all, unless 
;;; he says so in writing.  Refer to the GNU Emacs General Public
;;; License for full details.
;;;
;;;  Send bug reports and suggestions for improvement to Kevin Gallagher
;;;  (kgallagh@digi.lonestar.org).
;;;
;;; Everyone is granted permission to copy, modify and redistribute
;;; GNU Emacs, but only under the conditions described in the GNU
;;; Emacs General Public License.  A copy of this license is supposed
;;; to have been given to you along with GNU Emacs so you can know
;;; your rights and responsibilities.  It should be in a file named
;;; COPYING.  Among other things, the Copyright notice and this notice
;;; must be preserved on all copies.
;;;

;;;; Terminals that use XON/XOFF flow control can cause problems with
;;;; GNU Emacs users.  This file contains elisp code that makes it
;;;; easy for a user to deal with this problem, when using such a
;;;; terminal. 
;;;; 
;;;; To make this facility available for use to all users, place this
;;;; file, flow-control.el, into your site's public emacs/lisp
;;;; directory and add the following command to your site's default.el
;;;; file: 
;;;; 
;;;;           (require 'flow-control)
;;;;      
;;;; To invoke these adjustments, a user need only define the varible
;;;; terminal-uses-flow-control-chars in his/her own .emacs file.  The
;;;; varible must contain a list of one or more terminal types in use
;;;; by that user which require flow control adjustments.  Here's an
;;;; example: 
;;;; 
;;;;           (setq terminal-uses-flow-control-chars 
;;;;                 '("vt200" "vt300" "vt101" "vt131"))

(if (boundp 'terminal-uses-flow-control-chars)
    (let ((term (getenv "TERM"))
	  hyphend)
      ;; Strip off hyphen and what follows
      (while (setq hyphend (string-match "[-_][^-_]+$" term))
	(setq term (substring term 0 hyphend)))
      (let ((len (length terminal-uses-flow-control-chars))
	    (idx 0)
	    (temp-term nil))
	(while (and (< idx len)
		    (not temp-term))
	  (if (string-equal term 
			    (nth idx terminal-uses-flow-control-chars))
              (progn
                (evade-flow-control)
                (setq temp-term term))
              (setq idx (1+ idx)))))))


;;;;
;;;; Evade Flow Control
;;;;

(defun evade-flow-control ()
  "Replace C-s with C-\ and C-q with C-^ and tell emacs to pass C-s
and C-q characters to OS."
  (interactive)
  ;; Tell emacs to pass C-s and C-q to OS.
  (set-input-mode nil t)
  ;; Initialize translate table.
  (let ((the-table (make-string 128 0)))
    (let ((i 0))
      (while (< i 128)
        (aset the-table i i)
        (setq i (1+ i))))
    ;; Swap C-s and C-\
    (aset the-table ?\034 ?\^s)
    (aset the-table ?\^s ?\034)
    ;; Swap C-q and C-^
    (aset the-table ?\036 ?\^q)
    (aset the-table ?\^q ?\036)
    (setq keyboard-translate-table the-table))
  (message (concat 
	     "XON/XOFF adjustment for " 
	     (getenv "TERM") 
	     ":  use C-\\ for C-s  and  use C-^ for C-q."))
  (sleep-for 6)) ; Give user a chance to see message.

(provide 'flow-control)
-- 
----------------------------------------------------------------------------
Kevin Gallagher        kgallagh@digi.lonestar.org OR ...!uunet!digi!kgallagh
DSC Communications Corporation   Addr: MS 152, 1000 Coit Rd, Plano, TX 75075
----------------------------------------------------------------------------