|
Warning: this is an htmlized version!
The original is here, and the conversion rules are here. |
-- This file:
-- http://anggtwu.net/LUA/SaveM1.lua.html
-- http://anggtwu.net/LUA/SaveM1.lua
-- (find-angg "LUA/SaveM1.lua")
-- Author: Eduardo Ochs <eduardoochs@gmail.com>
--
-- (defun e () (interactive) (find-angg "LUA/SaveM1.lua"))
-- (find-es "maxima" "same-Ms")
Path.addLUAtopath()
SaveM = Class {
type = "SaveM",
fromfile = function (fname) return SaveM {o=ee_readfile(fname)} end,
__index = {
delinit = function (sm)
local bigstr = sm.o
local newpos
for pos in bigstr:gmatch("()%(%%i1%)", print) do
newpos = pos
end
sm.o = bigstr:sub(newpos or 1)
return sm
end,
delstrnl = function (sm)
sm.o = sm.o:gsub("%$\n", "$")
return sm
end,
getposs = function (sm)
local poss = VTable {}
for pos,n in sm.o:gmatch("()%(%%i([0-9]+)%)") do
print(pos, n)
poss[n+0] = pos
end
-- poss[#poss+1] = #sm.o
sm.poss = poss
return sm
end,
sub = function (sm,a,b)
print(a,b)
return sm.o:sub(sm.poss[a], sm.poss[b]-1)
end,
},
}
--[[
* (eepitch-lua51)
* (eepitch-kill)
* (eepitch-lua51)
dofile "SaveM1.lua"
sm = SaveM.fromfile "/tmp/o"
sm:delinit():delstrnl():getposs()
= sm.o
= sm.poss
= sm.poss[1]
= sm.poss[2]
= sm.o:sub(sm.poss[1], sm.poss[2]-1)
= sm.o:sub(sm.poss[2], sm.poss[3]-1)
= sm:sub(1,4)
= sm:sub(1,22)
--]]
-- Local Variables:
-- coding: utf-8-unix
-- End: