From mboxrd@z Thu Jan 1 00:00:00 1970 Received: by 10.213.7.146 with SMTP id d18cs28413ebd; Tue, 12 Jan 2010 06:56:29 -0800 (PST) Received: by 10.224.86.153 with SMTP id s25mr10642354qal.91.1263308188360; Tue, 12 Jan 2010 06:56:28 -0800 (PST) Return-Path: Received: from rubyforge.org (rubyforge.org [205.234.109.19]) by mx.google.com with ESMTP id 7si1444767qwb.32.2010.01.12.06.56.27; Tue, 12 Jan 2010 06:56:28 -0800 (PST) Received-SPF: pass (google.com: domain of sup-devel-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-devel-bounces@rubyforge.org designates 205.234.109.19 as permitted sender) smtp.mail=sup-devel-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 9D61D19782D4; Tue, 12 Jan 2010 09:56:27 -0500 (EST) Received: from qw-out-2122.google.com (qw-out-2122.google.com [74.125.92.26]) by rubyforge.org (Postfix) with ESMTP id 5C74818582CB for ; Tue, 12 Jan 2010 09:56:24 -0500 (EST) Received: by qw-out-2122.google.com with SMTP id 5so1234716qwd.29 for ; Tue, 12 Jan 2010 06:56:24 -0800 (PST) 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 :in-reply-to:references:date:message-id:user-agent :content-transfer-encoding; bh=cxd1vtbypd6IoJ49B2WnW3XMPR3ovUUFF6OJdWZLfm8=; b=lQQgsOUBn/FLXQyO3V09aol6F8WV2kZ93gNshTRqmAjuQQukvQ9JgOapiS7RUHC5Nr /CeqxAHKcqD+rSzpiiuoYJg2v3Xh/1zrqXtP1iZJAt7gkQbh5jyvCMkFda63FYmXhj7u pqpUPFTB1ZklvGGsi6aco4XhYtjeRSJY5KBxc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=content-type:subject:from:to:in-reply-to:references:date:message-id :user-agent:content-transfer-encoding; b=rzWX3qdhIVVSJaTio2k3gH1uvJdgUDgk/gLkE01QH8fk7MYbUgzAQEWwgllDaIu2NG r5TWVWh8PJUw0rVMphsnNIyD7xnJ/aflBLjjvRx0yzeApOtyOz+0zNjRDcm8Epz/0zN7 LBp5d9u/r776Z3lbmvE3W4zSC5JVpZntHoGtw= Received: by 10.224.109.77 with SMTP id i13mr388295qap.258.1263308183987; Tue, 12 Jan 2010 06:56:23 -0800 (PST) Received: from localhost (c-76-98-110-216.hsd1.nj.comcast.net [76.98.110.216]) by mx.google.com with ESMTPS id 20sm5469111qyk.9.2010.01.12.06.56.22 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 12 Jan 2010 06:56:23 -0800 (PST) From: Eric Sherman To: sup-devel In-reply-to: <1263307713-sup-7005@changeling.local> References: <1262607214-sup-4535@changeling.local> <1263307713-sup-7005@changeling.local> Date: Tue, 12 Jan 2010 09:56:21 -0500 Message-Id: <1263308149-sup-5426@changeling.local> User-Agent: Sup/git Subject: [sup-devel] [PATCHv3] [issue14] poll updates accumulate while idle X-BeenThere: sup-devel@rubyforge.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: Sup developer discussion List-Id: Sup developer discussion 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-devel-bounces@rubyforge.org Errors-To: sup-devel-bounces@rubyforge.org If you were to leave sup running for a long time, this patch would enable you to get a glance summary of new mail activity since sup was last touched, by letting the poll update message accumulate its totals while idle. On keystrokes, BufferManager sends an :unidle update if the last keystroke occurred more than :idle_threshold seconds ago. PollManager listens for :unidle updates to clear @running_totals, which is also cleared on each poll unless idle. * :idle_threshold defaults to 60 seconds if not defined in config.yaml * presently no :idle update is sent when becoming idle * but we can check for idleness with BufferManager.idle? * after-poll behavior is unaffected --- lib/sup.rb | 3 ++- lib/sup/buffer.rb | 5 +++++ lib/sup/poll.rb | 13 +++++++++++-- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/lib/sup.rb b/lib/sup.rb index b83bbe7..e228772 100644 --- a/lib/sup.rb +++ b/lib/sup.rb @@ -230,7 +230,8 @@ else :discard_snippets_from_encrypted_messages => false, :default_attachment_save_dir => "", :sent_source => "sup://sent", - :poll_interval => 300 + :poll_interval => 300, + :idle_threshold => 60 } begin FileUtils.mkdir_p Redwood::BASE_DIR diff --git a/lib/sup/buffer.rb b/lib/sup/buffer.rb index c826ab9..2f5eaa8 100644 --- a/lib/sup/buffer.rb +++ b/lib/sup/buffer.rb @@ -212,6 +212,7 @@ EOS @in_x = ENV["TERM"] =~ /(xterm|rxvt|screen)/ @sigwinch_happened = false @sigwinch_mutex = Mutex.new + @no_keystrokes_since = Time.now end def sigwinch_happened!; @sigwinch_mutex.synchronize { @sigwinch_happened = true } end @@ -269,6 +270,8 @@ EOS @focus_buf.mode.cancel_search! @focus_buf.mark_dirty end + UpdateManager.relay self, :unidle, Time.at(@no_keystrokes_since) if idle? + @no_keystrokes_since = Time.now @focus_buf.mode.handle_input c end end @@ -761,6 +764,8 @@ EOS @shelled = false end + def idle?; Time.now.to_i - @no_keystrokes_since.to_i >= ($config[:idle_threshold] || 60); end + private def default_status_bar buf diff --git a/lib/sup/poll.rb b/lib/sup/poll.rb index f3e1224..ad51647 100644 --- a/lib/sup/poll.rb +++ b/lib/sup/poll.rb @@ -37,6 +37,8 @@ EOS @polling = false @poll_sources = nil @mode = nil + clear_running_totals + UpdateManager.register self end def poll_with_sources @@ -45,8 +47,12 @@ EOS BufferManager.flash "Polling for new messages..." num, numi, from_and_subj, from_and_subj_inbox, loaded_labels = @mode.poll - if num > 0 - BufferManager.flash "Loaded #{num.pluralize 'new message'}, #{numi} to inbox. Labels: #{loaded_labels.map{|l| l.to_s}.join(', ')}" + clear_running_totals unless BufferManager.idle? + @running_totals[:num] += num + @running_totals[:numi] += numi + @running_totals[:loaded_labels] += loaded_labels || [] + if @running_totals[:num] > 0 + BufferManager.flash "Loaded #{@running_totals[:num].pluralize 'new message'}, #{@running_totals[:numi]} to inbox. Labels: #{@running_totals[:loaded_labels].map{|l| l.to_s}.join(', ')}" else BufferManager.flash "No new messages." end @@ -183,6 +189,9 @@ EOS Index.add_message m UpdateManager.relay self, :added, m end + + def handle_unidle_update sender, idle_since; clear_running_totals; end + def clear_running_totals; @running_totals = {:num => 0, :numi => 0, :loaded_labels => Set.new}; end end end -- 1.6.6 _______________________________________________ Sup-devel mailing list Sup-devel@rubyforge.org http://rubyforge.org/mailman/listinfo/sup-devel