Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reset definitions and reload .emacs without closing, or restart Emacs and re-open buffers

Tags:

As far as I understand, the following sequence of commands

M-x load-file ENTER
~/.emacs
ENTER

would re-load my .emacs file. However, from what I have read on other forums, they are not guaranteed to give me a totally revised configuration, i.e. they would force Emacs to parse the new configuration file and reload modified variable and function definitions, but they would not remove previously loaded definitions.

With this, my questions are:

  1. Is it possible to clear ups Emacs's definitions in memory and re-load .emacs without having to fully restart Emacs?
  2. If the above is not possible, is there a way to restart Emacs (so that I parses my .emacs file from scratch) asking it to re-open all buffers that I have open?
like image 894
Amelio Vazquez-Reina Avatar asked Oct 04 '11 20:10

Amelio Vazquez-Reina


People also ask

How do I reload a .Emacs file?

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 I restart Emacs?

There is no way to restart an Emacs session once you have killed it. You can, however, arrange for Emacs to record certain session information, such as which files are visited, when you kill it, so that the next time you restart Emacs it will try to visit the same files and so on.

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.


2 Answers

Undoing everything that might have been done in your .emacs is impossible.

You can save and restore an emacs session with desktop. Quit with M-x desktop-save RET C-x C-c and then restore with emacs -f desktop-read.

See (info "(emacs) Saving Emacs Sessions") for more information. (You can also customize desktop-save-mode so that this behavior is the default.)

like image 137
Michael Hoffman Avatar answered Oct 10 '22 18:10

Michael Hoffman


This question is a duplicate, but as it has an accepted answer I'll repeat my comments about the Desktop library which is that it stores a certain amount of state (modes and local variables) with each buffer that it saves, and it then restores that same state when it reloads those files.

In your case, of course, this is exactly what you don't want to happen.

See Reload .emacs for all active buffers for a simple way to revert (reload) all the buffers.

Combining the two approaches would let you restart Emacs, with Desktop restoring the files, at which point you could revert all the files.

like image 31
phils Avatar answered Oct 10 '22 16:10

phils