[comp.emacs] command idea

roland@AI.MIT.EDU (Roland McGrath) (11/10/90)

> 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))

rms@AI.MIT.EDU (Richard Stallman) (11/12/90)

   Date: 10 Nov 90 06:40:44 GMT
   From: jwz@lucid.com  (Jamie Zawinski)
   Organization: Lucid, Inc., Menlo Park, CA
   References: <9011100445.AA02007@albert.ai.mit.edu>
   Sender: help-gnu-emacs-request@prep.ai.mit.edu

   In article <9011100445.AA02007@albert.ai.mit.edu> roland@AI.MIT.EDU (Roland McGrath) wrote:
   > 
   > That sounds odd.  Emacs's redisplay is pretty smart.  Does it know what
   > speed you're at?  Try "stty 1200" before starting Emacs.

   Been there, done that.  (baud-rate) returns 1200.  I'm going through a
   terminal concentrator, but that shouldn't matter if emacs is pushing
   characters exactly at the speed of the line, which it doesn't seem to be
   doing.

There is already code in dispnew.c to do this.