1.1.1 Installation

emacs-ffi’ is not yet available in any ELPA archives. In Emacs 30 (and later), one can use the builtin ‘use-package’ with ‘:vc’ keyword support. In older versions of Emacs, the installation is done manually.

For Emacs 30 and later, one may install ‘emacs-ffi’ using something like the below:

(use-package package-vc :ensure nil :demand t
  :custom
  (package-vc-allow-build-commands t))

(use-package ffi :ensure nil
  :unless noninteractive
  :vc (ffi :url "https://github.com/emacs-ffi/emacs-ffi"
           :branch "master" ;; use branch "dev" for latest pre-release
           :rev :newest
           :make "vc-install"
           :lisp-dir "./src"
           :doc "./src/emacs-ffi.texi"))

For Emacs-29 and earlier, proceed by cloning the emacs-ffi repository. Then build and install the package via the ‘make install’ target. To confirm that the installation is working as intended:

  1. Ensure that the tests pass using compiled package via ‘make check’.
  2. If the above succeeds, ensure that the tests pass using the version of the package that’s actually installed via:
    make check USE_BUILTIN_LIB=1 EMACS="emacs -L /path/to/ffi/installation"
    

Finally, if you have the Guix package manager, you can install a relatively recent release via the ‘emacs-ffi’ package. Additionally, the guix.scm file in the repository is sufficient for testing out the development version of the library in an isolated environment. To activate this environment, evaluate something like the below in an interactive shell at the root of the repository checkout. Once that’s done, the subsequent code snippets can be evaluated in an Emacs instance started from the Guix shell environment.

guix shell --pure -CPWN \ -E '.*GTK.*|.*XDG.*|.*DISPLAY.*|TERM|INSIDE_EMACS' \
-m guix.scm