Added in remove file function. (#272)
* Added in remove file function. * Changed namespace of rename and remove (now delete).
This commit is contained in:
parent
1ad4289e76
commit
bdc37f1f6c
|
@ -297,7 +297,7 @@ local commands = {
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
["doc:rename"] = function()
|
["file:rename"] = function()
|
||||||
local old_filename = doc().filename
|
local old_filename = doc().filename
|
||||||
if not old_filename then
|
if not old_filename then
|
||||||
core.error("Cannot rename unsaved doc")
|
core.error("Cannot rename unsaved doc")
|
||||||
|
@ -312,6 +312,21 @@ local commands = {
|
||||||
end
|
end
|
||||||
end, common.path_suggest)
|
end, common.path_suggest)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
|
||||||
|
["file:delete"] = function()
|
||||||
|
local filename = doc().abs_filename
|
||||||
|
if not filename then
|
||||||
|
core.error("Cannot remove unsaved doc")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
for i,docview in ipairs(core.get_views_referencing_doc(doc())) do
|
||||||
|
local node = core.root_view.root_node:get_node_for_view(docview)
|
||||||
|
node:close_view(core.root_view, docview)
|
||||||
|
end
|
||||||
|
os.remove(filename)
|
||||||
|
core.log("Removed \"%s\"", filename)
|
||||||
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue