Xref: utzoo gnu.emacs.help:289 comp.emacs:9481 Path: utzoo!utgpu!watserv1!watmath!uunet!tut.cis.ohio-state.edu!AI.MIT.EDU!roland From: roland@AI.MIT.EDU (Roland McGrath) Newsgroups: gnu.emacs.help,comp.emacs Subject: Re: command idea Message-ID: <9011100445.AA02007@albert.ai.mit.edu> Date: 10 Nov 90 04:45:52 GMT Sender: daemon@tut.cis.ohio-state.edu Followup-To: gnu.emacs.help Organization: GNUs Not Usenet Lines: 69 > Of course, the root of the problem is that emacs gets out of touch with the > characters that are actually on the screen; the "right" solution would be > to do what Gosling Emacs did, and only send the characters as fast as they > will be received. That is, if on a 1200 baud line, delay for 1/150th second > between each character. This would prevent the (now-common) situation of > Emacs dumping a screenful of characters into the tty's buffer, and then > dumping more before the buffer has emptied. That sounds odd. Emacs's redisplay is pretty smart. Does it know what speed you're at? Try "stty 1200" before starting Emacs. > So how about this: what if there was a command, similar in usage to > define-keyboard-macro, which would read a sequence of keystrokes and then > execute them? Since Emacs would get the keystrokes all at once, there would > be no chance for redisplay to get out of synch with the buffering on the > terminal line, and no thrashing. Would such a thing be possible? I think such a thing might be possible. In fact, it only took five minutes or so. ;;; read-kbd-macro.el -- Read a sequence of commands from the keyboard. ;;; ;;; Copyright (C) 1990 Roland McGrath ;;; ;;; This program is free software; you can redistribute it and/or modify ;;; it under the terms of the GNU General Public License as published by ;;; the Free Software Foundation; either version 1, or (at your option) ;;; any later version. ;;; ;;; This program is distributed in the hope that it will be useful, ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;; GNU General Public License for more details. ;;; ;;; A copy of the GNU General Public License can be obtained from this ;;; program's author (send electronic mail to roland@ai.mit.edu) or from ;;; the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA ;;; 02139, USA. ;;; ;;; Send bug reports to roland@ai.mit.edu. ;;; ;;; To use this package, put: ;;; (autoload 'read-kbd-macro "read-kbd-macro" nil t) ;;; (autoload 'read-execute-kbd-macro "read-kbd-macro" nil t) ;;; in your .emacs or site-init.el, and bind these functions to ;;; keys as you desire, e.g.: ;;; (global-set-key "\C-ce" 'read-execute-kbd-macro) ;;; (global-set-key "\C-cr" 'read-kbd-macro) (defun read-kbd-macro () "Read a sequence of commands from the keyboard, ending when \\[end-kbd-macro] is read, and assign it to `last-kbd-macro'. It can then be executed with \\[call-last-kbd-macro] or named with \\[name-last-kbd-macro]." (interactive) (let ((keys '("")) (prompt "Reading keyboard macro: ")) (while (not (eq (key-binding (car keys)) 'end-kbd-macro)) (setq keys (cons (read-key-sequence prompt) keys) prompt (concat prompt " " (key-description (car keys))))) (setq last-kbd-macro (mapconcat 'identity (nreverse (cdr keys)) "")) (message "Keyboard macro defined: %s" (key-description last-kbd-macro)))) (defun read-execute-kbd-macro () "Read a sequence of commands from the keyboard using \\[read-kbd-macro], and then execute it using \\[call-last-kbd-macro]." (interactive) (read-kbd-macro) (call-last-kbd-macro))