@@ -24,7 +24,7 @@ every keybind bit by bit.
2424 config = {
2525 hook = function(keybinds)
2626 keybinds.unmap("norg", "n", "gtd")
27- keybinds.remap ("norg", "n", "<C-Space>", "gta ")
27+ keybinds.remap_event ("norg", "n", "<C-Space>", "core.norg.qol.todo_items.todo.task_done ")
2828 end,
2929 }
3030}
@@ -258,16 +258,30 @@ module.public = {
258258 bound_keys [neorg_mode ][mode ][key ] = bound_keys [neorg_mode ][mode ][key ] and nil
259259 end ,
260260
261- remap = function (neorg_mode , mode , old_key , new_key )
262- payload .rremap (neorg_mode , mode , old_key , mode , new_key )
261+ remap = function (neorg_mode , mode , key , new_rhs )
262+ local opts = bound_keys [neorg_mode ][mode ][key ].opts
263+
264+ payload .map (neorg_mode , mode , key , new_rhs , opts )
265+ end ,
266+
267+ remap_event = function (neorg_mode , mode , key , new_event )
268+ local opts = bound_keys [neorg_mode ][mode ][key ].opts
269+
270+ payload .map (
271+ neorg_mode ,
272+ mode ,
273+ key ,
274+ " <cmd>Neorg keybind " .. neorg_mode .. " " .. new_event .. " <CR>" ,
275+ opts
276+ )
263277 end ,
264278
265- rremap = function (neorg_mode , mode , old_key , new_mode , new_key )
279+ remap_key = function (neorg_mode , mode , old_key , new_key )
266280 local command = bound_keys [neorg_mode ][mode ][old_key ].command
267281 local opts = bound_keys [neorg_mode ][mode ][old_key ].opts
268282
269283 payload .unmap (neorg_mode , mode , old_key )
270- payload .map (neorg_mode , new_mode , new_key , command , opts )
284+ payload .map (neorg_mode , mode , new_key , command , opts )
271285 end ,
272286
273287 -- @Summary Maps a bunch of keys for a certain mode
@@ -333,21 +347,21 @@ module.public = {
333347 leader = module .config .public .neorg_leader ,
334348 }
335349
336- --- Generates a set of default functions for a given list of them
337- -- Default functions are postfixed with "d" and omit the beginning "neorg_mode"
338- -- parameter. The string "norg" is used in those places.
339- --- @vararg string A list of strings that define the functions to be given a default counterpart
340- local function generate_default_functions (...)
350+ local function generate_default_functions (cb , ...)
341351 local funcs = { ... }
342352
343353 for _ , func in ipairs (funcs ) do
344- payload [ func .. " d " ] = function (... )
345- payload [ func ]( " norg " , ... )
346- end
354+ local name , to_exec = cb ( func , payload [ func ] )
355+
356+ payload [ name ] = to_exec
347357 end
348358 end
349359
350- generate_default_functions (" map" , " map_event" , " unmap" , " remap" )
360+ generate_default_functions (function (name , func )
361+ return name .. " d" , function (...)
362+ func (" norg" , ... )
363+ end
364+ end , " map" , " map_event" , " unmap" , " remap" , " remap_key" , " remap_event" )
351365
352366 if
353367 module .config .public .default_keybinds
0 commit comments