Mercurial > emacs
annotate lisp/flow-ctrl.el @ 13938:3e0b6a3707bd
(browse-url-usr1-signal): Doc fix.
author | Karl Heuer <kwzh@gnu.org> |
---|---|
date | Thu, 04 Jan 1996 22:53:41 +0000 |
parents | 116a22176b36 |
children | 83f275dcd93a |
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 |
7298 | 3 ;;; Copyright (C) 1990, 1991, 1994 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 |
6736
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
5643
diff
changeset
|
10 ;; This file is part of GNU Emacs. |
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
5643
diff
changeset
|
11 |
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
5643
diff
changeset
|
12 ;; GNU Emacs is free software; you can redistribute it and/or modify |
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
5643
diff
changeset
|
13 ;; it under the terms of the GNU General Public License as published by |
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
5643
diff
changeset
|
14 ;; the Free Software Foundation; either version 2, or (at your option) |
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
5643
diff
changeset
|
15 ;; any later version. |
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
5643
diff
changeset
|
16 |
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
5643
diff
changeset
|
17 ;; GNU Emacs is distributed in the hope that it will be useful, |
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
5643
diff
changeset
|
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
5643
diff
changeset
|
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
5643
diff
changeset
|
20 ;; GNU General Public License for more details. |
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
5643
diff
changeset
|
21 |
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
5643
diff
changeset
|
22 ;; You should have received a copy of the GNU General Public License |
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
5643
diff
changeset
|
23 ;; along with GNU Emacs; see the file COPYING. If not, write to |
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
5643
diff
changeset
|
24 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
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 | 27 |
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 | 30 ;;;; easy for a user to deal with this problem, when using such a |
31 ;;;; terminal. | |
32 ;;;; | |
33 ;;;; 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
|
34 ;;;; enable-flow-control-on with a list of terminal types in his/her own |
541 | 35 ;;;; .emacs file. As arguments, give it the names of one or more terminal |
36 ;;;; types in use by that user which require flow control adjustments. | |
37 ;;;; Here's an example: | |
38 ;;;; | |
1855
80c1064620a8
(enable-flow-control...): Renamed from evade...
Richard M. Stallman <rms@gnu.org>
parents:
1848
diff
changeset
|
39 ;;;; (enable-flow-control-on "vt200" "vt300" "vt101" "vt131") |
541 | 40 |
41 ;;; Portability note: This uses (getenv "TERM"), and therefore probably | |
42 ;;; won't work outside of UNIX-like environments. | |
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 |
5506
9b694015caec
(enable-flow-control): Use prefix argument like minor modes.
Richard M. Stallman <rms@gnu.org>
parents:
3660
diff
changeset
|
46 (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
|
47 "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
|
48 (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
|
49 "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
|
50 |
13272
7ee88c335076
(enable-flow-control): Use a char-table.
Richard M. Stallman <rms@gnu.org>
parents:
9716
diff
changeset
|
51 (put 'keyboard-translate-table 'char-table-extra-slots 0) |
7ee88c335076
(enable-flow-control): Use a char-table.
Richard M. Stallman <rms@gnu.org>
parents:
9716
diff
changeset
|
52 |
1855
80c1064620a8
(enable-flow-control...): Renamed from evade...
Richard M. Stallman <rms@gnu.org>
parents:
1848
diff
changeset
|
53 ;;;###autoload |
5506
9b694015caec
(enable-flow-control): Use prefix argument like minor modes.
Richard M. Stallman <rms@gnu.org>
parents:
3660
diff
changeset
|
54 (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
|
55 "Toggle flow control handling. |
9b694015caec
(enable-flow-control): Use prefix argument like minor modes.
Richard M. Stallman <rms@gnu.org>
parents:
3660
diff
changeset
|
56 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
|
57 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
|
58 (interactive "P") |
9b694015caec
(enable-flow-control): Use prefix argument like minor modes.
Richard M. Stallman <rms@gnu.org>
parents:
3660
diff
changeset
|
59 (if (if argument |
9b694015caec
(enable-flow-control): Use prefix argument like minor modes.
Richard M. Stallman <rms@gnu.org>
parents:
3660
diff
changeset
|
60 ;; 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
|
61 (<= (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
|
62 ;; No arg means toggle. |
9b694015caec
(enable-flow-control): Use prefix argument like minor modes.
Richard M. Stallman <rms@gnu.org>
parents:
3660
diff
changeset
|
63 (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
|
64 (progn |
9b694015caec
(enable-flow-control): Use prefix argument like minor modes.
Richard M. Stallman <rms@gnu.org>
parents:
3660
diff
changeset
|
65 ;; 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
|
66 (set-input-mode t nil (nth 2 (current-input-mode))) |
7731
3cfe5791ddfb
(enable-flow-control): Fix bugs turning off flow ctrl.
Richard M. Stallman <rms@gnu.org>
parents:
7298
diff
changeset
|
67 (if keyboard-translate-table |
3cfe5791ddfb
(enable-flow-control): Fix bugs turning off flow ctrl.
Richard M. Stallman <rms@gnu.org>
parents:
7298
diff
changeset
|
68 (progn |
13272
7ee88c335076
(enable-flow-control): Use a char-table.
Richard M. Stallman <rms@gnu.org>
parents:
9716
diff
changeset
|
69 (aset keyboard-translate-table flow-control-c-s-replacement nil) |
7ee88c335076
(enable-flow-control): Use a char-table.
Richard M. Stallman <rms@gnu.org>
parents:
9716
diff
changeset
|
70 (aset keyboard-translate-table ?\^s nil) |
7ee88c335076
(enable-flow-control): Use a char-table.
Richard M. Stallman <rms@gnu.org>
parents:
9716
diff
changeset
|
71 (aset keyboard-translate-table flow-control-c-q-replacement nil) |
7ee88c335076
(enable-flow-control): Use a char-table.
Richard M. Stallman <rms@gnu.org>
parents:
9716
diff
changeset
|
72 (aset keyboard-translate-table ?\^q nil)))) |
5506
9b694015caec
(enable-flow-control): Use prefix argument like minor modes.
Richard M. Stallman <rms@gnu.org>
parents:
3660
diff
changeset
|
73 ;; Turn flow control on. |
9b694015caec
(enable-flow-control): Use prefix argument like minor modes.
Richard M. Stallman <rms@gnu.org>
parents:
3660
diff
changeset
|
74 ;; 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
|
75 (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
|
76 ;; Initialize translate table, saving previous mappings, if any. |
13272
7ee88c335076
(enable-flow-control): Use a char-table.
Richard M. Stallman <rms@gnu.org>
parents:
9716
diff
changeset
|
77 (cond ((null keyboard-translate-table) |
7ee88c335076
(enable-flow-control): Use a char-table.
Richard M. Stallman <rms@gnu.org>
parents:
9716
diff
changeset
|
78 (setq keyboard-translate-table |
7ee88c335076
(enable-flow-control): Use a char-table.
Richard M. Stallman <rms@gnu.org>
parents:
9716
diff
changeset
|
79 (make-char-table 'keyboard-translate-table nil))) |
7ee88c335076
(enable-flow-control): Use a char-table.
Richard M. Stallman <rms@gnu.org>
parents:
9716
diff
changeset
|
80 ((char-table-p keyboard-translate-table) |
7ee88c335076
(enable-flow-control): Use a char-table.
Richard M. Stallman <rms@gnu.org>
parents:
9716
diff
changeset
|
81 (setq keyboard-translate-table |
7ee88c335076
(enable-flow-control): Use a char-table.
Richard M. Stallman <rms@gnu.org>
parents:
9716
diff
changeset
|
82 (copy-sequence keyboard-translate-table))) |
7ee88c335076
(enable-flow-control): Use a char-table.
Richard M. Stallman <rms@gnu.org>
parents:
9716
diff
changeset
|
83 (t |
7ee88c335076
(enable-flow-control): Use a char-table.
Richard M. Stallman <rms@gnu.org>
parents:
9716
diff
changeset
|
84 (let ((the-table (make-char-table 'keyboard-translate-table nil))) |
7ee88c335076
(enable-flow-control): Use a char-table.
Richard M. Stallman <rms@gnu.org>
parents:
9716
diff
changeset
|
85 (let ((i 0) |
7ee88c335076
(enable-flow-control): Use a char-table.
Richard M. Stallman <rms@gnu.org>
parents:
9716
diff
changeset
|
86 (j (length keyboard-translate-table))) |
7ee88c335076
(enable-flow-control): Use a char-table.
Richard M. Stallman <rms@gnu.org>
parents:
9716
diff
changeset
|
87 (while (< i j) |
7ee88c335076
(enable-flow-control): Use a char-table.
Richard M. Stallman <rms@gnu.org>
parents:
9716
diff
changeset
|
88 (aset the-table i (elt keyboard-translate-table i)) |
7ee88c335076
(enable-flow-control): Use a char-table.
Richard M. Stallman <rms@gnu.org>
parents:
9716
diff
changeset
|
89 (setq i (1+ i)))) |
7ee88c335076
(enable-flow-control): Use a char-table.
Richard M. Stallman <rms@gnu.org>
parents:
9716
diff
changeset
|
90 (setq keyboard-translate-table the-table)))) |
5506
9b694015caec
(enable-flow-control): Use prefix argument like minor modes.
Richard M. Stallman <rms@gnu.org>
parents:
3660
diff
changeset
|
91 ;; 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
|
92 (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
|
93 (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
|
94 ;; 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
|
95 (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
|
96 (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
|
97 (message (concat |
9b694015caec
(enable-flow-control): Use prefix argument like minor modes.
Richard M. Stallman <rms@gnu.org>
parents:
3660
diff
changeset
|
98 "XON/XOFF adjustment for " |
9b694015caec
(enable-flow-control): Use prefix argument like minor modes.
Richard M. Stallman <rms@gnu.org>
parents:
3660
diff
changeset
|
99 (getenv "TERM") |
9716
dfe865222721
(enable-flow-control): Make message depend on customization variables.
Richard M. Stallman <rms@gnu.org>
parents:
9090
diff
changeset
|
100 ": use " |
dfe865222721
(enable-flow-control): Make message depend on customization variables.
Richard M. Stallman <rms@gnu.org>
parents:
9090
diff
changeset
|
101 (single-key-description flow-control-c-s-replacement) |
dfe865222721
(enable-flow-control): Make message depend on customization variables.
Richard M. Stallman <rms@gnu.org>
parents:
9090
diff
changeset
|
102 " for C-s, and use " |
dfe865222721
(enable-flow-control): Make message depend on customization variables.
Richard M. Stallman <rms@gnu.org>
parents:
9090
diff
changeset
|
103 (single-key-description flow-control-c-q-replacement) |
dfe865222721
(enable-flow-control): Make message depend on customization variables.
Richard M. Stallman <rms@gnu.org>
parents:
9090
diff
changeset
|
104 " for C-q")) |
5506
9b694015caec
(enable-flow-control): Use prefix argument like minor modes.
Richard M. Stallman <rms@gnu.org>
parents:
3660
diff
changeset
|
105 (sleep-for 2))) ; Give user a chance to see message. |
541 | 106 |
107 ;;;###autoload | |
1855
80c1064620a8
(enable-flow-control...): Renamed from evade...
Richard M. Stallman <rms@gnu.org>
parents:
1848
diff
changeset
|
108 (defun enable-flow-control-on (&rest losing-terminal-types) |
669
4c64c671426f
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
660
diff
changeset
|
109 "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
|
110 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
|
111 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
|
112 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
|
113 to get the effect of a C-q." |
541 | 114 (let ((term (getenv "TERM")) |
115 hyphend) | |
13796
116a22176b36
(enable-flow-control-on): Try the whole TERM name
Karl Heuer <kwzh@gnu.org>
parents:
13272
diff
changeset
|
116 ;; Look for TERM in LOSING-TERMINAL-TYPES. |
116a22176b36
(enable-flow-control-on): Try the whole TERM name
Karl Heuer <kwzh@gnu.org>
parents:
13272
diff
changeset
|
117 ;; If we don't find it literally, try stripping off words |
116a22176b36
(enable-flow-control-on): Try the whole TERM name
Karl Heuer <kwzh@gnu.org>
parents:
13272
diff
changeset
|
118 ;; from the end, one by one. |
116a22176b36
(enable-flow-control-on): Try the whole TERM name
Karl Heuer <kwzh@gnu.org>
parents:
13272
diff
changeset
|
119 (while (and term (not (member term losing-terminal-types))) |
116a22176b36
(enable-flow-control-on): Try the whole TERM name
Karl Heuer <kwzh@gnu.org>
parents:
13272
diff
changeset
|
120 ;; Strip off last hyphen and what follows, then try again. |
116a22176b36
(enable-flow-control-on): Try the whole TERM name
Karl Heuer <kwzh@gnu.org>
parents:
13272
diff
changeset
|
121 (if (setq hyphend (string-match "[-_][^-_]+$" term)) |
116a22176b36
(enable-flow-control-on): Try the whole TERM name
Karl Heuer <kwzh@gnu.org>
parents:
13272
diff
changeset
|
122 (setq term (substring term 0 hyphend)) |
116a22176b36
(enable-flow-control-on): Try the whole TERM name
Karl Heuer <kwzh@gnu.org>
parents:
13272
diff
changeset
|
123 (setq term nil))) |
5643
860d91d72063
(enable-flow-control-on): Do nothing if no TERM.
Richard M. Stallman <rms@gnu.org>
parents:
5506
diff
changeset
|
124 (if term |
13796
116a22176b36
(enable-flow-control-on): Try the whole TERM name
Karl Heuer <kwzh@gnu.org>
parents:
13272
diff
changeset
|
125 (enable-flow-control)))) |
541 | 126 |
127 (provide 'flow-ctrl) | |
128 | |
660
08eb386dd0f3
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
129 ;;; flow-ctrl.el ends here |