Created
August 16, 2012 13:11
-
-
Save cra/3370011 to your computer and use it in GitHub Desktop.
Notion kpress_count test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
COUNTER_FILE = "/tmp/notion_counter" | |
function kpress_count(binding, fn, args) | |
local counter = {} | |
local inp = io.open(COUNTER_FILE) | |
if inp then | |
-- read | |
for line in inp:lines() do | |
local k, v = line:match '(%S+)%s+(%S+)%s' | |
counter.k = v | |
end | |
file:close() | |
end | |
-- update | |
if counter.binding then | |
counter.binding = counter.binding + 1 | |
else | |
counter.binding = 1 | |
end | |
-- dump | |
local outp = io.open(COUNTER_FILE, "w") | |
for k, v in pairs(counter) do | |
outp:write(k .. " " .. v) | |
end | |
outp:close() | |
return kpress(binding, string.format("%s(%s)", fn, args)) | |
end | |
defbindings("WScreen", { | |
bdoc("Toggle scratchpad."), | |
--kpress(ALTMETA.."Shift+C", "named_scratchpad(_, 'ims')"), | |
kpress_count(ALTMETA.."Shift+C", "named_scratchpad", "_, 'ims'"), | |
}) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment