Previous: , Up: Preparing Lisp code for distribution   [Contents][Index]

44.6 Supporting older versions of Emacs

Packages that wish to support older releases of Emacs, without giving up on newer functionality from recent Emacs releases, one can make use of the Compat package on GNU ELPA. By depending on the package, Emacs can provide compatibility definitions for missing functionality.

The versioning of Compat follows that of Emacs, so next to the oldest version that a package relies on (via the emacs-package), one can also indicate what the newest version of Emacs is, that a package wishes to use definitions from:

;; Package-Requires: ((emacs "27.2") (compat "29.1"))

Note that Compat provides replacement functions with extended functionality for functions that are already defined (sort, assoc, …). These functions may have changed their calling convention (additional optional arguments) or may have changed their behavior. These functions must be looked up explicitly with compat-function or called explicitly with compat-call. We call them Extended Definitions. In contrast, newly Added Definitions can be called as usual.

Macro: compat-call fun &rest args

This macro calls the compatibility function fun with args. Many functions provided by Compat can be called directly without this macro. However in the case where Compat provides an alternative version of an existing function, the function call has to go through compat-call.

Macro: compat-function fun

This macro returns the compatibility function symbol for fun. See compat-call for a more convenient macro to directly call compatibility functions.

For further details on how to make use of the package, see Usage in "Compat" Manual. In case you don’t have the manual installed, you can also read the Online Compat manual.

Previous: Interfacing to an archive web server, Up: Preparing Lisp code for distribution   [Contents][Index]