Next: , Previous: , Up: Evaluate Emacs Lisp Expressions   [Index]


F.1.4 Eval Defun

eval-defun

C-M-x

Evaluate the top-level form containing point, or after point. If the current defun is actually a call to ‘defvar’ or ‘defcustom’, evaluating it this way resets the variable using its initial value expression.

If ‘eval-expression-debug-on-error’ is non-nil, which is the default, this command arranges for all errors to enter the debugger.

With a prefix argument, instrument the code for Edebug.

This command is designed for a typical hacker’s write-eval-test cycle. You can type ‘C-M-x’ anywhere in a form, and it will evaluate the outer-most form, ensuring that you won’t accidentally evaluate only a part of a larger form.

It has built-in support for Edebug. Using the universal argument ‘C-u’ Emacs will evaluate the form as normal, but enable debug instrumentation. The next time it is run it kicks off the debugger and lets you step through the code, with every evaluation showing its value (if any) in the echo area.