annotate lisp/flow-ctrl.el @ 584:4cd7543be581

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