Warning: this is an htmlized version!
The original is here, and
the conversion rules are here.
-- This file:
--   http://anggtwu.net/LUA/MaximaMsg1.lua.html
--   http://anggtwu.net/LUA/MaximaMsg1.lua
--          (find-angg "LUA/MaximaMsg1.lua")
-- Author: Eduardo Ochs <eduardoochs@gmail.com>
--
-- A tool to download messages from the archive of the Maxima mailing list.
--   (find-fline "~/usrc/maxima-msgs/")
--
-- (defun e () (interactive) (find-angg "LUA/MaximaMsg1.lua"))
--
-- «.MaximaDay»			(to "MaximaDay")
-- «.all-cached-messages»	(to "all-cached-messages")
--
-- (find-angg "LUA/lua50init.lua" "fileexists")
-- (find-maximamsg "59113685 202501 01" "Stavros: Should polish-like expressions be documented?")

lynx_cmd = function (url, width)
    return format("lynx -dump -width=%d '%s'", width or 205, url)
  end
lynx_run = function (url, width)
    return getoutput(lynx_cmd(url, width))
  end

--[[
* (eepitch-lua51)
* (eepitch-kill)
* (eepitch-lua51)
dofile "MaximaMsg1.lua"
= lynx "https://sourceforge.net/p/maxima/mailman/message/59113712/"
= lynx "https://sourceforge.net/p/maxima/mailman/maxima-discuss/?viewmonth=202501&viewday=01"

--]]

LynxCache = Class {
  type = "LynxCache",
  from = function (url,stem) return LynxCache {url=url, stem=stem} end,
  messages0 = function () return LynxCache({}):run "ls ????????" end,
  messages  = function () return VTable(splitlines(LynxCache.messages0())) end,
  __index = {
    dir = "~/usrc/maxima-msgs/",
    fname      = function (lc) return lc.dir..lc.stem end,
    fileexists = function (lc) return fileexists(ee_expand(lc:fname())) end,
    fileload   = function (lc) return ee_readfile(lc:fname()) end,
    lynx_cmd   = function (lc) return lynx_cmd(lc.url) end,
    lynx_run   = function (lc) return lynx_run(lc.url) end,
    lynx_save  = function (lc)
        local output = lc:lynx_run()
        getoutput(format("mkdir -p %s", lc.dir))
        ee_writefile(lc:fname(), output)
        return output
      end,
    lynx = function (lc)
        if lc:fileexists() then return lc:fileload() end
        return lc:lynx_save()
      end,
    run0 = function (lc,cmd) return format("cd %s && %s", lc.dir, cmd) end,
    run  = function (lc,cmd) return getoutput(lc:run0(cmd)) end,
    delete  = function (lc,str) return getoutput(lc:delete0(str)) end,
    delete0 = function (lc,str)
        return format("rm -v %s%s", lc.dir, str or lc.stem)
      end,
  },
}

--[[
* (eepitch-lua51)
* (eepitch-kill)
* (eepitch-lua51)
dofile "MaximaMsg1.lua"
lc = LynxCache.from("http://anggtwu.net/", "o")
= lc:fname()
= lc:fileexists()
= lc:lynx()
= lc:lynx()
= lc:delete0("o")
= lc:delete0()
= lc:delete()
= lc:delete()
* (find-sh0 "rm -v ~/usrc/maxima-msgs/o")
** (find-fline "~/usrc/maxima-msgs/")
= lc:run "ls ????????"
= LynxCache.messages()

--]]

shortfrom_table = VTable {
  ["Barton W. <wi...@un...>"]    = "BWillis",
  ["Daniel V. <dan...@ya...>"]   = "DVolinski",
  ["Eduardo O. <edu...@gm...>"]  = "Edrx",
  ["El O. De M. <obs...@gm...>"] = "ElObservatorio",
  ["Gunter K. <gun...@gm...>"]   = "GKoenigsmann",
  ["Jaime V. <vi...@fe...>"]     = "JVillate",
  ["Leo B. <Leo...@um...>"]      = "LButler",
  ["Majzoub, E. <eri...@um...>"] = "EMajzoub",
  ["Michel G. <mg...@gm...>"]    = "MGosse",
  ["Michel T. <ta...@lp...>"]    = "MTalon",
  ["Oscar B. <osc...@gm...>"]    = "OBenjamin",
  ["Raymond T. <toy...@gm...>"]  = "RToy",
  ["Richard F. <fa...@gm...>"]   = "RFateman",
  ["Robert D. <rob...@gm...>"]   = "RDodier",
  ["Stavros M. <mac...@gm...>"]  = "Stavros",
  ["Viktor T. T. <vt...@vt...>"] = "VToth",
  ["Wolfgang D. <wol...@da...>"] = "WDautermann",
  ["ehm <eri...@gm...>"]         = "EMajzoub",
  ["richard <rp...@cl...>"]      = "rpx",
}

MaximaMsg = Class {
  type    = "MaximaMsg",
  from    = function (id) return MaximaMsg {id=id} end,
  __index = {
    stem = function (mm) return mm.id end,
    url = function (mm)
        local fmt = "https://sourceforge.net/p/maxima/mailman/message/%s/"
        return format(fmt, mm.id)
      end,
    lynx  = function (mm) return LynxCache.from(mm:url(), mm:stem()):lynx() end,
    lines = function (mm) return splitlines(mm:lynx()) end,
    subjline0 = function (mm)
        for _,li in ipairs(mm:lines()) do
          if li:match("%[Maxima%-discuss%]") then return li end
        end
      end,
    subjline = function (mm)
        return (mm:subjline0():gsub("%[Maxima%-discuss%] ", ""))
      end,
    fromline = function (mm)
        return mm:lynx():match("(From:[^\n]*)")
      end,
    from = function (mm)
        return mm:fromline():match("^From: (.-) %- ")
      end,
    shortfrom = function (mm)
        local a = mm:from()
        if shortfrom_table[a] then return shortfrom_table[a] end
        return a:match("^(.-) <") or "???"
      end,
    date = function (mm)
        return mm:fromline():match("(%d%d%d%d)%-(%d%d)%-(%d%d)")
      end,
    synthstr = function (mm)
        local y,m,d = mm:date()
        return format("%s %s%s %s", mm.id, y,m, d)
      end,
    synthsexp = function (mm)
        local fmt = '(find-maximamsg "%s" "%s: %s")'
        return format(fmt, mm:synthstr(), mm:shortfrom(), mm:subjline())
      end,
  },
}

--[[
* (eepitch-lua51)
* (eepitch-kill)
* (eepitch-lua51)
dofile "MaximaMsg1.lua"
mm = MaximaMsg.from "59113685"
= mm:lynx()
= mm:lynx()
= mm:fromline()
= mm:from()
= mm:shortfrom()
= mm:date()
= mm:subjline0()
= mm:subjline()
= mm:synthstr()
= mm:synthsexp()

ids = LynxCache.messages()
for _,id in ipairs(ids) do
  print(id, MaximaMsg.from(id):subjline())
end
for _,id in ipairs(ids) do
  print(id, MaximaMsg.from(id):from())
end

= VTable {a=4}




# (find-fline "/tmp/maximamsgs/")

= getoutput(mm:lynx0())

(find-maximamsg "59113685 202501 01" "")

(find-lynx "https://sourceforge.net/p/maxima/mailman/maxima-discuss/?viewmonth=202501&viewday=01")




--]]

-- «MaximaDay»  (to ".MaximaDay")
MaximaDay = Class {
  type    = "MaximaDay",
  from = function (y,m,d) return MaximaDay {y=y, m=m, d=d} end,
  __index = {
    stem = function (md) return format("%04d-%02d-%02d", md.y, md.m, md.d) end,
    url = function (md)
        local pre = "https://sourceforge.net/p/maxima/mailman/maxima-discuss/"
        local fmt = "%s?viewmonth=%04d%02d&viewday=%02d"
        return format(fmt, pre, md.y, md.m, md.d)
      end,
    lynx0 = function (md) return LynxCache.from(md:url(), md:stem()) end,
    lynx  = function (md) return LynxCache.from(md:url(), md:stem()):lynx() end,
    lines = function (md) return splitlines(md:lynx()) end,
    pat = "^ *(%d+)%. https://sourceforge.net/p/maxima/mailman/message/(%d+)/",
    nids = function (md)
        local A = VTable {}
        for _,li in ipairs(md:lines()) do
          local n,id = li:match(md.pat)
          if n then table.insert(A, {n,id}) end
        end
        return A
      end,
    ids = function (md)
        local A = VTable {}
        for _,nid in ipairs(md:nids()) do table.insert(A, nid[2]) end
        return A
      end,
    reload = function (md)
        print(md:lynx0():delete())
        return md 
      end,
  },
}



--[[
* (eepitch-lua51)
* (eepitch-kill)
* (eepitch-lua51)
dofile "MaximaMsg1.lua"
md = MaximaDay.from("2025", "01", "01")
md = MaximaDay.from(2025, 1, 1)
= md:stem()
= md:url()
= md:lynx()
= md:nids()
= md:ids()

* (eepitch-lua51)
* (eepitch-kill)
* (eepitch-lua51)
dofile "MaximaMsg1.lua"
ids = MaximaDay.from(2025, 1, 4):reload():ids()
ids = MaximaDay.from(2025, 1, 5):reload():ids()
= ids

for _,id in ipairs(ids) do
  local mm = MaximaMsg.from(id)
  -- print(mm:shortfrom())
  print(mm:synthsexp())
end

-- (find-angg "LUA/Calendar1.lua" "Calendar")

mdays = {31,29,31,30,31,}

--]]


cal_mes_ndias    = VTable {31, 29, 31, 30, 31, 30,   -- jan fev mar abr mai jun
                           31, 31, 30, 31, 30, 31}   -- jul ago set out nov dez

--[[
* (eepitch-lua51)
* (eepitch-kill)
* (eepitch-lua51)
dofile "MaximaMsg1.lua"
for month=1,12 do
  for day=1,cal_mes_ndias[month] do
    local md = MaximaDay.from(2024, month, day)
    print(md:ids())
  end
end

for month=1,12 do
  for day=1,cal_mes_ndias[month] do
    md = MaximaDay.from(2024, month, day)
    ids = md:ids()
    for _,id in ipairs(ids) do
      thisid = id
      print(id, MaximaMsg.from(id):synthsexp())
    end
  end
end

= md
PP(md)
= ids
= thisid

mm = MaximaMsg.from(58721097)
mm = MaximaMsg.from(58731746)
= mm:fromline()
= mm:lynx()
= mm
= mm:from()
= mm:synthsexp()



ids = LynxCache.messages()
= ids
for _,id in ipairs(ids) do
  print(id, MaximaMsg.from(id):subjline())
end
for _,id in ipairs(ids) do
  print(id, MaximaMsg.from(id):from())
end


--]]



-- «all-cached-messages»  (to ".all-cached-messages")
-- (find-fline "~/usrc/maxima-msgs/")
--[[
* (eepitch-lua51)
* (eepitch-kill)
* (eepitch-lua51)
dofile "MaximaMsg1.lua"
ids = LynxCache.messages()
for _,id in ipairs(ids) do
  -- thisid = id
  print(MaximaMsg.from(id):synthsexp())
end

* (eepitch-lua51)
* (eepitch-kill)
* (eepitch-lua51)
dofile "MaximaMsg1.lua"
mm = MaximaMsg.from(59114438)
mm = MaximaMsg.from(59114461)
mm = MaximaMsg.from(59114492)
= mm:synthsexp()

--]]








-- Local Variables:
-- coding:  utf-8-unix
-- End: