aboutsummaryrefslogtreecommitdiff
path: root/mbox.lua
diff options
context:
space:
mode:
authorAdrian C. (anrxc) <anrxc@sysphere.org>2009-10-04 00:28:54 +0200
committerAdrian C. (anrxc) <anrxc@sysphere.org>2009-10-04 16:06:20 +0200
commitc55614d449217c9478f37de91c64148c6d56dc35 (patch)
tree12c68e82132cb7c428105bff8efa62b7fa91a6bf /mbox.lua
parentc2bba8953c42640254ca579278dfdbbc79798caa (diff)
downloadvicious-legacy-c55614d449217c9478f37de91c64148c6d56dc35.tar.xz
mbox: don't hide when there is no mail
Diffstat (limited to 'mbox.lua')
-rw-r--r--mbox.lua13
1 files changed, 6 insertions, 7 deletions
diff --git a/mbox.lua b/mbox.lua
index 4d0e5be..108a5c6 100644
--- a/mbox.lua
+++ b/mbox.lua
@@ -17,18 +17,15 @@ module("vicious.mbox")
-- {{{ Mailbox widget type
local function worker(format, mbox)
- local f = io.open(mbox)
-- mbox could be huge, get a 15kb chunk from EOF
-- * attachments could be much bigger than this
+ local f = io.open(mbox)
f:seek("end", -15360)
-
- local text = f:read("*all")
+ local txt = f:read("*all")
f:close()
- for match in string.gfind(text, "Subject: ([^\n]*)") do
- subject = match
- end
-
+ -- Find all Subject lines
+ for s in string.gfind(txt, "Subject: ([^\n]*)") do subject = s end
if subject then
-- Spam sanitize only the last subject
subject = helpers.escape(subject)
@@ -37,6 +34,8 @@ local function worker(format, mbox)
subject = helpers.truncate(subject, 22)
return {subject}
+ else
+ return {"N/A"}
end
end
-- }}}