Next: , Previous: Stack Manipulation, Up: Stack and Trail

5.2 Editing Stack Entries

The ` (calc-edit) command creates a temporary buffer (*Calc Edit*) for editing the top-of-stack value using regular Emacs commands. Note that ` is a grave accent, not an apostrophe. With a numeric prefix argument, it edits the specified number of stack entries at once. (An argument of zero edits the entire stack; a negative argument edits one specific stack entry.)

When you are done editing, press C-c C-c to finish and return to Calc. The <RET> and <LFD> keys also work to finish most sorts of editing, though in some cases Calc leaves <RET> with its usual meaning (“insert a newline”) if it's a situation where you might want to insert new lines into the editing buffer.

When you finish editing, the Calculator parses the lines of text in the *Calc Edit* buffer as numbers or formulas, replaces the original stack elements in the original buffer with these new values, then kills the *Calc Edit* buffer. The original Calculator buffer continues to exist during editing, but for best results you should be careful not to change it until you have finished the edit. You can also cancel the edit by killing the buffer with C-x k.

The formula is normally reevaluated as it is put onto the stack. For example, editing ‘a + 2’ to ‘3 + 2’ and pressing C-c C-c will push 5 on the stack. If you use <LFD> to finish, Calc will put the result on the stack without evaluating it.

If you give a prefix argument to C-c C-c, Calc will not kill the *Calc Edit* buffer. You can switch back to that buffer and continue editing if you wish. However, you should understand that if you initiated the edit with `, the C-c C-c operation will be programmed to replace the top of the stack with the new edited value, and it will do this even if you have rearranged the stack in the meanwhile. This is not so much of a problem with other editing commands, though, such as s e (calc-edit-variable; see Operations on Variables).

If the calc-edit command involves more than one stack entry, each line of the *Calc Edit* buffer is interpreted as a separate formula. Otherwise, the entire buffer is interpreted as one formula, with line breaks ignored. (You can use C-o or C-q C-j to insert a newline in the buffer without pressing <RET>.)

The ` key also works during numeric or algebraic entry. The text entered so far is moved to the *Calc Edit* buffer for more extensive editing than is convenient in the minibuffer.