summaryrefslogtreecommitdiff
path: root/lisp/flow-ctrl.el
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>1994-01-08 10:04:22 +0000
committerRichard M. Stallman <rms@gnu.org>1994-01-08 10:04:22 +0000
commit162de1825de6bc2dbc5ab28f0a60ea0862d64800 (patch)
treea279d96be08de26838a2bcc3522facdcd65ac859 /lisp/flow-ctrl.el
parent7d606649feeb8cec6cd1846e2c3124e6c2cd9a0e (diff)
downloademacs-162de1825de6bc2dbc5ab28f0a60ea0862d64800.tar.gz
(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 @@
;;; Code:
-;;;###autoload
-(defun enable-flow-control ()
- "Enable use of flow control; let user type C-s as C-\\ and C-q as C-^."
- (interactive)
- ;; Tell emacs to pass C-s and C-q to OS.
- (set-input-mode nil t (nth 2 (current-input-mode)))
- ;; Initialize translate table, saving previous mappings, if any.
- (let ((the-table (make-string 128 0)))
- (let ((i 0)
- (j (length keyboard-translate-table)))
- (while (< i j)
- (aset the-table i (elt keyboard-translate-table i))
- (setq i (1+ i)))
- (while (< i 128)
- (aset the-table i i)
- (setq i (1+ i))))
- (setq keyboard-translate-table the-table))
- ;; Swap C-s and C-\
- (aset keyboard-translate-table ?\034 ?\^s)
- (aset keyboard-translate-table ?\^s ?\034)
- ;; Swap C-q and C-^
- (aset keyboard-translate-table ?\036 ?\^q)
- (aset keyboard-translate-table ?\^q ?\036)
- (message (concat
- "XON/XOFF adjustment for "
- (getenv "TERM")
- ": use C-\\ for C-s and use C-^ for C-q."))
- (sleep-for 2)) ; Give user a chance to see message.
+(defvar flow-control-c-s-replacement ?\034
+ "Character that replaces C-s, when flow control handling is enabled.")
+(defvar flow-control-c-q-replacement ?\036
+ "Character that replaces C-q, when flow control handling is enabled.")
-(defun enable-flow-control-memstr= (e s)
- (cond ((null s) nil)
- ((string= e (car s)) t)
- (t (enable-flow-control-memstr= e (cdr s)))))
+;;;###autoload
+(defun enable-flow-control (&optional argument)
+ "Toggle flow control handling.
+When handling is enabled, user can type C-s as C-\\, and C-q as C-^.
+With arg, enable flow control mode if arg is positive, otherwise disable."
+ (interactive "P")
+ (if (if argument
+ ;; Argument means enable if arg is positive.
+ (<= (prefix-numeric-value argument) 0)
+ ;; No arg means toggle.
+ (nth 1 (current-input-mode)))
+ (progn
+ ;; Turn flow control off, and stop exchanging chars.
+ (set-input-mode t nil (nth 2 (current-input-mode)))
+ (aset keyboard-translate-table flow-control-c-s-replacement nil)
+ (aset keyboard-translate-table ?\^s nil)
+ (aset keyboard-translate-table flow-control-c-q-replacement nil)
+ (aset keyboard-translate-table ?\^q nil))
+ ;; Turn flow control on.
+ ;; Tell emacs to pass C-s and C-q to OS.
+ (set-input-mode nil t (nth 2 (current-input-mode)))
+ ;; Initialize translate table, saving previous mappings, if any.
+ (let ((the-table (make-string 128 0)))
+ (let ((i 0)
+ (j (length keyboard-translate-table)))
+ (while (< i j)
+ (aset the-table i (elt keyboard-translate-table i))
+ (setq i (1+ i)))
+ (while (< i 128)
+ (aset the-table i i)
+ (setq i (1+ i))))
+ (setq keyboard-translate-table the-table))
+ ;; Swap C-s and C-\
+ (aset keyboard-translate-table flow-control-c-s-replacement ?\^s)
+ (aset keyboard-translate-table ?\^s flow-control-c-s-replacement)
+ ;; Swap C-q and C-^
+ (aset keyboard-translate-table flow-control-c-q-replacement ?\^q)
+ (aset keyboard-translate-table ?\^q flow-control-c-q-replacement)
+ (message (concat
+ "XON/XOFF adjustment for "
+ (getenv "TERM")
+ ": use C-\\ for C-s and use C-^ for C-q."))
+ (sleep-for 2))) ; Give user a chance to see message.
;;;###autoload
(defun enable-flow-control-on (&rest losing-terminal-types)
@@ -90,7 +105,7 @@ to get the effect of a C-q."
;; Strip off hyphen and what follows
(while (setq hyphend (string-match "[-_][^-_]+$" term))
(setq term (substring term 0 hyphend)))
- (and (enable-flow-control-memstr= term losing-terminal-types)
+ (and (member term losing-terminal-types)
(enable-flow-control))))
(provide 'flow-ctrl)