From mboxrd@z Thu Jan 1 00:00:00 1970 Received: by 10.213.32.82 with SMTP id b18cs52782ebd; Sat, 10 Apr 2010 03:51:03 -0700 (PDT) Received: by 10.204.141.69 with SMTP id l5mr1480037bku.64.1270896663127; Sat, 10 Apr 2010 03:51:03 -0700 (PDT) Return-Path: Received: from rubyforge.org (rubyforge.org [205.234.109.19]) by mx.google.com with ESMTP id u10si4904443bkz.50.2010.04.10.03.51.02; Sat, 10 Apr 2010 03:51:03 -0700 (PDT) Received-SPF: pass (google.com: domain of sup-talk-bounces@rubyforge.org designates 205.234.109.19 as permitted sender) client-ip=205.234.109.19; Authentication-Results: mx.google.com; spf=pass (google.com: domain of sup-talk-bounces@rubyforge.org designates 205.234.109.19 as permitted sender) smtp.mail=sup-talk-bounces@rubyforge.org; dkim=neutral (body hash did not verify) header.i=@gmail.com Received: from rubyforge.org (rubyforge.org [127.0.0.1]) by rubyforge.org (Postfix) with ESMTP id 49AB01D78897; Sat, 10 Apr 2010 06:51:02 -0400 (EDT) Received: from mail-pw0-f50.google.com (mail-pw0-f50.google.com [209.85.160.50]) by rubyforge.org (Postfix) with ESMTP id 7EA141858307 for ; Sat, 10 Apr 2010 06:50:52 -0400 (EDT) Received: by pwj1 with SMTP id 1so3665890pwj.23 for ; Sat, 10 Apr 2010 03:50:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:content-type:subject:from:to :date:message-id:user-agent:content-transfer-encoding; bh=b4nu9ZYbf8Knr7hahwfskrcM6paNR4AtUJRhoQET1ns=; b=EhLoqYVRR2MpDvdZmPg+pAMmD4WJyVJMY+6u9nKAphrucA69MiqpkAbYO6K8PcGPmE yXLaQh+XAi0LJdSGOOI6XtRI4b4my4q/9jzcy11CsS+cg7r44E2Ayohdvl6T+xOo9mAV a4LSvnoAwf3wm5R2x8DXwB4JlzElu8NWq++sA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=content-type:subject:from:to:date:message-id:user-agent :content-transfer-encoding; b=IvQZ3mAsmD9BPuIFQ09rouBbm0N2hsIwnuFlV3M8VI8QcKBXrBfVdLjG3pq4hgmlBd Q4UqqawIIsd2onS07fXlk2N5iNDadQkf5ol7Ao3ejOt9A8cO8Y8iyUw2R09lM7eiwrKH YVPDcRjH6BErGKH1EaQF8FkW+TWejlNDk0JGM= Received: by 10.141.89.12 with SMTP id r12mr1537284rvl.185.1270896174713; Sat, 10 Apr 2010 03:42:54 -0700 (PDT) Received: from localhost ([203.110.240.41]) by mx.google.com with ESMTPS id 20sm1837451pzk.7.2010.04.10.03.42.52 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sat, 10 Apr 2010 03:42:54 -0700 (PDT) From: Ramkumar Ramachandra To: sup-talk Date: Sat, 10 Apr 2010 16:10:34 +0530 Message-Id: <1270896024-sup-8760@kytes> User-Agent: Sup/git Subject: [sup-talk] [PATCH 4/4] Appropriate call to shell_out_async X-BeenThere: sup-talk@rubyforge.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: User & developer discussion of Sup List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: sup-talk-bounces@rubyforge.org Errors-To: sup-talk-bounces@rubyforge.org 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 --- 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