[Geany-Users] script to delete currently viewed document

pauriem at gmail.com pauriem at xxxxx
Tue Apr 30 22:04:34 UTC 2013


-- in case anyone finds it helpful, here is a script to delete from
disk-- the document currently being viewed, which is something that
some of-- the other text editors out there have a button or menu
command forlocal keys_to_read, path, code, alerts, gloss, i,
jgeany.banner = "Lua Script: Close and unlink"i = 60if (geany.count ()
> 0) then path = geany.filename () keys_to_read = geany.fileinfo
()else path = nil keys_to_read = nilendif ((path == nil) or
(keys_to_read == nil) or (keys_to_read["changed"])) then alerts = "No
saved document to unlink"elseif (keys_to_read["readonly"]) then alerts
= "Read-only document cannot be unlinked"else gloss = ("Unlink \"" ..
path) .. "\"?" j = string.len (gloss) if (j < i) then j = i end alerts
= gloss .. ("\n" .. string.rep ("_", j)) if (geany.confirm (" ",
alerts, false)) then   geany.close ()   code, alerts = os.remove
(path)   if (code) then     alerts = ("Unlinked \"" .. path) .."\""
else     if (alerts == nil) then gloss ="unknown OS error" else gloss
= alerts end     alerts = ("Unable to unlink \"" .. path) .. (("\" ("
.. gloss) .. ")")   end else   alerts = "" endendj = string.len
(alerts)if j > 0 then if (j < i) then j = i end geany.message (alerts
.. ("\n" .. string.rep ("_", j)))end


More information about the Users mailing list