From ce7ce9908b2a3f32cbfabb6b00ad52e105f0c7f5 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Fri, 6 Jul 2018 13:32:06 +0200 Subject: rem: extract summary (subject) from events --- rem.lua | 13 +++++++++---- toreminder.lua | 3 ++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/rem.lua b/rem.lua index ed3a355..c8826dc 100644 --- a/rem.lua +++ b/rem.lua @@ -247,7 +247,7 @@ local rem_of_vcalendars do return nil end - local msg_of_description = function (val) + local string_of_textdata = function (val) local sane = unescape_string (val.value) return trim_whitespace (sane) @@ -259,7 +259,7 @@ local rem_of_vcalendars do local rem_of_vevent = function (ev) local dtstart, dtend - local date, msg + local date, msg, msg_desc local vals = ev.value local nvals = #vals @@ -269,11 +269,12 @@ local rem_of_vcalendars do if val.kind == "other" then local valname = val.name - if valname == "description" then msg = msg_of_description (val) + if valname == "summary" then msg = string_of_textdata (val) + elseif valname == "description" then msg_desc = string_of_textdata (val) elseif valname == "dtstart" then dtstart = val elseif valname == "dtend" then dtend = val else - noiseln ("rem_of_vevent: ignoring value [%s]", valname) + debugln ("rem_of_vevent: ignoring value [%s]", valname) end else end @@ -289,6 +290,10 @@ local rem_of_vcalendars do error ("could not derive message text from event values") end + if msg_desc ~= nil then + msg = stringformat ("%s (%s)", msg, msg_desc) + end + return stringformat ("REM %s MSG %s", date, msg_of_string (msg)) end diff --git a/toreminder.lua b/toreminder.lua index e0216f4..5fe9e4b 100755 --- a/toreminder.lua +++ b/toreminder.lua @@ -3,7 +3,7 @@ local cal = require "cal" local rem = require "rem" local common = require "common" -common.set_verbosity (2) +common.set_verbosity (1) local main = function (argv) local ok, parsed = cal.parse_stdin () @@ -12,6 +12,7 @@ local main = function (argv) end local ok = rem.output_calendar (parsed) + print "" return ok and 0 or -1 end -- cgit v1.2.3