Skip to content

Commit 2adb21e

Browse files
Add helper function for opening capture template by shortcut.
1 parent 171ef59 commit 2adb21e

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

lua/orgmode/capture/init.lua

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,15 @@ function Capture:open_template(template)
4949
vim.cmd([[autocmd OrgCapture BufWipeout <buffer> ++once lua require('orgmode').action('capture.refile', true)]])
5050
end
5151

52+
---@param shortcut string
53+
function Capture:open_template_by_shortcut(shortcut)
54+
local template = self.templates[shortcut]
55+
if not template then
56+
return utils.echo_error('No capture template with shortcut ' .. shortcut)
57+
end
58+
return self:open_template(template)
59+
end
60+
5261
---Triggered when refiling from capture buffer
5362
---@param confirm? boolean
5463
function Capture:refile(confirm)

0 commit comments

Comments
 (0)