annotate lisp/flow-ctrl.el @ 6518:07ecb7a5c916

(x_consider_frame_title, decode_mode_spec): Use assignment, not initialization.
author Karl Heuer <kwzh@gnu.org>
date Fri, 25 Mar 1994 00:41:29 +0000
parents 860d91d72063
children 3e1323443b1a
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
1848
94f7516ccdc1 Fix copyright notice.
Richard M. Stallman <rms@gnu.org>
parents: 856
diff changeset
3 ;;; Copyright (C) 1990, 1991 Free Software Foundation, Inc.
846
20674ae6bf52 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 844
diff changeset
4
793
6fb68a1460a6 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 792
diff changeset
5 ;; Author Kevin Gallagher
6fb68a1460a6 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 792
diff changeset
6 ;; Maintainer: FSF
6fb68a1460a6 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 792
diff changeset
7 ;; Adapted-By: ESR
811
e694e0879463 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 793
diff changeset
8 ;; Keywords: hardware
660
08eb386dd0f3 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 584
diff changeset
9
846
20674ae6bf52 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 844
diff changeset
10 ;;; This file is part of GNU Emacs.
541
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
11 ;;;
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
12 ;;; GNU Emacs is distributed in the hope that it will be useful, but
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
13 ;;; WITHOUT ANY WARRANTY. No author or distributor accepts
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
14 ;;; RESPONSIBILITY TO anyone for the consequences of using it or for
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
15 ;;; whether it serves any particular purpose or works at all, unless
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
16 ;;; he says so in writing. Refer to the GNU Emacs General Public
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
17 ;;; License for full details.
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
18 ;;;
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
19 ;;; Everyone is granted permission to copy, modify and redistribute
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
20 ;;; GNU Emacs, but only under the conditions described in the GNU
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
21 ;;; Emacs General Public License. A copy of this license is supposed
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
22 ;;; 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
23 ;;; your rights and responsibilities. It should be in a file named
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
24 ;;; COPYING. Among other things, the Copyright notice and this notice
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
25 ;;; must be preserved on all copies.
793
6fb68a1460a6 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 792
diff changeset
26
6fb68a1460a6 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 792
diff changeset
27 ;;; Commentary:
541
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
28
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
29 ;;;; 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
30 ;;;; GNU Emacs users. This file contains Emacs Lisp code that makes it
541
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
31 ;;;; easy for a user to deal with this problem, when using such a
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
32 ;;;; terminal.
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
33 ;;;;
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
34 ;;;; To invoke these adjustments, a user need only invoke the function
1855
80c1064620a8 (enable-flow-control...): Renamed from evade...
Richard M. Stallman <rms@gnu.org>
parents: 1848
diff changeset
35 ;;;; enable-flow-control-on with a list of terminal types in his/her own
541
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
36 ;;;; .emacs file. As arguments, give it the names of one or more terminal
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
37 ;;;; types in use by that user which require flow control adjustments.
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
38 ;;;; Here's an example:
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
39 ;;;;
1855
80c1064620a8 (enable-flow-control...): Renamed from evade...
Richard M. Stallman <rms@gnu.org>
parents: 1848
diff changeset
40 ;;;; (enable-flow-control-on "vt200" "vt300" "vt101" "vt131")
541
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
41
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
42 ;;; Portability note: This uses (getenv "TERM"), and therefore probably
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
43 ;;; won't work outside of UNIX-like environments.
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
44
793
6fb68a1460a6 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 792
diff changeset
45 ;;; Code:
6fb68a1460a6 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 792
diff changeset
46
5506
9b694015caec (enable-flow-control): Use prefix argument like minor modes.
Richard M. Stallman <rms@gnu.org>
parents: 3660
diff changeset
47 (defvar flow-control-c-s-replacement ?\034
9b694015caec (enable-flow-control): Use prefix argument like minor modes.
Richard M. Stallman <rms@gnu.org>
parents: 3660
diff changeset
48 "Character that replaces C-s, when flow control handling is enabled.")
9b694015caec (enable-flow-control): Use prefix argument like minor modes.
Richard M. Stallman <rms@gnu.org>
parents: 3660
diff changeset
49 (defvar flow-control-c-q-replacement ?\036
9b694015caec (enable-flow-control): Use prefix argument like minor modes.
Richard M. Stallman <rms@gnu.org>
parents: 3660
diff changeset
50 "Character that replaces C-q, when flow control handling is enabled.")
9b694015caec (enable-flow-control): Use prefix argument like minor modes.
Richard M. Stallman <rms@gnu.org>
parents: 3660
diff changeset
51
1855
80c1064620a8 (enable-flow-control...): Renamed from evade...
Richard M. Stallman <rms@gnu.org>
parents: 1848
diff changeset
52 ;;;###autoload
5506
9b694015caec (enable-flow-control): Use prefix argument like minor modes.
Richard M. Stallman <rms@gnu.org>
parents: 3660
diff changeset
53 (defun enable-flow-control (&optional argument)
9b694015caec (enable-flow-control): Use prefix argument like minor modes.
Richard M. Stallman <rms@gnu.org>
parents: 3660
diff changeset
54 "Toggle flow control handling.
9b694015caec (enable-flow-control): Use prefix argument like minor modes.
Richard M. Stallman <rms@gnu.org>
parents: 3660
diff changeset
55 When handling is enabled, user can type C-s as C-\\, and C-q as C-^.
9b694015caec (enable-flow-control): Use prefix argument like minor modes.
Richard M. Stallman <rms@gnu.org>
parents: 3660
diff changeset
56 With arg, enable flow control mode if arg is positive, otherwise disable."
9b694015caec (enable-flow-control): Use prefix argument like minor modes.
Richard M. Stallman <rms@gnu.org>
parents: 3660
diff changeset
57 (interactive "P")
9b694015caec (enable-flow-control): Use prefix argument like minor modes.
Richard M. Stallman <rms@gnu.org>
parents: 3660
diff changeset
58 (if (if argument
9b694015caec (enable-flow-control): Use prefix argument like minor modes.
Richard M. Stallman <rms@gnu.org>
parents: 3660
diff changeset
59 ;; Argument means enable if arg is positive.
9b694015caec (enable-flow-control): Use prefix argument like minor modes.
Richard M. Stallman <rms@gnu.org>
parents: 3660
diff changeset
60 (<= (prefix-numeric-value argument) 0)
9b694015caec (enable-flow-control): Use prefix argument like minor modes.
Richard M. Stallman <rms@gnu.org>
parents: 3660
diff changeset
61 ;; No arg means toggle.
9b694015caec (enable-flow-control): Use prefix argument like minor modes.
Richard M. Stallman <rms@gnu.org>
parents: 3660
diff changeset
62 (nth 1 (current-input-mode)))
9b694015caec (enable-flow-control): Use prefix argument like minor modes.
Richard M. Stallman <rms@gnu.org>
parents: 3660
diff changeset
63 (progn
9b694015caec (enable-flow-control): Use prefix argument like minor modes.
Richard M. Stallman <rms@gnu.org>
parents: 3660
diff changeset
64 ;; Turn flow control off, and stop exchanging chars.
9b694015caec (enable-flow-control): Use prefix argument like minor modes.
Richard M. Stallman <rms@gnu.org>
parents: 3660
diff changeset
65 (set-input-mode t nil (nth 2 (current-input-mode)))
9b694015caec (enable-flow-control): Use prefix argument like minor modes.
Richard M. Stallman <rms@gnu.org>
parents: 3660
diff changeset
66 (aset keyboard-translate-table flow-control-c-s-replacement nil)
9b694015caec (enable-flow-control): Use prefix argument like minor modes.
Richard M. Stallman <rms@gnu.org>
parents: 3660
diff changeset
67 (aset keyboard-translate-table ?\^s nil)
9b694015caec (enable-flow-control): Use prefix argument like minor modes.
Richard M. Stallman <rms@gnu.org>
parents: 3660
diff changeset
68 (aset keyboard-translate-table flow-control-c-q-replacement nil)
9b694015caec (enable-flow-control): Use prefix argument like minor modes.
Richard M. Stallman <rms@gnu.org>
parents: 3660
diff changeset
69 (aset keyboard-translate-table ?\^q nil))
9b694015caec (enable-flow-control): Use prefix argument like minor modes.
Richard M. Stallman <rms@gnu.org>
parents: 3660
diff changeset
70 ;; Turn flow control on.
9b694015caec (enable-flow-control): Use prefix argument like minor modes.
Richard M. Stallman <rms@gnu.org>
parents: 3660
diff changeset
71 ;; Tell emacs to pass C-s and C-q to OS.
9b694015caec (enable-flow-control): Use prefix argument like minor modes.
Richard M. Stallman <rms@gnu.org>
parents: 3660
diff changeset
72 (set-input-mode nil t (nth 2 (current-input-mode)))
9b694015caec (enable-flow-control): Use prefix argument like minor modes.
Richard M. Stallman <rms@gnu.org>
parents: 3660
diff changeset
73 ;; Initialize translate table, saving previous mappings, if any.
9b694015caec (enable-flow-control): Use prefix argument like minor modes.
Richard M. Stallman <rms@gnu.org>
parents: 3660
diff changeset
74 (let ((the-table (make-string 128 0)))
9b694015caec (enable-flow-control): Use prefix argument like minor modes.
Richard M. Stallman <rms@gnu.org>
parents: 3660
diff changeset
75 (let ((i 0)
9b694015caec (enable-flow-control): Use prefix argument like minor modes.
Richard M. Stallman <rms@gnu.org>
parents: 3660
diff changeset
76 (j (length keyboard-translate-table)))
9b694015caec (enable-flow-control): Use prefix argument like minor modes.
Richard M. Stallman <rms@gnu.org>
parents: 3660
diff changeset
77 (while (< i j)
9b694015caec (enable-flow-control): Use prefix argument like minor modes.
Richard M. Stallman <rms@gnu.org>
parents: 3660
diff changeset
78 (aset the-table i (elt keyboard-translate-table i))
9b694015caec (enable-flow-control): Use prefix argument like minor modes.
Richard M. Stallman <rms@gnu.org>
parents: 3660
diff changeset
79 (setq i (1+ i)))
9b694015caec (enable-flow-control): Use prefix argument like minor modes.
Richard M. Stallman <rms@gnu.org>
parents: 3660
diff changeset
80 (while (< i 128)
9b694015caec (enable-flow-control): Use prefix argument like minor modes.
Richard M. Stallman <rms@gnu.org>
parents: 3660
diff changeset
81 (aset the-table i i)
9b694015caec (enable-flow-control): Use prefix argument like minor modes.
Richard M. Stallman <rms@gnu.org>
parents: 3660
diff changeset
82 (setq i (1+ i))))
9b694015caec (enable-flow-control): Use prefix argument like minor modes.
Richard M. Stallman <rms@gnu.org>
parents: 3660
diff changeset
83 (setq keyboard-translate-table the-table))
9b694015caec (enable-flow-control): Use prefix argument like minor modes.
Richard M. Stallman <rms@gnu.org>
parents: 3660
diff changeset
84 ;; Swap C-s and C-\
9b694015caec (enable-flow-control): Use prefix argument like minor modes.
Richard M. Stallman <rms@gnu.org>
parents: 3660
diff changeset
85 (aset keyboard-translate-table flow-control-c-s-replacement ?\^s)
9b694015caec (enable-flow-control): Use prefix argument like minor modes.
Richard M. Stallman <rms@gnu.org>
parents: 3660
diff changeset
86 (aset keyboard-translate-table ?\^s flow-control-c-s-replacement)
9b694015caec (enable-flow-control): Use prefix argument like minor modes.
Richard M. Stallman <rms@gnu.org>
parents: 3660
diff changeset
87 ;; Swap C-q and C-^
9b694015caec (enable-flow-control): Use prefix argument like minor modes.
Richard M. Stallman <rms@gnu.org>
parents: 3660
diff changeset
88 (aset keyboard-translate-table flow-control-c-q-replacement ?\^q)
9b694015caec (enable-flow-control): Use prefix argument like minor modes.
Richard M. Stallman <rms@gnu.org>
parents: 3660
diff changeset
89 (aset keyboard-translate-table ?\^q flow-control-c-q-replacement)
9b694015caec (enable-flow-control): Use prefix argument like minor modes.
Richard M. Stallman <rms@gnu.org>
parents: 3660
diff changeset
90 (message (concat
9b694015caec (enable-flow-control): Use prefix argument like minor modes.
Richard M. Stallman <rms@gnu.org>
parents: 3660
diff changeset
91 "XON/XOFF adjustment for "
9b694015caec (enable-flow-control): Use prefix argument like minor modes.
Richard M. Stallman <rms@gnu.org>
parents: 3660
diff changeset
92 (getenv "TERM")
9b694015caec (enable-flow-control): Use prefix argument like minor modes.
Richard M. Stallman <rms@gnu.org>
parents: 3660
diff changeset
93 ": use C-\\ for C-s and use C-^ for C-q."))
9b694015caec (enable-flow-control): Use prefix argument like minor modes.
Richard M. Stallman <rms@gnu.org>
parents: 3660
diff changeset
94 (sleep-for 2))) ; Give user a chance to see message.
541
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
95
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
96 ;;;###autoload
1855
80c1064620a8 (enable-flow-control...): Renamed from evade...
Richard M. Stallman <rms@gnu.org>
parents: 1848
diff changeset
97 (defun enable-flow-control-on (&rest losing-terminal-types)
669
4c64c671426f *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 660
diff changeset
98 "Enable flow control if using one of a specified set of terminal types.
1855
80c1064620a8 (enable-flow-control...): Renamed from evade...
Richard M. Stallman <rms@gnu.org>
parents: 1848
diff changeset
99 Use `(enable-flow-control-on \"vt100\" \"h19\")' to enable flow control
669
4c64c671426f *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 660
diff changeset
100 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
101 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
102 to get the effect of a C-q."
541
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
103 (let ((term (getenv "TERM"))
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
104 hyphend)
5643
860d91d72063 (enable-flow-control-on): Do nothing if no TERM.
Richard M. Stallman <rms@gnu.org>
parents: 5506
diff changeset
105 (if term
860d91d72063 (enable-flow-control-on): Do nothing if no TERM.
Richard M. Stallman <rms@gnu.org>
parents: 5506
diff changeset
106 (progn
860d91d72063 (enable-flow-control-on): Do nothing if no TERM.
Richard M. Stallman <rms@gnu.org>
parents: 5506
diff changeset
107 ;; Strip off hyphen and what follows
860d91d72063 (enable-flow-control-on): Do nothing if no TERM.
Richard M. Stallman <rms@gnu.org>
parents: 5506
diff changeset
108 (while (setq hyphend (string-match "[-_][^-_]+$" term))
860d91d72063 (enable-flow-control-on): Do nothing if no TERM.
Richard M. Stallman <rms@gnu.org>
parents: 5506
diff changeset
109 (setq term (substring term 0 hyphend)))
860d91d72063 (enable-flow-control-on): Do nothing if no TERM.
Richard M. Stallman <rms@gnu.org>
parents: 5506
diff changeset
110 (and (member term losing-terminal-types)
860d91d72063 (enable-flow-control-on): Do nothing if no TERM.
Richard M. Stallman <rms@gnu.org>
parents: 5506
diff changeset
111 (enable-flow-control))))))
541
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
112
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
113 (provide 'flow-ctrl)
1c956f448a00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
114
660
08eb386dd0f3 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 584
diff changeset
115 ;;; flow-ctrl.el ends here