开发者

query-replace for macros in emacs?

I use the builtin f3/f4 bindings in emacs a lot to record and repeat macros, and find it to be a very powerful and useful feature, especially when combined with search. However, I noticed recently that whenever I do a query-replace (M-S-5 by default) that recording my macro stops! Is there a way to prevent this? I know that query-replace is interactive but if I enter 'y' 3 times to do 3 replaces, I figure the macro should just do the same.

No problem I figure, when recording my macro I'll do C-u 3 M-S-5 so it'll do the replacement exactly 3 times since I know that's good enough for what I'm doing. But apparently query-replace ignores C-u! Usually macro use and C-u use are seamless for me. Is there a way I can make them wor开发者_StackOverflow社区k with query-replace?


With my Emacs (23.2) and no user init file (emacs -q), I find that query-replace works just fine. This is my test

I typed in:

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 that text block

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

which 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 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

Works as expected. I'd recommend trying with emacs -q to ensure you don't have any customizations that affect the behavior.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜