Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/syohex/emacs-lua
Lua engine from Emacs Lisp
https://github.com/syohex/emacs-lua
Last synced: about 2 months ago
JSON representation
Lua engine from Emacs Lisp
- Host: GitHub
- URL: https://github.com/syohex/emacs-lua
- Owner: syohex
- License: gpl-3.0
- Created: 2016-02-19T11:24:58.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2022-01-24T05:07:03.000Z (almost 3 years ago)
- Last Synced: 2024-11-05T15:49:55.292Z (about 2 months ago)
- Language: C
- Size: 22.5 KB
- Stars: 18
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: COPYING
Awesome Lists containing this project
README
# lua-emacs
Lua script engine from Emacs Lisp. This package is inspired by [mruby-lua](https://github.com/dyama/mruby-lua).
## How to build
```
% make LUA_VERSION=5.2
# Default Lua version is 5.2. You need to specify if you use other than 5.2.
```## Sample Code
``` lisp
(defun lua-factorial ()
(interactive)
(let* ((state (lua-new))
(got (lua-do-string state
"
function factorial(n)
if n <= 1 then
return 1
else
return n * factorial(n - 1)
end
endans = factorial(10)
")))
(message "@@ %s" (lua-get-global state "ans"))))
;; => @@ 3628800
`````` lisp
(defun lua-set-global-test ()
(interactive)
(let ((state (lua-new)))
(lua-set-global state "a" "bar")
(lua-set-global state "b" 100)
(lua-set-global state "c" t)
(lua-do-string state "
print(a)
print(b)
print(c)
") ;; Output to stdout
(message "@@ a=%s, b=%s, c=%s"
(lua-get-global state "a")
(lua-get-global state "b")
(lua-get-global state "c"))));; => @@ a=bar, b=100, c=t
```