Subject: [sup-talk] [PATCH 3/4] Callback to compose

From: Ramkumar Ramachandra <[email-masked]>
Date: Sat, 10 Apr 2010 16:09:43 +0530

Write a callback to parse the file and fill in the parsed contents
into a newly spawned buffer.

Signed-off-by: Ramkumar Ramachandra <[email-masked]>
---
 lib/sup/modes/compose-mode.rb |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/lib/sup/modes/compose-mode.rb b/lib/sup/modes/compose-mode.rb
index f0d1e23..a19c294 100644
--- a/lib/sup/modes/compose-mode.rb
+++ b/lib/sup/modes/compose-mode.rb
@@ -20,6 +20,23 @@ class ComposeMode < EditMessageMode
     edited
   end
 
+  def parse_file fn
+    super fn
+  end
+
+  def self.edit_message_callback file, mtime
+    edited = File.mtime(file.path) > mtime ? true : false
+
+    return edited unless edited
+
+    mode = ComposeMode.new
+    header, body = mode.parse_file file.path
+    header -= NON_EDITABLE_HEADERS
+    mode.header, mode.body = header, body
+    BufferManager.spawn "New Message", mode
+    mode.update
+  end
+
   def self.spawn_nicely opts={}
     to = opts[:to] || (BufferManager.ask_for_contacts(:people, "To: ", [opts[:to_default]]) or return if ($config[:ask_for_to] != false))
     cc = opts[:cc] || (BufferManager.ask_for_contacts(:people, "Cc: ") or return if $config[:ask_for_cc])
-- 
1.7.0.4
_______________________________________________
sup-talk mailing list
[email-masked]
http://rubyforge.org/mailman/listinfo/sup-talk