Query-replace for macros in emacs?

I use the built-in f3 / f4 bindings in emacs to write and repeat macros, and I think this is a very powerful and useful feature, especially when combined with search. However, I recently noticed that whenever I execute a replacement request (MS-5 by default), macro recording stops! Is there any way to prevent this? I know that query-replace is interactive, but if I type 'y' 3 times to make 3 replacements, I believe the macro should just do the same.

No problem, I think when I write my macro I will do Cu 3 MS-5, so it will do the replacement exactly 3 times, since I know that it is good enough for what I do. But obviously, the replacement request ignores Cu! Usually using macros and using Cu for me is no problem. Is there a way to get them to work with query replacement?

+3
source share
1 answer

With my Emacs (23.2) and without a user initialization file ( emacs -q), I found that it query-replaceworks just fine. This is my test.

I typed:

1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5

I moved the cursor to the top of this text block

<f3> M-S-5 3 RET tj RET y y y q <f4>

who left me:

1 2 tj 4 5
1 2 tj 4 5
1 2 tj 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5

Pressing <f4>again left me with:

1 2 tj 4 5
1 2 tj 4 5
1 2 tj 4 5
1 2 3 4 5
1 2 tj 4 5
1 2 tj 4 5
1 2 tj 4 5
1 2 3 4 5

, . emacs -q, , , .

+3

Source: https://habr.com/ru/post/1752147/


All Articles