Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I easily reload Emacs lisp code as I am editing it?

Tags:

emacs

elisp

As an Emacs beginner, I am working on writing a minor mode. My current (naive) method of programming elisp consists of making a change, closing out Emacs, restarting Emacs, and observing the change. How can I streamline this process? Is there a command to refresh everything?

like image 774
davidscolgan Avatar asked Oct 26 '10 02:10

davidscolgan


People also ask

How do I reload Emacs?

You can use the command load-file ( M-x load-file , then press return twice to accept the default filename, which is the current file being edited). You can also just move the point to the end of any sexp and press C-x C-e to execute just that sexp.

How do you reload in Doom Emacs?

Press M-x and select doom/reload to apply the changes; If changes doesn't apply, close and re-open the Emacs.

How do I run a Lisp in Emacs?

In a fresh Emacs window, type ESC-x lisp-interaction-mode . That will turn your buffer into a LISP terminal; pressing Ctrl+j will feed the s-expression that your cursor (called "point" in Emacs manuals' jargon) stands right behind to LISP, and will print the result.

What does #' mean in Emacs Lisp?

function (aka #' ) is used to quote functions, whereas quote (aka ' ) is used to quote data.


2 Answers

You might try using M-C-x (eval-defun), which will re-evaluate the top-level form around point. Unlike M-x eval-buffer or C-x C-e (exal-last-sexp), this will reset variables declared with defvar and defcustom to their initial values, which might what's tripping you up.

like image 187
Sean Avatar answered Sep 25 '22 17:09

Sean


Also try out C-u C-M-x which evaluates the definition at point and sets a breakpoint there, so you get dropped into the debugger when you hit that function.

M-x ielm is also very useful as a more feature-rich Lisp REPL when developing Emacs code.

like image 43
Joakim Hårsman Avatar answered Sep 21 '22 17:09

Joakim Hårsman