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 ?

1 Answer 1


Just redefine the function with its original definition again.

You'll probably find this article very helpful:

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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