2007-03-06 10:05:38 -05:00
|
|
|
import os
|
|
|
|
|
|
|
|
# default callbacks
|
|
|
|
def none(window):
|
|
|
|
return None
|
|
|
|
|
|
|
|
def last_buffer(window):
|
|
|
|
bl = window.application.bufferlist
|
|
|
|
return bl.hidden_buffers[0].name()
|
|
|
|
|
|
|
|
def current_buffer(window):
|
|
|
|
return window.buffer.name()
|
|
|
|
|
|
|
|
def last_replace_before(window):
|
|
|
|
return None #XYZ
|
|
|
|
if window.application.last_replace_before:
|
|
|
|
return window.application.last_replace_before
|
|
|
|
else:
|
|
|
|
return None
|
|
|
|
|
|
|
|
def last_replace_after(window):
|
|
|
|
return None #XYZ
|
|
|
|
if window.application.last_replace_after:
|
|
|
|
return window.application.last_replace_after
|
|
|
|
else:
|
|
|
|
return None
|
|
|
|
|
|
|
|
def current_working_dir(window):
|
|
|
|
home = os.getenv('HOME')
|
|
|
|
cwd = os.getcwd()
|
|
|
|
if cwd.startswith(home):
|
|
|
|
cwd = cwd.replace(home, '~', 1)
|
|
|
|
if not cwd.endswith('/'):
|
|
|
|
cwd += '/'
|
|
|
|
return cwd
|
|
|
|
|
2008-03-16 17:36:34 -04:00
|
|
|
def path_dirname(window):
|
|
|
|
if hasattr(window.buffer, 'path'):
|
|
|
|
return os.path.dirname(window.buffer.path) + '/'
|
|
|
|
|
2007-03-06 10:05:38 -05:00
|
|
|
# default callback builders
|
|
|
|
def build_constant(c):
|
|
|
|
return lambda w: c
|