I have both .el
and the byte compiled version (.elc
) of an elisp file. Accidentally I delete the .el
file. Can I retrieve the .el
file from its .elc
version? Is an .elc
file without its .el
file functional?
2 Answers
I have both .el and the byte compiled version (.elc) of an elisp file. Accidentally I delete the .el file. Can I retrieve the .el file from its .elc version?
In practice, no.
In theory you could use the elc file to produce an el file with human readable definitions. However, this probably wouldn't look the same as the original file you deleted, due to macros and compiler optimizations, and even then I'm not aware of any libraries that do that.
Is an .elc file without its .el file functional?
Yes, Emacs is happy to load a .elc
file entirely by itself. No .el
file is necessary at all.
In fact, even when you do have both in the same directory, Emacs will usually load the elc anyway.
-
You do not need "both in the same directory". You do not need both. The *.elc suffices, at least if your Emacs version is compatible with it (e.g. with the Emacs version it was compiled from).– DrewAug 8, 2015 at 14:26
-
@Name The second sentence is complementary information. The answer is "Yes". Emacs will load 'elc' files just fine without the '.el' file. Aug 8, 2015 at 14:30
-
2"In fact, even when you do have both in the same directory, Emacs will usually load the elc anyway.".. If
load-prefer-newer
is set tot
in emacs 24.4+, newer of the .el/.elc will be loaded. Aug 11, 2015 at 13:38
Check for a *.el~
file - there may be an Emacs backup of your missing *.el
file (which some tools will hide from you in their UI, so use something like ls -a
).