From: gigabo@gmail.com (Bo Borgerson)
Subject: [sup-talk] [PATCH] Add command for polling unusual sources
Date: Sun, 13 Sep 2009 10:38:35 -0400 [thread overview]
Message-ID: <1252852715-9601-1-git-send-email-gigabo@gmail.com> (raw)
bin/sup: Add new global key binding, '{', to poll unusual sources
(requires confirmation). This allows update of unusual sources
without having to leave sup to run a sync.
lib/sup/poll.rb: Add new method, poll_unusual. Both the pre-existing
poll method and the new poll_unusual method are now wrappers around
new poll_with_sources method that contains the bulk of functionality
previously in poll.
lib/sup/source.rb: Add new accessor for unusual_sources
---
bin/sup | 5 +++++
lib/sup/poll.rb | 23 +++++++++++++++++++----
lib/sup/source.rb | 1 +
3 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/bin/sup b/bin/sup
index 76a0438..996c99e 100755
--- a/bin/sup
+++ b/bin/sup
@@ -75,6 +75,7 @@ global_keymap = Keymap.new do |k|
k.add :search_unread, "Show all unread messages", 'U'
k.add :list_labels, "List labels", 'L'
k.add :poll, "Poll for new messages", 'P'
+ k.add :poll_unusual, "Poll for new messages from unusual sources", '{'
k.add :compose, "Compose new message", 'm', 'c'
k.add :nothing, "Do nothing", :ctrl_g
k.add :recall_draft, "Edit most recent draft message", 'R'
@@ -282,6 +283,10 @@ begin
ComposeMode.spawn_nicely
when :poll
reporting_thread("user-invoked poll") { PollManager.poll }
+ when :poll_unusual
+ if BufferManager.ask_yes_or_no "Really poll unusual sources?"
+ reporting_thread("user-invoked unusual poll") { PollManager.poll_unusual }
+ end
when :recall_draft
case Index.num_results_for :label => :draft
when 0
diff --git a/lib/sup/poll.rb b/lib/sup/poll.rb
index b59237f..ec51dec 100644
--- a/lib/sup/poll.rb
+++ b/lib/sup/poll.rb
@@ -35,12 +35,11 @@ EOS
@thread = nil
@last_poll = nil
@polling = false
+ @poll_sources = nil
@mode = nil
end
- def poll
- return if @polling
- @polling = true
+ def poll_with_sources
@mode ||= PollMode.new
HookManager.run "before-poll"
@@ -54,6 +53,22 @@ EOS
HookManager.run "after-poll", :num => num, :num_inbox => numi, :from_and_subj => from_and_subj, :from_and_subj_inbox => from_and_subj_inbox, :num_inbox_total_unread => lambda { Index.num_results_for :labels => [:inbox, :unread] }
+ end
+
+ def poll
+ return if @polling
+ @polling = true
+ @poll_sources = SourceManager.usual_sources
+ num, numi = poll_with_sources
+ @polling = false
+ [num, numi]
+ end
+
+ def poll_unusual
+ return if @polling
+ @polling = true
+ @poll_sources = SourceManager.unusual_sources
+ num, numi = poll_with_sources
@polling = false
[num, numi]
end
@@ -78,7 +93,7 @@ EOS
from_and_subj_inbox = []
@mutex.synchronize do
- SourceManager.usual_sources.each do |source|
+ @poll_sources.each do |source|
# yield "source #{source} is done? #{source.done?} (cur_offset #{source.cur_offset} >= #{source.end_offset})"
begin
yield "Loading from #{source}... " unless source.done? || (source.respond_to?(:has_errors?) && source.has_errors?)
diff --git a/lib/sup/source.rb b/lib/sup/source.rb
index 78386ff..6fe7bfb 100644
--- a/lib/sup/source.rb
+++ b/lib/sup/source.rb
@@ -207,6 +207,7 @@ class SourceManager
def source_for uri; sources.find { |s| s.is_source_for? uri }; end
def usual_sources; sources.find_all { |s| s.usual? }; end
+ def unusual_sources; sources.find_all { |s| !s.usual? }; end
def load_sources fn=Redwood::SOURCE_FN
source_array = (Redwood::load_yaml_obj(fn) || []).map { |o| Recoverable.new o }
--
1.6.0.4
next reply other threads:[~2009-09-13 14:38 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-13 14:38 Bo Borgerson [this message]
2009-10-01 16:54 ` William Morgan
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=1252852715-9601-1-git-send-email-gigabo@gmail.com \
--to=gigabo@gmail.com \
/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