When I add some lisp program in the init.el. I don't want to restart emacs in order to make effect. Then how can I do that?


In addition to Drew's answer, if you add more than one expression, and don't want to have to evaluate them all individually, there's eval-region. Its docstring:

Execute the region as Lisp code.

Select the region (move point to before the first expression, press C-space, move point to after the expression), then run M-x eval-region.

| improve this answer | |

Evaluate it: call it with its arguments, using, for example C-x C-e. If the function foo takes arguments arg1 and arg2, type (foo arg1 arg2), put the cursor after ), and hit C-x C-e.

But if you are going to use some Emacs Lisp you really should start to read the Intro to Emacs Lisp manual - use C-h i then choose Emacs Lisp Intro.

| improve this answer | |

If your function has defvar or defcustom and you want those reset as part of the eval, then consider C-M-x (eval-defun). A plain eval will not reset previous values of the defvars, if any.

| 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.