all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Bruno Barbier <brubar.cs@gmail.com>
To: Eduardo Ochs <eduardoochs@gmail.com>
Cc: help-gnu-emacs <help-gnu-emacs@gnu.org>
Subject: Re: Redisplay inside keyboard macros
Date: Wed, 09 Feb 2022 19:28:49 +0100	[thread overview]
Message-ID: <620407a3.1c69fb81.7d4cb.38fb@mx.google.com> (raw)
In-Reply-To: <CADs++6g+=16q8-9zSxvc2SS_+4ZZk2EzsuAtezmad-JDsqXasw@mail.gmail.com>


Hi Eduardo,

Eduardo Ochs <eduardoochs@gmail.com> writes:

> On Tue, 8 Feb 2022 at 17:39, Bruno Barbier <brubar.cs@gmail.com> wrote:

>> Eduardo, your 'eek' function just works fine in my emacs, using
>> just the (sleep-for 1) definition. I can cleanup and share my hack if
>> you're interested.
>>
>> Bruno.
>
> Hi Bruno!
> I'm interested! Please share! =)

Here is my hack to force a redisplay between each command, when
executing a keyboard macro; this ensures that running the macro does
the same thing as when recording it, and the same thing as when
running it step by step.

Not that I'm adding my hack to 'post-command-hook', so, be careful, and
only try it in a *new* instance of emacs, just to be safe.

  #+begin_src elisp
    (defun bba-kmacros-force-redisplay ()
      "Hack to force redisplay when running keyboard macros."
      (when executing-kbd-macro
        (let (;; Hide any pending events.
              (unread-command-events nil)
              ;; Pretend that we are not currently executing a keyboard
              ;; macro ...
              (executing-kbd-macro nil)
              (defining-kbd-macro nil)
              )
          ;; Make emacs believe that we're asking something to the user: that
          ;; triggers a redisplay.
          (let ((mb-oops (read-event "kmacro replay (hack): don't touch anything ..." nil .0))
                )
            (when mb-oops
              ;; Really ? Got an event before 0 second ?  ... sweeping it
              ;; under the carpet, hoping that nobody notices ...
              (message "ERROR: bba-kmacros-force-redisplay: loosing one event %S..."
                       mb-oops))
            )
          )))

    ;; Tell emacs to run `bba-kmacros-force-redisplay' after each command.
    (add-hook 'post-command-hook
              'bba-kmacros-force-redisplay
              :better-at-the-end)

  #+end_src

I just tested your example with GNU Emacs 27.2, and no personal config
(-Q) and it seems to do what you want.


Bruno.


>   [[]], Eduardo



  reply	other threads:[~2022-02-09 18:28 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-08 15:17 Redisplay inside keyboard macros Eduardo Ochs
2022-02-08 16:47 ` Eli Zaretskii
2022-02-08 19:42   ` Bruno Barbier
2022-02-08 21:00     ` Eduardo Ochs
2022-02-09 18:28       ` Bruno Barbier [this message]
2022-02-08 17:31 ` Eduardo Ochs

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=620407a3.1c69fb81.7d4cb.38fb@mx.google.com \
    --to=brubar.cs@gmail.com \
    --cc=eduardoochs@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.