Skip to content

Instantly share code, notes, and snippets.

Created September 18, 2014 09:29
Show Gist options
  • Save anonymous/b1c2beb9ccddd2787e12 to your computer and use it in GitHub Desktop.
Save anonymous/b1c2beb9ccddd2787e12 to your computer and use it in GitHub Desktop.
supmua publish hook hack for follow-ups
#
# Publish hook that adds follow-up support to sup.
# In message view, press 'P'. You will be prompted when you want to follow up on the current message
# The mail is then archived and a reminder entry is written to /home/myuser/.sup/reminders
# A before-poll hook that retrieves the reminder again, when it's time.
#
message = chunk
if not message.instance_of? Message
say "Reminders only work for messages"
return false
end
completions = [ 'tomorrow', 'in', '1', '2', '3', 'days', 'week', 'weeks', 'month', 'months', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday' ]
answer = BufferManager.ask_many_with_completions :followup, 'Follow up when? ', completions
date = Chronic.parse answer
if date.nil?
BufferManager.flash "Could not parse date #{answer}"
return
end
message.add_label :followup
message.remove_label :inbox
Index.instance.update_message message
reminder_path = '/home/myuser/.sup/reminders'
if not File.exists? reminder_path
reminders = {}
else
reminders = YAML.load_file reminder_path
end
reminders[message.id] = date
File.open(reminder_path, 'w') { |f| f.write reminders.to_yaml }
BufferManager.flash "Marked for follow-up on #{date.strftime '%d.%m.%Y %H:%M'}"
UpdateManager.relay self, :archived, message
UpdateManager.relay self, :single_message_labeled, message
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment