Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't run a macro a second time #1331

Closed
juacq97 opened this issue Jul 7, 2020 · 6 comments
Closed

Can't run a macro a second time #1331

juacq97 opened this issue Jul 7, 2020 · 6 comments
Labels

Comments

@juacq97
Copy link

juacq97 commented Jul 7, 2020

Issue type

  • Bug report

Environment

Emacs version: GNU Emacs 26.3 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.20) of 2020-05-19
Operating System: Arch Linux
Evil version: 1.14.0
Evil installation type: Melpa
Graphical/Terminal: Graphical
Tested in a make emacs session (see CONTRIBUTING.md): No

Reproduction steps

  • Start Emacs
  • Record a macro with Q-, example Q-1
  • Play the marco with @-, example @-1
    -Play the macro again

Expected behavior

The macro is played again

Actual behavior

The macro isn't played and I get an error After 0 kbd macro iterations: evil-execute-macro: Keyboard macro terminated by a command ringing the bell

@TheBB
Copy link
Member

TheBB commented Jul 7, 2020

I don't understand your reproduction steps. Q-1? Q isn't how you record a macro and - is not a valid register.

Tested in a make emacs session (see CONTRIBUTING.md): No

We have this question for a reason.

@TheBB TheBB added the invalid label Jul 7, 2020
@juacq97
Copy link
Author

juacq97 commented Jul 7, 2020

My bad, I mean q-1, a lowercase q and the any character.

I ran make emacs. I get the next error:

F evil-test-flyspell-motions
    Test flyspell motions
    Info: Simple
    (ert-test-failed
     ((should
       (string=
	(buffer-substring
	 (max ... ...)
	 (point))
	before))
      :form
      (string= "I cannt tpye " "I cannt tpye for ")
      :value nil))

@TheBB
Copy link
Member

TheBB commented Jul 7, 2020

Sorry, I still can't reproduce. Is the hyphen supposed to be 'any' character? This is what I tried:

  • qa1xq record a macro in register a that deletes a character
  • @a@a replay macro, works fine

q followed by any character followed by 1 is an incomplete macro.

I ran make emacs. I get the next error:

I'm not sure why the tests are failing for you, but when asked whether you want to run the tests you can safely answer no. The point is just to reproduce the error in a make emacs instance.

@juacq97
Copy link
Author

juacq97 commented Jul 7, 2020

I tried tpo reproduce the error on the make emacs instance, I tried two macros:

  • q1ihello<ESC>q: write the word "hello". I can reproduce it at many times I want, just as expected.
    -df"i[[<ESC>f"a][<ESC>ldf>f<Da]] (<ESC> means press the ESC key): This is the one that trigger my error: I have a list of links like this <DT><A HREF="https://doc.opensuse.org/" ADD_DATE="1543974418" LAST_MODIFIED="1590776675">openSUSE Documentation</A> on a html file and I want to transform it to org-mode links with that macro. I can reproduce the macro just one time, the second time I get the error. This happens both the normal emacs and the make emacs instance

@mohkale
Copy link

mohkale commented Oct 14, 2020

I've run into something like this a few times but could never reproduce it intentionally so I never made an issue.

@classieur
Copy link

classieur commented Jun 17, 2022

This happens when you save a macro to registers between "1 and "9. Those registers get overwritten whenever you delete text (see http://vimdoc.sourceforge.net/htmldoc/change.html#registers), so if your macro contains x or d, executing it will overwrite the register "1, and executing it again won't work because "1 is not a macro anymore, it's your deleted content.

You can display the registers on Emacs with M-x evil-show-registers, and on Vim with :registers (to compare).

It's more difficult to reproduce with Vim, because of this:

Numbered register 1 contains the text deleted by the most recent delete or
change command, unless the command specified another register or the text is
less than one line (the small delete register is used then).

So on Vim you need to delete at least one full line (e.g. with dd) to break a macro saved in the register "1.

I think evil-mode saving small deletes in numbered registers ("1 to "9) is the bug. It should only save them in the small delete register ("-). See #1049 (comment).

I don't think it's a good idea to save macros in numbered registers, regardless. You should save them in named registers: "a to "z. (Or "A to "Z if you want to append to an existing macro.)

@axelf4 axelf4 closed this as not planned Won't fix, can't repro, duplicate, stale Jan 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants