emacs-devel
[Top][All Lists]
Advanced

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

Re: Native compilation of Keyboard Macros


From: Stefan Monnier
Subject: Re: Native compilation of Keyboard Macros
Date: Fri, 16 Sep 2022 15:27:18 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

Philip Kaludercic [2022-09-16 18:56:19] wrote:
> Is it possible to use native compilation to speed up the execution of
> keyboard macros (or is this already being done)?  I think that there are
> certain situations where a macro is executed many times over (C-x C-k r,
> C-0 C-x e) that can slow down Emacs noticeably, where JITing could help.

I think it's somewhere between difficult and impossible.
The problem is not in the *native* part but in the transformation of the
keyboard macro into code: a keyboard macro is defined as a sequence of
events, and each one of those events can cause execution of a different
command every time it's repeated.

Also, I think that if `C-0 C-x e` is too slow, it's usually either:

- The few commands that are executed just take a lot of time
  (native-compilation of those commands can help but that's not specific
  to the case where they're run via a keyboard macro).
- The `C-x 0 C-x e` looping itself is costly, but most of that is
  execution of the repl (the lookup through keymaps, the pre/post
  command hooks, processing `interactive`, etc...) most of which is
  already coded in C.  In that case, turning the keyboard macro into
  "plain" ELisp code would bring a significant performance increase,
  regardless if it's (native) compiled, but it's almost impossible to do
  in general.

So, I think you should focus on the problem of turning a keyboard macro
into code.  We know it's impossible in general, so it has to be
"user-visible" (i.e. the user specifically asks for it and is made aware
that the result is a chunk of code which will not always run the same
commands as the keyboard macro).

You could have a "run kmacro and turn *this* execution into ELisp code".
IIUC some people tried to do that already, but I can't remember where
I saw that and my search-fu is weak right now.


        Stefan




reply via email to

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