4

I am using different versions of emacs, on different computers. On some of those (work computers) I don't really have a choice to update, whereas for my personal computers, I like to run the latest stable release.

I carry a customization "package" around, with init files and third-party packages, downloaded either separately or with the package manager.

Usually it works fine, but from time to time, after installing a new package on one of the devices, I will run into errors with the others.

It may happen that the package is simply not compatible with the older version of emacs (in which case I have no choice but to use package-load-list to exclude those packages), but more frequently the package is compatible, but its compiled version isn't.

A work-around is to recompile the package on the older emacs, but this is a hassle, and I'm always worried that I will lose on performances (the machines running older emacses are typically faster than my personal computer).

Hence my question: is there a way to have emacs automatically manage this, for example by indicating with each compiled file the version for which it was compiled, and recompiling if no compatible version is found?

Or, at least, is there a way to tell emacs to always compile packages for some specified older version of emacs?

T. Verron
  • 4,233
  • 1
  • 22
  • 55
  • If you take a look at a `.elc` file, you'll see that it already records the version of Emacs in which it was compiled (albeit in human-readable format; I'm unsure whether that's encoded elsewhere in the file as well); so automatically recompiling when the existing `.elc` came from a newer Emacs seems like it should be do-able. (It also seems like a potential enhancement to [auto-compile](https://github.com/emacscollective/auto-compile), although it's unclear to me what the performance implications of this would be.) – phils Sep 10 '18 at 12:33
  • 1
    With `package.el`, I have the setting `(setq package-user-dir (concat "~/.emacs.d/elpa-" emacs-version))` so each version of Emacs keeps it owns packages. – xuchunyang Sep 10 '18 at 12:35
  • @xuchunyang Does it work well with `package-load-list`, ie does each emacs version redownload its packages when needed, ensuring a consistent work environment across versions? If the answer is yes, you could promote your comment to an answer, that's definitely a solution (albeit a little extreme) to my problem. -- Edit: after a quick test, it seems to be working as expected. – T. Verron Sep 10 '18 at 12:56
  • @phils Interesting. Is auto-compile also the one in charge of compiling elisp libraries installed through the package manager? – T. Verron Sep 10 '18 at 12:57
  • @T.Verron No, `auto-compile` is not part of Emacs. The prior mention is a link to its repository. – phils Sep 10 '18 at 13:02
  • @xuchunyang Apparently with this snippet of code, emacs did redownload some of my packages, but not all. At least it loaded those which had a relevant `use-package` directive in my init file. But I guess that it shouldn't be too hard to propagate the list of installed packages across versions. – T. Verron Sep 10 '18 at 13:05

0 Answers0