2

I have a function named my-func in my init.el. I copy this function to the scratch buffer, make some changes to it and evaluate it with C - j. I then delete the code in the scratch buffer and then call my-func, but it executes the scratch version, not the init.el version.

How can I make Emacs forget code evaluated in the scratch buffer ?

6

Just redefine the function with its original definition again.

You'll probably find this article very helpful:
https://masteringemacs.org/article/evaluating-elisp-emacs

You can't 'undo' lisp evaluation like you can undo text editing -- Emacs isn't keeping a history of all previous states of the lisp interpreter (it couldn't do so -- the idea just isn't practical). Maintaining a history of versions of named functions would be possible, but Emacs doesn't do that.

If you want to experiment with elisp in a safe environment, simply start a separate instance of Emacs.

| improve this answer | |

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.