Commits

Steve Losh committed 61c6ca7

Fix the binding of \u in grid/other modes.

  • Participants
  • Parent commits 8cfa904

Comments (0)

Files changed (3)

autoload/threesomelib/modes.py

 
 
     def activate(self):
+        keys.unbind('u')
         keys.bind('u1', ':ThreesomeUse1<cr>')
         keys.bind('u2', ':ThreesomeUse2<cr>')
         return super(GridMode, self).activate()
     def deactivate(self):
         keys.unbind('u1')
         keys.unbind('u2')
+        keys.bind('u', ':ThreesomeUse<cr>')
         return super(GridMode, self).deactivate()
 
 
 
 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()

autoload/threesomelib/util/bufferlib.py

                  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()
 

autoload/threesomelib/util/keys.py

 import vim
+from bufferlib import buffers
 
 
 def bind(key, to, options='', mode=None, leader='<localleader>'):
 def unbind(key, options='', leader='<localleader>'):
     vim.command('unmap %s %s%s' % (options, leader, key))
 
+def bind_for_all(key, to, options='', mode=None, leader='<localleader>'):
+    with buffers.remain():
+        for b in buffers.all:
+            b.open()
+            bind(key, to, options, mode, leader)
+
+def unbind_for_all(key, options='', leader='<localleader>'):
+    with buffers.remain():
+        for b in buffers.all:
+            b.open()
+            unbind(key, options, leader)