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 def path_dirname(window): if hasattr(window.buffer, 'path'): return os.path.dirname(window.buffer.path) + '/' # default callback builders def build_constant(c): return lambda w: c