|
Warning: this is an htmlized version!
The original is here, and the conversion rules are here. |
-- This file:
-- http://angg.twu.net/LATEX/myrepl.lua.html
-- http://angg.twu.net/LATEX/myrepl.lua
-- (find-angg "LATEX/myrepl.lua")
-- See: (find-es "luatex" "require")
-- (find-es "lua5" "lua-repl-0.5")
-- http://tug.org/pipermail/luatex/2015-February/005073.html
-- Usage:
-- \directlua{dofile "lualoader.lua"}
-- \directlua{dofile "myrepl.lua"}
-- \directlua{myrepl()}
HOME = os.getenv "HOME"
repldir = HOME.."/usrc/lua-repl-0.5/"
-- repldir = "/tmp/lua-repl-0.5/"
package.path = ""
package.path = repldir.."?/init.lua;"..package.path
package.path = repldir.."?.lua;" ..package.path
repl = require "repl"
sync = require "repl.sync"
function sync:showprompt(p) io.write(p == ">" and ">>> " or ">>>> ") end
function sync:lines() return io.stdin:lines() end
function sync:displayerror(err) print(err) end
function sync:displayresults(results)
if results.n == 0 then return end
print(unpack(results, 1, results.n))
end
function myrepl() print(); sync:run() end