annotate lisp/flow-ctrl.el @ 793:6fb68a1460a6

*** empty log message ***
author Eric S. Raymond <esr@snark.thyrsus.com>
date Thu, 16 Jul 1992 07:28:05 +0000
parents 45d748a65f24
children e694e0879463
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
793
6fb68a1460a6 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 792
diff changeset
1 ;;; flow-ctrl.el --- help for lusers on cu(1) or ttys with wired-in ^S/^Q flow control
6fb68a1460a6 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 792
diff changeset
2
6fb68a1460a6 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 792
diff changeset
3 ;; Author Kevin Gallagher
6fb68a1460a6 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 792
diff changeset
4 ;; Maintainer: FSF
6fb68a1460a6 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 792
diff changeset
5 ;; Last-Modified: 03 Jun 1992
6fb68a1460a6 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 792
diff changeset
6 ;; Adapted-By: ESR
660
08eb386dd0f3 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 584
diff changeset
7
541
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
8 ;;; Copyright (C) 1990 Free Software Foundation, Inc.
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
9 ;;; Copyright (C) 1991 Kevin Gallagher
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10 ;;;
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
11 ;;; GNU Emacs is distributed in the hope that it will be useful, but
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
12 ;;; WITHOUT ANY WARRANTY. No author or distributor accepts
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
13 ;;; RESPONSIBILITY TO anyone for the consequences of using it or for
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
14 ;;; whether it serves any particular purpose or works at all, unless
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
15 ;;; he says so in writing. Refer to the GNU Emacs General Public
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
16 ;;; License for full details.
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
17 ;;;
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
18 ;;; Everyone is granted permission to copy, modify and redistribute
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
19 ;;; GNU Emacs, but only under the conditions described in the GNU
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
20 ;;; Emacs General Public License. A copy of this license is supposed
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
21 ;;; to have been given to you along with GNU Emacs so you can know
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
22 ;;; your rights and responsibilities. It should be in a file named
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
23 ;;; COPYING. Among other things, the Copyright notice and this notice
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
24 ;;; must be preserved on all copies.
793
6fb68a1460a6 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 792
diff changeset
25
6fb68a1460a6 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 792
diff changeset
26 ;;; Commentary:
541
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
27
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
28 ;;;; Terminals that use XON/XOFF flow control can cause problems with
792
45d748a65f24 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 677
diff changeset
29 ;;;; GNU Emacs users. This file contains Emacs Lisp code that makes it
541
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
30 ;;;; easy for a user to deal with this problem, when using such a
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
31 ;;;; terminal.
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
32 ;;;;
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
33 ;;;; To invoke these adjustments, a user need only invoke the function
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
34 ;;;; evade-flow-control-on with a list of terminal types in his/her own
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
35 ;;;; .emacs file. As arguments, give it the names of one or more terminal
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
36 ;;;; types in use by that user which require flow control adjustments.
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
37 ;;;; Here's an example:
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
38 ;;;;
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
39 ;;;; (evade-flow-control-on "vt200" "vt300" "vt101" "vt131")
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
40
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
41 ;;; Portability note: This uses (getenv "TERM"), and therefore probably
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
42 ;;; won't work outside of UNIX-like environments.
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
43
793
6fb68a1460a6 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 792
diff changeset
44 ;;; Code:
6fb68a1460a6 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 792
diff changeset
45
541
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
46 (defun evade-flow-control ()
669
4c64c671426f *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 660
diff changeset
47 "Enable use of flow control; let user type C-s as C-\ and C-q as C-^."
541
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
48 (interactive)
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
49 ;; Tell emacs to pass C-s and C-q to OS.
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
50 (set-input-mode nil t)
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
51 ;; Initialize translate table, saving previous mappings, if any.
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
52 (let ((the-table (make-string 128 0)))
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
53 (let ((i 0)
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
54 (j (length keyboard-translate-table)))
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
55 (while (< i j)
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
56 (aset the-table i (elt keyboard-translate-table i))
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
57 (setq i (1+ i)))
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
58 (while (< i 128)
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
59 (aset the-table i i)
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
60 (setq i (1+ i))))
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
61 (setq keyboard-translate-table the-table))
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
62 ;; Swap C-s and C-\
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
63 (aset keyboard-translate-table ?\034 ?\^s)
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
64 (aset keyboard-translate-table ?\^s ?\034)
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
65 ;; Swap C-q and C-^
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
66 (aset keyboard-translate-table ?\036 ?\^q)
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
67 (aset keyboard-translate-table ?\^q ?\036)
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
68 (message (concat
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
69 "XON/XOFF adjustment for "
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
70 (getenv "TERM")
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
71 ": use C-\\ for C-s and use C-^ for C-q."))
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
72 (sleep-for 2)) ; Give user a chance to see message.
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
73
669
4c64c671426f *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 660
diff changeset
74 (defun evade-flow-control-memstr= (e s)
541
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
75 (cond ((null s) nil)
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
76 ((string= e (car s)) t)
669
4c64c671426f *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 660
diff changeset
77 (t (evade-flow-control-memstr= e (cdr s)))))
541
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
78
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
79 ;;;###autoload
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
80 (defun evade-flow-control-on (&rest losing-terminal-types)
669
4c64c671426f *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 660
diff changeset
81 "Enable flow control if using one of a specified set of terminal types.
677
7a9b4ea68565 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 669
diff changeset
82 Use `(evade-flow-control-on \"vt100\" \"h19\")' to enable flow control
669
4c64c671426f *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 660
diff changeset
83 on VT-100 and H19 terminals. When flow control is enabled,
677
7a9b4ea68565 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 669
diff changeset
84 you must type C-\\ to get the effect of a C-s, and type C-^
669
4c64c671426f *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 660
diff changeset
85 to get the effect of a C-q."
541
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
86 (let ((term (getenv "TERM"))
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
87 hyphend)
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
88 ;; Strip off hyphen and what follows
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
89 (while (setq hyphend (string-match "[-_][^-_]+$" term))
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
90 (setq term (substring term 0 hyphend)))
669
4c64c671426f *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 660
diff changeset
91 (and (evade-flow-control-memstr= term losing-terminal-types) (evade-flow-control)))
541
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
92 )
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
93
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
94 (provide 'flow-ctrl)
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
95
660
08eb386dd0f3 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 584
diff changeset
96 ;;; flow-ctrl.el ends here