I want to have a single .emacs file, under version control. Unfortunately, different systems have different versions of Emacs running. How do I detect the Emacs version from within Elisp?


You can test variables emacs-major-version and emacs-minor-version, which return numbers.

You can also use functions (predicates) version<, version<=, and version= to test. Or functions version-list-<, version-list-<=, version-list=, and version-list-not-zero, together with function version-to-list.

Function emacs-version (or just version) returns a string completely describing the version.

| improve this answer | |
  • Thanks. Just what I wanted. I did an apropos but didn't find those. – vy32 Mar 8 '18 at 1:22

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.