pmacs3/default.py

56 lines
1.2 KiB
Python
Raw Normal View History

2007-03-06 10:05:38 -05:00
import os
import util
2007-03-06 10:05:38 -05:00
# default callbacks
def none(w):
2007-03-06 10:05:38 -05:00
return None
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
def current_buffer(w):
return w.buffer.name()
2007-03-06 10:05:38 -05:00
def current_word(w):
return w.get_word() or ''
def current_token(w):
if w.mode.name not in w.buffer.highlights:
return ''
token = w.get_token()
if token:
return token.string
else:
return ''
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
def current_working_dir(w):
return util.normal_path(os.getcwd())
2007-03-06 10:05:38 -05:00
def path_dirname(w):
if hasattr(w.buffer, 'path'):
return util.normal_path(os.path.dirname(w.buffer.path))
else:
return current_working_dir(w)
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 ''