aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/flow-ctrl.el
diff options
context:
space:
mode:
authorRichard M. Stallman1994-01-08 10:04:22 +0000
committerRichard M. Stallman1994-01-08 10:04:22 +0000
commit162de1825de6bc2dbc5ab28f0a60ea0862d64800 (patch)
treea279d96be08de26838a2bcc3522facdcd65ac859 /lisp/flow-ctrl.el
parent7d606649feeb8cec6cd1846e2c3124e6c2cd9a0e (diff)
downloademacs-162de1825de6bc2dbc5ab28f0a60ea0862d64800.tar.gz
emacs-162de1825de6bc2dbc5ab28f0a60ea0862d64800.zip
(enable-flow-control): Use prefix argument like minor modes.
(enable-flow-control-memstr=): Function deleted. (enable-flow-control-on): Use member instead. (flow-control-c-q-replacement, flow-control-c-s-replacement): New vars.
Diffstat (limited to 'lisp/flow-ctrl.el')
-rw-r--r--lisp/flow-ctrl.el81
1 files changed, 48 insertions, 33 deletions
diff --git a/lisp/flow-ctrl.el b/lisp/flow-ctrl.el
index 138ef0908d1..ec76e29bfdf 100644
--- a/lisp/flow-ctrl.el
+++ b/lisp/flow-ctrl.el
@@ -44,39 +44,54 @@
44 44
45;;; Code: 45;;; Code:
46 46
47;;;###autoload 47(defvar flow-control-c-s-replacement ?\034
48(defun enable-flow-control () 48 "Character that replaces C-s, when flow control handling is enabled.")
49 "Enable use of flow control; let user type C-s as C-\\ and C-q as C-^." 49(defvar flow-control-c-q-replacement ?\036
50 (interactive) 50 "Character that replaces C-q, when flow control handling is enabled.")
51 ;; Tell emacs to pass C-s and C-q to OS.
52 (set-input-mode nil t (nth 2 (current-input-mode)))
53 ;; Initialize translate table, saving previous mappings, if any.
54 (let ((the-table (make-string 128 0)))
55 (let ((i 0)
56 (j (length keyboard-translate-table)))
57 (while (< i j)
58 (aset the-table i (elt keyboard-translate-table i))
59 (setq i (1+ i)))
60 (while (< i 128)
61 (aset the-table i i)
62 (setq i (1+ i))))
63 (setq keyboard-translate-table the-table))
64 ;; Swap C-s and C-\
65 (aset keyboard-translate-table ?\034 ?\^s)
66 (aset keyboard-translate-table ?\^s ?\034)
67 ;; Swap C-q and C-^
68 (aset keyboard-translate-table ?\036 ?\^q)
69 (aset keyboard-translate-table ?\^q ?\036)
70 (message (concat
71 "XON/XOFF adjustment for "
72 (getenv "TERM")
73 ": use C-\\ for C-s and use C-^ for C-q."))
74 (sleep-for 2)) ; Give user a chance to see message.
75 51
76(defun enable-flow-control-memstr= (e s) 52;;;###autoload
77 (cond ((null s) nil) 53(defun enable-flow-control (&optional argument)
78 ((string= e (car s)) t) 54 "Toggle flow control handling.
79 (t (enable-flow-control-memstr= e (cdr s))))) 55When handling is enabled, user can type C-s as C-\\, and C-q as C-^.
56With arg, enable flow control mode if arg is positive, otherwise disable."
57 (interactive "P")
58 (if (if argument
59 ;; Argument means enable if arg is positive.
60 (<= (prefix-numeric-value argument) 0)
61 ;; No arg means toggle.
62 (nth 1 (current-input-mode)))
63 (progn
64 ;; Turn flow control off, and stop exchanging chars.
65 (set-input-mode t nil (nth 2 (current-input-mode)))
66 (aset keyboard-translate-table flow-control-c-s-replacement nil)
67 (aset keyboard-translate-table ?\^s nil)
68 (aset keyboard-translate-table flow-control-c-q-replacement nil)
69 (aset keyboard-translate-table ?\^q nil))
70 ;; Turn flow control on.
71 ;; Tell emacs to pass C-s and C-q to OS.
72 (set-input-mode nil t (nth 2 (current-input-mode)))
73 ;; Initialize translate table, saving previous mappings, if any.
74 (let ((the-table (make-string 128 0)))
75 (let ((i 0)
76 (j (length keyboard-translate-table)))
77 (while (< i j)
78 (aset the-table i (elt keyboard-translate-table i))
79 (setq i (1+ i)))
80 (while (< i 128)
81 (aset the-table i i)
82 (setq i (1+ i))))
83 (setq keyboard-translate-table the-table))
84 ;; Swap C-s and C-\
85 (aset keyboard-translate-table flow-control-c-s-replacement ?\^s)
86 (aset keyboard-translate-table ?\^s flow-control-c-s-replacement)
87 ;; Swap C-q and C-^
88 (aset keyboard-translate-table flow-control-c-q-replacement ?\^q)
89 (aset keyboard-translate-table ?\^q flow-control-c-q-replacement)
90 (message (concat
91 "XON/XOFF adjustment for "
92 (getenv "TERM")
93 ": use C-\\ for C-s and use C-^ for C-q."))
94 (sleep-for 2))) ; Give user a chance to see message.
80 95
81;;;###autoload 96;;;###autoload
82(defun enable-flow-control-on (&rest losing-terminal-types) 97(defun enable-flow-control-on (&rest losing-terminal-types)
@@ -90,7 +105,7 @@ to get the effect of a C-q."
90 ;; Strip off hyphen and what follows 105 ;; Strip off hyphen and what follows
91 (while (setq hyphend (string-match "[-_][^-_]+$" term)) 106 (while (setq hyphend (string-match "[-_][^-_]+$" term))
92 (setq term (substring term 0 hyphend))) 107 (setq term (substring term 0 hyphend)))
93 (and (enable-flow-control-memstr= term losing-terminal-types) 108 (and (member term losing-terminal-types)
94 (enable-flow-control)))) 109 (enable-flow-control))))
95 110
96(provide 'flow-ctrl) 111(provide 'flow-ctrl)