# HG changeset patch # User Steve Losh # Date 1309474410 14400 # Node ID 61c6ca7b2d8a92a32f0b891f7b491d7b37635c18 # Parent 8cfa904908841dd19ffc0e1861dca522303e54b1 Fix the binding of \u in grid/other modes. diff -r 8cfa90490884 -r 61c6ca7b2d8a autoload/threesomelib/modes.py --- a/autoload/threesomelib/modes.py Thu Jun 30 18:36:50 2011 -0400 +++ b/autoload/threesomelib/modes.py Thu Jun 30 18:53:30 2011 -0400 @@ -387,6 +387,7 @@ def activate(self): + keys.unbind('u') keys.bind('u1', ':ThreesomeUse1') keys.bind('u2', ':ThreesomeUse2') return super(GridMode, self).activate() @@ -394,6 +395,7 @@ def deactivate(self): keys.unbind('u1') keys.unbind('u2') + keys.bind('u', ':ThreesomeUse') return super(GridMode, self).deactivate() @@ -885,20 +887,24 @@ def key_grid(): global current_mode + current_mode.deactivate() current_mode = grid grid.activate() def key_loupe(): global current_mode + current_mode.deactivate() current_mode = loupe loupe.activate() def key_compare(): global current_mode + current_mode.deactivate() current_mode = compare compare.activate() def key_path(): global current_mode + current_mode.deactivate() current_mode = path path.activate() diff -r 8cfa90490884 -r 61c6ca7b2d8a autoload/threesomelib/util/bufferlib.py --- a/autoload/threesomelib/util/bufferlib.py Thu Jun 30 18:36:50 2011 -0400 +++ b/autoload/threesomelib/util/bufferlib.py Thu Jun 30 18:53:30 2011 -0400 @@ -78,5 +78,14 @@ buffers.two.name: 'Two', buffers.result.name: 'Result' } + class remain: + def __enter__(self): + self.curbuf = vim.eval('bufnr(bufname("%"))') + self.pos = windows.pos() + + def __exit__(self, type, value, traceback): + vim.command('%dbuffer' % self.curbuf) + vim.current.window.cursor = self.pos + buffers = _BufferList() diff -r 8cfa90490884 -r 61c6ca7b2d8a autoload/threesomelib/util/keys.py --- a/autoload/threesomelib/util/keys.py Thu Jun 30 18:36:50 2011 -0400 +++ b/autoload/threesomelib/util/keys.py Thu Jun 30 18:53:30 2011 -0400 @@ -1,4 +1,5 @@ import vim +from bufferlib import buffers def bind(key, to, options='', mode=None, leader=''): @@ -7,3 +8,14 @@ def unbind(key, options='', leader=''): vim.command('unmap %s %s%s' % (options, leader, key)) +def bind_for_all(key, to, options='', mode=None, leader=''): + with buffers.remain(): + for b in buffers.all: + b.open() + bind(key, to, options, mode, leader) + +def unbind_for_all(key, options='', leader=''): + with buffers.remain(): + for b in buffers.all: + b.open() + unbind(key, options, leader)