From 81de411291b4aaf4770adc8595f93706e1b48277 Mon Sep 17 00:00:00 2001 From: moculus Date: Mon, 6 Apr 2009 06:23:41 +0000 Subject: [PATCH] better Interact --HG-- branch : pmacs2 --- method/shell.py | 5 +++++ mode/lua.py | 17 +++++------------ 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/method/shell.py b/method/shell.py index 0c20494..0d7c999 100644 --- a/method/shell.py +++ b/method/shell.py @@ -140,10 +140,15 @@ class Interact(Method): args = [arg('bname', dt="str", p="Buffer Name: ", dv=lambda w: '*Interact*'), arg('cmd', dt="shell", p="Command: ", dv=lambda w: 'bash')] modename = None + reuse = False def _execute(self, w, **vargs): bname = vargs['bname'] cmd = vargs['cmd'] a = w.application + if self.reuse and a.has_buffer_name(bname): + a.switch_buffer(a.get_buffer_by_name(bname)) + return + a.close_buffer_by_name(bname) b = XTermBuffer(a, 'bash', ['-c', cmd], name=bname, modename=self.modename) diff --git a/mode/lua.py b/mode/lua.py index 931ce98..8972451 100644 --- a/mode/lua.py +++ b/mode/lua.py @@ -50,23 +50,16 @@ class LuaCheckSyntax(Method): class LuaStart(Interact): args = [] modename = 'luapipe' + reuse = True def _execute(self, w, **vargs): - a = w.application - if a.has_buffer_name('*Lua*'): - a.switch_buffer(a.get_buffer_by_name('*Lua*')) - else: - Interact._execute(self, w, bname='*Lua*', cmd='lua') + Interact._execute(self, w, bname='*Lua*', cmd='lua') class LuaLoadFile(Interact): args = [] modename = 'luapipe' + reuse = True def _execute(self, w, **vargs): - a = w.application - if a.has_buffer_name('*Lua*'): - b = a.get_buffer_by_name('*Lua*') - a.switch_buffer(b) - else: - Interact._execute(self, w, bname='*Lua*', cmd='lua') - b = a.get_buffer_by_name('*Lua*') + Interact._execute(self, w, bname='*Lua*', cmd='lua') + b = w.application.get_buffer_by_name('*Lua*') path = w.buffer.path b.pipe_write('dofile("' + path + '");\n')