Skip to content

Commit 63e4c5a

Browse files
feat(capture): Add option to template to refile whole file
1 parent 5a5b486 commit 63e4c5a

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lua/orgmode/capture/init.lua

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,10 @@ function Capture:_get_refile_vars()
445445
end
446446

447447
local source_file = self.files:get_current_file()
448-
local source_headline = source_file:get_headlines()[1]
448+
local source_headline = nil
449+
if not self._window.template.whole_file then
450+
source_headline = source_file:get_headlines()[1]
451+
end
449452
local destination_file = self.files:get(file)
450453
local destination_headline = nil
451454
if self._window.template.headline then

lua/orgmode/capture/template/init.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ local expansions = {
4343
---@field regexp? string
4444
---@field properties? OrgCaptureTemplateProperties
4545
---@field subtemplates? table<string, OrgCaptureTemplate>
46+
---@field whole_file? boolean
4647

4748
---@class OrgCaptureTemplate:OrgCaptureTemplateOpts
4849
---@field private _compile_hooks (fun(content:string):string)[]
@@ -62,6 +63,7 @@ function Template:new(opts)
6263
properties = { opts.properties, 'table', true },
6364
subtemplates = { opts.subtemplates, 'table', true },
6465
datetree = { opts.datetree, { 'boolean', 'table' }, true },
66+
whole_file = { opts.whole_file, 'boolean', true },
6567
})
6668

6769
local this = {}
@@ -72,6 +74,7 @@ function Template:new(opts)
7274
this.properties = TemplateProperties:new(opts.properties)
7375
this.datetree = opts.datetree
7476
this.regexp = opts.regexp
77+
this.whole_file = opts.whole_file
7578

7679
this.subtemplates = {}
7780
for key, subtemplate in pairs(opts.subtemplates or {}) do

0 commit comments

Comments
 (0)