Jeff Balogh wrote:
> When you're on the last thread of a ThreadSet and press ',<key>',
> nothing happens, but you can't '.<key>' since @dying == true.  This
> patch changes :next to :kill if there is no next thread.
> ---
> I usually traverse my inbox with ',a', so it annoys me when sup gets stuck on
> the last thread.  This patch implements what I expect to happen: the thread is
> killed and the previous buffer pops up.

Ok, this patch causes a no block given exception with ',n' on the last thread.
As you might expect, no block is given with the do nothing command.

Here's where it's happening:
  def dispatch op
    return if @dying
    @dying = true

    op = :kill unless @index_mode.has_thread_after(@thread)

    case op
    when :next
      @index_mode.launch_next_thread_after(@thread) do
        @thread.save Index if block_given? && yield
        BufferManager.kill_buffer_safely buffer
      end
    when :kill
      @thread.save Index if yield
      BufferManager.kill_buffer_safely buffer
    else
      raise ArgumentError, "unknown thread dispatch operation #{op.inspect}"
    end
  end

The :next case guards against this exception with 'if block_given? && yield'.  
If
I put that in the :kill case, those two lines will be exact duplicates of the
lines above.

Is there a clean way to handle this?  I'm learning Ruby as I go along, so please
forgive me if the answer is obvious.
_______________________________________________
sup-talk mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/sup-talk

Reply via email to