2

I'd like to select a simple formula like 17+5 and replace that by the computed result, 22 in this case. And I need this to work during keyboard macro execution, to quickly process large portions of my file. What's the quickest way to achieve this?

My best bet at this point would be some form of embedded calc mode: select the region, then do C-u 0 C-x * e C-x * e to turn embedded mode on on the selected region, then turn it off again. But when executed inside a macro, the prefix argument appears to be handled somewhat differently. I get the message

After 0 kbd macro iterations: calcDigit-nondigit:
Keyboard macro terminated by a command ringing the bell

and the buffer stays in embedded calc mode.

Note: I'm seeing similar issues when I try some other approach. For example, at some point I tried using space instead of plus, and then followed this post to compute the sum using C-x * G V R + C-u y to grab the expression to the stack, reduce it using a sum there, then paste the result back replacing the selection. Again things work when recording the macro, but executing it I don't see the grabbed region on the stack, but instead see an empty grab vector followed by an empty arg vector. Perhaps there is some trick to make macro playback and calc mode cooperate more nicely for both these situations?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.