3

I recently started using emacs and extending it with elisp. That makes me wonder: is emacs the only program that can evaluate elisp expressions or do dedicated elisp-interpreters exist?

choroba
  • 231,213
  • 25
  • 204
  • 289
M0M0
  • 200
  • 9
  • Elisp does stand for Emacs lisp, so it is unlikely that you'll find another program to run it. There are, however, lightweight interpreter for other dialects of Lisp, such as guile (implements Scheme) or clisp (implements Lisp). – user4815162342 Sep 21 '21 at 16:44

2 Answers2

7

You can use Elisp outside emacs if you use Guile

here is de documentation:

https://www.gnu.org/software/guile/manual/html_node/Using-Other-Languages.html

☸ sandas-nonpro (qa) in ~ via ⬢ v12.4.0 took 11s
❯ guile                                                                                                                                  ~
GNU Guile 3.0.7
Copyright (C) 1995-2021 Free Software Foundation, Inc.

Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'.
This program is free software, and you are welcome to redistribute it
under certain conditions; type `,show c' for details.

Enter `,help' for help.
scheme@(guile-user)> ,language elisp
Happy hacking with Emacs Lisp!  To switch back, type `,L scheme'.
elisp@(guile-user)> (printf "Hello World!)

You can also write scripts in emacs lisp like this:

☸ sandas-nonpro (qa) in ~ via ⬢ v8.9.4
❯ cat > test.el                                                                                                                          ~
:;exec emacs -batch -l "$0" -f main "$@"

(defun main ()
  (print (version))
  (print (format "I did it. you passed in %s" command-line-args-left)))

;; Local Variables:
;; mode: emacs-lisp
;; End:

☸ sandas-nonpro (qa) in ~ via ⬢ v12.4.0
❯ chmod +x test.el                                                                                                                       ~

☸ sandas-nonpro (qa) in ~ via ⬢ v12.4.0
❯ ./test.el cat dog                                                                                                                      ~

"GNU Emacs 28.0.50 (build 2, x86_64-apple-darwin20.6.0, NS appkit-2022.60 Version 11.5.2 (Build 20G95))
 of 2021-09-15"

"I did it. you passed in (cat dog)"

But I encourage to use it inside emacs, use ielm buffer alot or eshell which is a shell that you can combine emacs lisp s-expressions with shell commands. and obviously gccemacs, if you pan to do intensive work in emacs.

anquegi
  • 11,125
  • 4
  • 51
  • 67
  • 1
    There are some more detailed notes on scripting elisp (with emacs) at https://stackoverflow.com/questions/10210742/run-elisp-program-without-emacs – phils Sep 23 '21 at 00:45
3

CLOCC/CLLIB/elisp.lisp allows running Emacs-Lisp code from Common Lisp.

sds
  • 58,617
  • 29
  • 161
  • 278