parent
317955c5d8
commit
35e4611dd0
|
@ -442,7 +442,7 @@ class Application(object):
|
|||
# buffer handling
|
||||
def new_file_buffer(self, path, data, switch_to=True):
|
||||
assert not self.has_buffer_name(path), '%r is already open' % path
|
||||
assert not os.path.exists(path), '%r already exists' % path
|
||||
#assert not os.path.exists(path), '%r already exists' % path
|
||||
# touch the file
|
||||
f = open(path, 'w')
|
||||
f.write(data)
|
||||
|
|
|
@ -115,6 +115,7 @@ class SaveBufferAs(Method):
|
|||
class SaveBuffer(Method):
|
||||
'''Save the contents of a buffer'''
|
||||
def _execute(self, w, **vargs):
|
||||
a = w.application
|
||||
if not w.buffer.changed():
|
||||
w.set_error("(No changes need to be saved)")
|
||||
return
|
||||
|
@ -125,7 +126,18 @@ class SaveBuffer(Method):
|
|||
w.buffer.save(force=True)
|
||||
w.set_error("File had disappeared! Wrote %s" % (w.buffer.path))
|
||||
except buffer.FileChangedError, e:
|
||||
pass
|
||||
path1 = w.buffer.path
|
||||
tf = tempfile.NamedTemporaryFile(delete=False)
|
||||
tf.write(w.buffer.make_string())
|
||||
tf.close()
|
||||
path2 = tf.name
|
||||
a.methods['diff'].execute(w, path1=path1, path2=path2)
|
||||
w.set_error("File changed on disk; showing differences")
|
||||
class ReloadBuffer(Method):
|
||||
'''Reload the contents of a buffer from the filesystem'''
|
||||
def _execute(self, w, **vargs):
|
||||
w.buffer.reload()
|
||||
w.set_error("Buffer contents reloaded from %r" % w.buffer.path)
|
||||
|
||||
class ToggleTabs(Method):
|
||||
'''Toggle whether to write tabs out or not (defaults to false)'''
|
||||
|
|
Loading…
Reference in New Issue