aboutsummaryrefslogtreecommitdiff
path: root/mbox.lua
diff options
context:
space:
mode:
authorAdrian C. (anrxc) <anrxc@sysphere.org>2010-03-14 01:55:33 +0100
committerAdrian C. (anrxc) <anrxc@sysphere.org>2010-03-14 01:55:33 +0100
commit237470c8f45190b213e3a173ce6ae1a74b3e11fe (patch)
tree7f53c8144761947d4bde20715bcad34f4be0d6c0 /mbox.lua
parent9a82d4113a8271b7dfc7506f2b07379e3ede89a8 (diff)
downloadvicious-legacy-237470c8f45190b213e3a173ce6ae1a74b3e11fe.tar.xz
API: transform widgets namespace table to a directory
Diffstat (limited to 'mbox.lua')
-rw-r--r--mbox.lua50
1 files changed, 0 insertions, 50 deletions
diff --git a/mbox.lua b/mbox.lua
deleted file mode 100644
index bc815ae..0000000
--- a/mbox.lua
+++ /dev/null
@@ -1,50 +0,0 @@
----------------------------------------------------
--- Licensed under the GNU General Public License v2
--- * (c) 2010, Adrian C. <anrxc@sysphere.org>
----------------------------------------------------
-
--- {{{ Grab environment
-local type = type
-local io = { open = io.open }
-local setmetatable = setmetatable
-local string = { gfind = string.gfind }
-local helpers = require("vicious.helpers")
--- }}}
-
-
--- Mbox: provides the subject of last e-mail in a mbox file
-module("vicious.mbox")
-
-
--- {{{ Mailbox widget type
-local function worker(format, warg)
- if type(warg) ~= "table" then mbox = warg end
- -- mbox could be huge, get a 30kb chunk from EOF
- -- * attachments could be much bigger than this
- local f = io.open(mbox or warg[1])
- f:seek("end", -30720)
- local txt = f:read("*all")
- f:close()
-
- -- Default value
- local subject = "N/A"
-
- -- Find all Subject lines
- for i in string.gfind(txt, "Subject: ([^\n]*)") do
- subject = i
- end
-
- -- Check if we should scroll, or maybe truncate
- if type(warg) == "table" then
- if warg[3] ~= nil then
- subject = helpers.scroll(subject, warg[2], warg[3])
- else
- subject = helpers.truncate(subject, warg[2])
- end
- end
-
- return {helpers.escape(subject)}
-end
--- }}}
-
-setmetatable(_M, { __call = function(_, ...) return worker(...) end })