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