[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[sup-talk] [PATCH 4/4] Appropriate call to shell_out_async
Call shell_out_async instead of shell_out when the appropriate config
option is present. Move parse_file and update out from the protected
section.
Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
lib/sup/modes/edit-message-mode.rb | 58 +++++++++++++++++++----------------
1 files changed, 31 insertions(+), 27 deletions(-)
diff --git a/lib/sup/modes/edit-message-mode.rb b/lib/sup/modes/edit-message-mode.rb
index c1537ae..3dba941 100644
--- a/lib/sup/modes/edit-message-mode.rb
+++ b/lib/sup/modes/edit-message-mode.rb
@@ -158,19 +158,23 @@ EOS
@file.close
editor = $config[:editor] || ENV['EDITOR'] || "/usr/bin/vi"
+ editor_daemon = $config[:editor_daemon]
+ if editor_daemon
+ BufferManager.shell_out_async editor_daemon, @file
+ else
+ mtime = File.mtime @file.path
+ BufferManager.shell_out "#{editor} #{@file.path}"
+ @edited = true if File.mtime(@file.path) > mtime
- mtime = File.mtime @file.path
- BufferManager.shell_out "#{editor} #{@file.path}"
- @edited = true if File.mtime(@file.path) > mtime
-
- return @edited unless @edited
+ return @edited unless @edited
- header, @body = parse_file @file.path
- @header = header - NON_EDITABLE_HEADERS
- handle_new_text @header, @body
- update
+ header, @body = parse_file @file.path
+ @header = header - NON_EDITABLE_HEADERS
+ handle_new_text @header, @body
+ update
- @edited
+ @edited
+ end
end
def killable?
@@ -202,6 +206,23 @@ EOS
end
end
+ def parse_file fn
+ File.open(fn) do |f|
+ header = Source.parse_raw_email_header(f).inject({}) { |h, (k, v)| h[k.capitalize] = v; h } # lousy HACK
+ body = f.readlines.map { |l| l.chomp }
+
+ header.delete_if { |k, v| NON_EDITABLE_HEADERS.member? k }
+ header.each { |k, v| header[k] = parse_header k, v }
+
+ [header, body]
+ end
+ end
+
+ def update
+ regen_text
+ buffer.mark_dirty if buffer
+ end
+
protected
def mime_encode string
@@ -250,11 +271,6 @@ protected
@selector_label_width = [@selector_label_width, s.label.length].max
end
- def update
- regen_text
- buffer.mark_dirty if buffer
- end
-
def regen_text
header, @header_lines = format_headers(@header - NON_EDITABLE_HEADERS) + [""]
@text = header + [""] + @body
@@ -269,18 +285,6 @@ protected
end
end
- def parse_file fn
- File.open(fn) do |f|
- header = Source.parse_raw_email_header(f).inject({}) { |h, (k, v)| h[k.capitalize] = v; h } # lousy HACK
- body = f.readlines.map { |l| l.chomp }
-
- header.delete_if { |k, v| NON_EDITABLE_HEADERS.member? k }
- header.each { |k, v| header[k] = parse_header k, v }
-
- [header, body]
- end
- end
-
def parse_header k, v
if MULTI_HEADERS.include?(k)
v.split_on_commas.map do |name|
--
1.7.0.4
_______________________________________________
sup-talk mailing list
sup-talk@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-talk