def _do_update(self): path = vim.eval('expand("%")') if path is None: path = "" fn = os.path.basename(path) ct = self.current_text self._snip._reset(ct) local_d = self._locals local_d.update({ 't': _Tabs(self), 'fn': fn, 'path': path, 'cur': ct, 'res': ct, 'snip' : self._snip, }) self._code = self._code.replace("\r\n", "\n") compatible_exec(self._code, self._globals, local_d) if self._snip._rv_changed: self.current_text = self._snip.rv else: self.current_text = str(local_d["res"])
def _do_update(self): path = vim.eval('expand("%")') if path is None: path = "" fn = os.path.basename(path) ct = self.current_text self._snip._reset(ct) local_d = self._locals local_d.update({ 't': _Tabs(self), 'fn': fn, 'path': path, 'cur': ct, 'res': ct, 'snip': self._snip, }) self._code = self._code.replace("\r\n", "\n") compatible_exec(self._code, self._globals, local_d) if self._snip._rv_changed: self.current_text = self._snip.rv else: self.current_text = str(local_d["res"])
def __init__(self, parent, token): code = token.code.replace("\\`", "`") # Find our containing snippet for snippet local data snippet = parent while snippet and not isinstance(snippet, SnippetInstance): try: snippet = snippet._parent except AttributeError: snippet = None self._snip = SnippetUtil(token.indent) self._locals = snippet.locals self._globals = {} globals = snippet.globals.get("!p", []) compatible_exec("\n".join(globals).replace("\r\n", "\n"), self._globals) # Add Some convenience to the code self._code = "import re, os, vim, string, random\n" + code TextObject.__init__(self, parent, token)