47 lines
1.1 KiB
Python
47 lines
1.1 KiB
Python
import os
|
|
import util
|
|
|
|
# default callbacks
|
|
def none(window):
|
|
return None
|
|
|
|
def last_buffer(window):
|
|
bl = window.application.bufferlist
|
|
if bl.hidden_buffers:
|
|
return bl.hidden_buffers[0].name()
|
|
else:
|
|
return ''
|
|
|
|
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):
|
|
return util.normal_path(os.getcwd())
|
|
|
|
def path_dirname(window):
|
|
if hasattr(window.buffer, 'path'):
|
|
return util.normal_path(window.buffer.path) + '/'
|
|
else:
|
|
return current_working_dir(window)
|
|
|
|
# default callback builders
|
|
def build_constant(c):
|
|
return lambda w: c
|
|
|
|
def build_mode_var(name):
|
|
return lambda w: hasattr(w.mode, name) and getattr(w.mode, name) or ''
|