Archive of RubyForge sup-talk mailing list
 help / color / mirror / Atom feed
* [sup-talk] [PATCH] Allow user to show all matching threads
@ 2008-01-19 19:17 Marcus Williams
  2008-01-25  5:35 ` William Morgan
  0 siblings, 1 reply; 2+ messages in thread
From: Marcus Williams @ 2008-01-19 19:17 UTC (permalink / raw)


This adds a double keypress action "!!" to load all threads in the
current search/view. Obviously this can return a lot of threads, but
coupled with the cancel search option it is now easy to stop.
---
 lib/sup/modes/thread-index-mode.rb |   18 ++++++++++++++++--
 lib/sup/thread.rb                  |    2 +-
 2 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/lib/sup/modes/thread-index-mode.rb b/lib/sup/modes/thread-index-mode.rb
index 2b8cc20..1785a91 100644
--- a/lib/sup/modes/thread-index-mode.rb
+++ b/lib/sup/modes/thread-index-mode.rb
@@ -16,6 +16,9 @@ EOS
 
   register_keymap do |k|
     k.add :load_threads, "Load #{LOAD_MORE_THREAD_NUM} more threads", 'M'
+    k.add_multi "Load all threads (! to confirm) :", '!' do |kk|
+      kk.add :load_all_threads, "Load all threads (may list a _lot_ of threads)", '!'
+    end
     k.add :cancel_search, "Cancel current search", :ctrl_g
     k.add :reload, "Refresh view", '@'
     k.add :toggle_archived, "Toggle archived status", 'a'
@@ -462,9 +465,12 @@ EOS
     @interrupt_search = false
     @mbid = BufferManager.say "Searching for threads..."
 
+    ts_to_load = n
+    ts_to_load = ts_to_load + @ts.size unless n == -1 # -1 means all threads
+
     orig_size = @ts.size
     last_update = Time.now
-    @ts.load_n_threads(@ts.size + n, opts) do |i|
+    @ts.load_n_threads(ts_to_load, opts) do |i|
       if (Time.now - last_update) >= 0.25
         BufferManager.say "Loaded #{i.pluralize 'thread'} (use ^G to cancel)...", @mbid
         update
@@ -495,8 +501,16 @@ EOS
     @interrupt_search = true
   end
 
+  def load_all_threads
+    load_threads :num => -1
+  end
+
   def load_threads opts={}
-    n = opts[:num] || ThreadIndexMode::LOAD_MORE_THREAD_NUM
+    if opts[:num].nil?
+      n = ThreadIndexMode::LOAD_MORE_THREAD_NUM
+    else
+      n = opts[:num]
+    end
 
     myopts = @load_thread_opts.merge({ :when_done => (lambda do |num|
       opts[:when_done].call(num) if opts[:when_done]
diff --git a/lib/sup/thread.rb b/lib/sup/thread.rb
index 32002c4..09fbfbb 100644
--- a/lib/sup/thread.rb
+++ b/lib/sup/thread.rb
@@ -324,7 +324,7 @@ class ThreadSet
   ## load in (at most) num number of threads from the index
   def load_n_threads num, opts={}
     @index.each_id_by_date opts do |mid, builder|
-      break if size >= num
+      break if size >= num unless num == -1
       next if contains_id? mid
 
       m = builder.call
-- 
1.5.3.7



^ permalink raw reply	[flat|nested] 2+ messages in thread

* [sup-talk] [PATCH] Allow user to show all matching threads
  2008-01-19 19:17 [sup-talk] [PATCH] Allow user to show all matching threads Marcus Williams
@ 2008-01-25  5:35 ` William Morgan
  0 siblings, 0 replies; 2+ messages in thread
From: William Morgan @ 2008-01-25  5:35 UTC (permalink / raw)


Reformatted excerpts from Marcus Williams's message of 2008-01-19:
> This adds a double keypress action "!!" to load all threads in the
> current search/view. Obviously this can return a lot of threads, but
> coupled with the cancel search option it is now easy to stop.

Merged into next!

-- 
William <wmorgan-sup at masanjin.net>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-01-25  5:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-01-19 19:17 [sup-talk] [PATCH] Allow user to show all matching threads Marcus Williams
2008-01-25  5:35 ` William Morgan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox