2007-03-06 10:05:38 -05:00
|
|
|
import os
|
2008-12-04 12:16:41 -05:00
|
|
|
import util
|
2007-03-06 10:05:38 -05:00
|
|
|
|
|
|
|
# default callbacks
|
2008-12-05 00:38:08 -05:00
|
|
|
def none(w):
|
2007-03-06 10:05:38 -05:00
|
|
|
return None
|
|
|
|
|
2008-12-05 00:38:08 -05:00
|
|
|
def last_buffer(w):
|
|
|
|
bl = w.application.bufferlist
|
2008-10-29 13:17:16 -04:00
|
|
|
if bl.hidden_buffers:
|
|
|
|
return bl.hidden_buffers[0].name()
|
|
|
|
else:
|
|
|
|
return ''
|
2007-03-06 10:05:38 -05:00
|
|
|
|
2008-12-05 00:38:08 -05:00
|
|
|
def current_buffer(w):
|
|
|
|
return w.buffer.name()
|
2007-03-06 10:05:38 -05:00
|
|
|
|
2008-12-05 00:38:08 -05:00
|
|
|
def last_replace_before(w):
|
|
|
|
a = w.application
|
|
|
|
if a.config.get('use_last_replace') and a.last_replace_before:
|
|
|
|
return a.last_replace_before
|
|
|
|
return None
|
|
|
|
def last_replace_after(w):
|
|
|
|
a = w.application
|
|
|
|
if a.config.get('use_last_replace') and a.last_replace_after:
|
|
|
|
return w.application.last_replace_after
|
|
|
|
return None
|
2007-03-06 10:05:38 -05:00
|
|
|
|
2008-12-05 00:38:08 -05:00
|
|
|
def current_working_dir(w):
|
2008-12-04 12:16:41 -05:00
|
|
|
return util.normal_path(os.getcwd())
|
2007-03-06 10:05:38 -05:00
|
|
|
|
2008-12-05 00:38:08 -05:00
|
|
|
def path_dirname(w):
|
|
|
|
if hasattr(w.buffer, 'path'):
|
2008-12-10 00:54:53 -05:00
|
|
|
return util.normal_path(os.path.dirname(w.buffer.path))
|
2008-12-04 12:16:41 -05:00
|
|
|
else:
|
2008-12-05 00:38:08 -05:00
|
|
|
return current_working_dir(w)
|
2008-03-16 17:36:34 -04:00
|
|
|
|
2007-03-06 10:05:38 -05:00
|
|
|
# default callback builders
|
|
|
|
def build_constant(c):
|
|
|
|
return lambda w: c
|
2008-05-18 22:05:29 -04:00
|
|
|
|
|
|
|
def build_mode_var(name):
|
|
|
|
return lambda w: hasattr(w.mode, name) and getattr(w.mode, name) or ''
|