From 9adcf939e9afd00ad544de58c028dfd07f6c9a4c Mon Sep 17 00:00:00 2001 From: moculus Date: Thu, 26 Mar 2009 01:21:13 +0000 Subject: [PATCH] close last buffer bug --HG-- branch : pmacs2 --- method/buffers.py | 7 +++++-- mode/__init__.py | 3 +-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/method/buffers.py b/method/buffers.py index 335c2f5..b99e1cf 100644 --- a/method/buffers.py +++ b/method/buffers.py @@ -57,8 +57,11 @@ class KillBuffer(Method): dv=default.current_buffer, h="name of the buffer to kill")] def _execute(self, w, **vargs): name = vargs['buffername'] - a = w.application - assert name in a.bufferlist.buffer_names, "Buffer %r does not exist" % name + a = w.application + if name not in a.bufferlist.buffer_names: + raise Exception("Buffer %r does not exist" % name) + elif len(a.bufferlist.buffers) == 1: + raise Exception("Can't close only open buffer") self._to_kill = a.bufferlist.buffer_names[name] self._old_window = w if self.force or not self._to_kill.changed(): diff --git a/mode/__init__.py b/mode/__init__.py index 0ab1551..c54726e 100644 --- a/mode/__init__.py +++ b/mode/__init__.py @@ -461,8 +461,7 @@ class Fundamental(Handler): if DEBUG: raise else: - err = "%s in mode '%s'" % (e, self.name) - self.window.set_error(err) + self.window.set_error(str(e)) def region_added(self, p, newlines): mname = self.name