% This file:
%   http://angg.twu.net/LATEX/2018repl-test.tex
%   http://angg.twu.net/LATEX/2018repl-test.tex.html
% This is a test for the "lua-repl" module of dednat6.
% See: http://angg.twu.net/luatex.html#repl
%
% (defun c () (interactive) (find-LATEXsh "lualatex -record 2018repl-test.tex"))
% (defun e () (interactive) (find-LATEX "2018repl-test.tex"))
% (defun u () (interactive) (find-latex-upload-links "2018repl-test"))
% (find-es "luatex" "show")
%
% Eduardo Ochs, 2018fev01.
%
\documentclass[oneside]{book}
\begin{document}

% Load dednat6
\catcode`\^^J=10
\directlua{dednat6dir = "dednat6/"}
\directlua{dofile(dednat6dir.."dednat6.lua")}
\directlua{texfile(tex.jobname)}
\directlua{verbose()}
%\directlua{output(preamble1)}
\def\expr#1{\directlua{output(tostring(#1))}}
\def\eval#1{\directlua{#1}}
\def\pu{\directlua{pu()}}

% See http://tug.org/pipermail/luatex/2018-January/006737.html
\def\alpha#1#2{beta#1gamma#2delta}
\directlua{
  print(token.get_macro("alpha"))
  print(token.get_meaning("alpha"))
  print(token.set_macro("alpha","whatever"))
  print(token.get_macro("alpha"))
  print(token.get_meaning("alpha"))
}

% Define \repl and run it
\def\repl{\eval{sync:run()}}
\repl

\end{document}

% ----------------------------------------







%  _____         _       
% |_   _|__  ___| |_ ___ 
%   | |/ _ \/ __| __/ __|
%   | |  __/\__ \ |_\__ \
%   |_|\___||___/\__|___/
%                        
% For information on how to use eepitch blocks from Emacs see section
% 6 here: http://angg.twu.net/eev-intros/find-eev-quick-intro.html

 (eepitch-shell)
 (eepitch-kill)
 (eepitch-shell)
cd ~/LATEX/
lualatex 2018repl-test

print(token.get_macro("alpha"))
print(token.get_meaning("alpha"))
print(token.set_macro("alpha","whatever"))
print(token.get_macro("alpha"))
print(token.get_meaning("alpha"))



 (eepitch-shell)
 (eepitch-kill)
 (eepitch-shell)
rm -rfv /tmp/2018repl-test.tgz
rm -rfv /tmp/edrx-latex/
cd /tmp/
wget http://angg.twu.net/LATEX/2018repl-test.tgz
mkdir  /tmp/edrx-latex/
tar -C /tmp/edrx-latex/ -xvzf /tmp/2018repl-test.tgz
cd     /tmp/edrx-latex/
lualatex 2018repl-test.tex

print(token.get_macro("alpha"))
print(token.get_meaning("alpha"))
print(token.set_macro("alpha","whatever"))
print(token.get_macro("alpha"))
print(token.get_meaning("alpha"))
