Archive of RubyForge sup-talk mailing list
 help / color / mirror / Atom feed
From: Ramkumar Ramachandra <artagnon@gmail.com>
To: sup-talk <sup-talk@rubyforge.org>
Subject: [sup-talk] [PATCH 4/4] Appropriate call to shell_out_async
Date: Sat, 10 Apr 2010 16:10:34 +0530	[thread overview]
Message-ID: <1270896024-sup-8760@kytes> (raw)

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


                 reply	other threads:[~2010-04-10 10:51 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1270896024-sup-8760@kytes \
    --to=artagnon@gmail.com \
    --cc=sup-talk@rubyforge.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox