12

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?

12

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). – Drew Aug 8 '15 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. – Malabarba Aug 8 '15 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 to t in emacs 24.4+, newer of the .el/.elc will be loaded. – Kaushal Modi Aug 11 '15 at 13:38
3

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

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.