質問

Right now I am trying to use the evil plugin in emacs so that I can have the editing capability of vim with the extensibility of emacs. Right now I'm trying to port over one of my favorite parts of my .vimrc: have space repeat whatever my last executed macro was. In my .vimrc it was simply

nore <Space> @@

I am trying to do the same thing in my .emacs file with

(define-key evil-normal-state-map " " (lambda () (interactive) (evil-execute-macro 1 "@")))

@@ repeats the last macro fine, however hitting space gives me the error

After 0 kbd macro iterations: No previous macro

I'm fairly new to lisp and evil so I'm sure I'm doing something very wrong and I would appreciate any help.

役に立ちましたか?

解決

You can bind it similarly to vim:

(define-key evil-normal-state-map " " (kbd "@@"))

Regarding your code: The second argument of evil-execute-macro should be a character, i.e. ?@. But this only holds if evil-execute-macro is called interactively because the content of the corresponding register is only retrieved in the interactive form.

This boils down to this: The correct call would be (evil-execute-macro 1 last-kbd-macro).

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top