help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Redisplay inside keyboard macros


From: Eduardo Ochs
Subject: Re: Redisplay inside keyboard macros
Date: Tue, 8 Feb 2022 14:31:27 -0300

On Tue, 8 Feb 2022 at 12:17, Eduardo Ochs <eduardoochs@gmail.com> wrote:
>
> Hi list,
>
> I am trying to write a keyboard macro that does some things, pauses
> for one second, and then does more things, but I discovered that the
> obvious ways to do sleep-and-redisplay don't work. Try to run the code
> below with your favorite variant of C-e C-x C-e after each sexp:
>
>   (defun eek (str)
>     "Execute STR as a keyboard macro. See `edmacro-mode' for the exact 
> format.\n
>   An example: (eek \"C-x 4 C-h\")"
>     (interactive "sKeys: ")
>     (execute-kbd-macro (read-kbd-macro str)))
>
>   ;; Choose one:
>   (defun s () (interactive)                    (sleep-for 1))
>   (defun s () (interactive) (redisplay)        (sleep-for 1) (redisplay))
>   (defun s () (interactive) (redisplay 'force) (sleep-for 1) (redisplay 
> 'force))
>
>   (eek "RET ab <<s>> cd")
>
> I expected to see an "ab", then a pause, then the "cd", but that's not
> what happens - I get a pause and then "abcd".
>
> What am I doing wrong? I just triple-checked the docs about redisplay
> and this behavior makes no sense to me...
>
>   Thanks in advance!!!
>     Eduardo Ochs
>     http://angg.twu.net/#eev

Hi Eli,

> 'redisplay' exits immediately if called from a keyboard macro.  It's a
> feature.

Aha! Thanks!
This works:

  (defun eek (str)
    "Execute STR as a keyboard macro. See `edmacro-mode' for the exact format.\n
  An example: (eek \"C-x 4 C-h\")"
    (interactive "sKeys: ")
    (execute-kbd-macro (read-kbd-macro str)))

  (defun rd () (interactive) (redisplay 'force))
  (defun s () (interactive) (rd) (sleep-for 1) (rd))

  (defun eeks (str &rest rest)
    (eek str)
    (if rest (progn (s) (apply 'eeks rest))))

    (eeks "RET ab" "cd" "ef")

Cheers =),
  Eduardo Ochs
  http://angg.twu.net/#eev



reply via email to

[Prev in Thread] Current Thread [Next in Thread]