This can be done quite easily by overriding the undo-boundary noflet for example with the noflet package.
A macro definition (generated by insert-kbd-macro ) is given as follows:
(fset 'my-macro [... keys ...])
or:
(fset 'my-macro (lambda (&optional arg) "Keyboard macro." (interactive "p") (kmacro-exec-ring-item (quote ([...keys...] 0 "%d")) arg)))
Edit it like this:
(require 'noflet) (fset 'my-macro (lambda (&optional arg) "Keyboard macro." (interactive "p") (undo-boundary) (noflet ((undo-boundary ())) (kmacro-exec-ring-item (quote ([...keys...] 0 "%d")) arg)) (undo-boundary)))
If you do not want to edit all macro definitions, you can alternatively add a shell that calls the macro specified as an argument, creating / suppressing undo borders, as described above.
Vladimir Panteleev
source share