From mboxrd@z Thu Jan 1 00:00:00 1970 From: its.jeff.balogh@gmail.com (Jeff Balogh) Date: Wed, 30 Jan 2008 18:05:40 -0500 Subject: [sup-talk] [PATCH] don't try to open the next thread if there isn't one available In-Reply-To: <1201681010-sup-3463@archie> References: <1201681010-sup-3463@archie> Message-ID: <1201732604-sup-4815@archie> Jeff Balogh wrote: > When you're on the last thread of a ThreadSet and press ',', > nothing happens, but you can't '.' 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.