Surrounding with tags in a macro doesn't seem to work properly
Closed this issue · 5 comments
I've noticed that, while using single-character surround commands in kbd-macros works, surrounding with tags seems to have anomalous behaviours when recording.
For example, given the text
foo
bar
baz
Putting the cursor on foo
and running C-x ( ysetfoo>j C-x )
works, resulting in the buffer looking like
<foo>foo</foo>
bar
baz
with the cursor on bar
, when I attempt to replay the macro, everything in the macro after the >
gets inserted, not treated as a command; i.e. after hitting C-x e, the buffer looks like
<foo>foo</foo>
<foo>j>bar</foo>
baz
Note the extra j>
.
I'm running evil 8a06c0da1f5cf09b721180c2b0a133285f4d409c and evil-surround d210e1f, although I've seen this behaviour in previous versions as well.
It seems to be due to the run-at-time
in evil-surround-read-tag-map
; if I change the define-key
on line 91 of evil-surround.el to be
(define-key map ">" (lambda ()
(interactive)
(call-interactively 'self-insert-command)
(when (active-minibuffer-window)
(select-window (active-minibuffer-window))
(exit-minibuffer))))
Then it seems to work...I assume there's a reason for the run-at-time though that makes just removing it not viable?
Hi @jamesnvc, I do not know the reason for that run-at-time
. If you run the tests successfully with your change, then everything should work fine. If the tests run 100%, I encorage you to prepare a PR including a test for this use case.
Interestingly, I'm finding it hard to write a test for this; evil-test-buffer
works by playing the keystrokes given as a macro, so I can't record a macro in there; theoretically, I should be able to then just try passing the contents of the macro of the key commands and see the behaviour I was seeing above happen in the test, but that doesn't seem to work either.
Running make emacs
, I can see the behaviour I expect interactively, but not in the tests. I will keep experimenting though.
Writing a test not using evil-test-buffer, that seems to work, but it does transpire that removing the run-at-time
makes the test for "buffer is widened before reading char" fail. This is somewhat confusing to me, as that test doesn't seem to have anything to do with reading tags...
EDIT: I re-ran at now it works? I am kind of confused...I'll make the PR, in any case.