CommonLispForEmacs

Some CommonLisp functions and macros can be used in EmacsLisp programs. For GNU Emacs version 24.3 and above, you can just add the following to your program:

    (require 'cl-lib)

For earlier GNU Emacs and XEmacs, `cl-lib.el’ can be downloaded from GNU ELPA: https://elpa.gnu.org/packages/cl-lib.html

There is a separate InfoMode manual for library `cl-lib.el’. See Info node (cl).

If you need only Common Lisp macros, that is, you do not need any Common Lisp functions at runtime, then you can just require library `cl-lib.el’ (or library `cl.el’) a compile time, like this:

    (eval-when-compile (require 'cl-lib))

Some aspects of EmacsLisp can’t be changed or emulated transparently: you don’t get packages, you don’t get LexicalBinding unless you ask for it with -*- lexical-binding: t -*-, you don’t get KeywordArguments unless you define your function with ‘cl-defun’ and so on. See the Info node Common Lisp Compatibility (cl).

Here are some things extending cl-lib.el,

Usage of cl.el in older Emacs

As noted above, GNU Emacs earlier than 24.3 and XEmacs don’t come with cl-lib.el. They instead have cl.el which provides the same functions, but is somewhat problematic as it defines them in the global namespace rather than prefixing with ‘cl-’. See Coding Conventions:

   • If you need Common Lisp extensions, use the ‘cl-lib’ library rather
     than the old ‘cl’ library.  The latter does not use a clean
     namespace (i.e., its definitions do not start with a ‘cl-’ prefix).
     If your package loads ‘cl’ at run time, that could cause name
     clashes for users who don’t use that package.

     There is no problem with using the ‘cl’ package at _compile_ time,
     with ‘(eval-when-compile (require 'cl))’.  That’s sufficient for
     using the macros in the ‘cl’ package, because the compiler expands
     them before generating the byte-code.  It is still better to use
     the more modern ‘cl-lib’ in this case, though.

EmacsCommonLisp is (or will soon be) a full implementation of CommonLisp.


CategoryCode CategoryExtensionLanguage