set_tab(2) function starts(String,Start) return string.sub(String,1,string.len(Start))==Start end meta_commands["blame"] = function() _, y = get_coords() handle = io.popen("git blame --porcelain -L"..tostring(math.floor(y)+1)..","..tostring(math.floor(y)+1).." "..get_filename()) lines = handle:read("*a") handle:close() author = string.match(lines, "author (%a+)") if author == nil then message("Not checked in!") else message(author) end end keys["%"] = function() s = get_text() count = 0 for word in s:gmatch("%w+") do count = count + 1 end message(count .. " words") end keys["!"] = function() command = prompt("shell command: %s") if command == nil then return end command = string.gsub(command, "%$", get_filename() or "") handle = io.popen(command) result = handle:read("*a") handle:close() result = string.gsub(result, "\n", " ") message(result) end meta_commands["carp"] = function() file = get_filename() if file == nil then message("File has no name!") return end handle = io.popen("carp --check "..file) result = handle:read("*a") handle:close() if result == "" then message("Checks passed!") return end if starts(result, "Invalid path") then message("File not yet saved to disk!") return end f, l, c, msg = string.match(result, "([^:]+):(%d+):(%d+) (.-)[\r\n].*") if string.match(f, file) then move(tonumber(l)-1, tonumber(c)) message(msg) end end function get_meta_commands() res = "" for k, _ in pairs(meta_commands) do res = res .. k .. ", " end return res end function get_keys() res = "" for k, _ in pairs(keys) do res = res .. k .. ", " end return res end