Skip to content

Commit 96a30ff

Browse files
feat(files): Add get_directive method to file
1 parent c79e06c commit 96a30ff

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

lua/orgmode/files/file.lua

+7
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,13 @@ function OrgFile:get_links()
629629
return links
630630
end
631631

632+
memoize('get_directive')
633+
---@param directive_name string
634+
---@return string | nil
635+
function OrgFile:get_directive(directive_name)
636+
return self:_get_directive(directive_name)
637+
end
638+
632639
---@private
633640
---@return string | nil
634641
function OrgFile:_get_directive(directive_name)

tests/plenary/files/file_spec.lua

+13
Original file line numberDiff line numberDiff line change
@@ -815,5 +815,18 @@ describe('OrgFile', function()
815815
})
816816
assert.are.same('112233', file:get_property('custom_id'))
817817
end)
818+
819+
it('should get directive', function()
820+
local file = load_file_sync({
821+
':PROPERTIES:',
822+
':ID: 443355',
823+
':CUSTOM_ID: 112233',
824+
':END:',
825+
'#+somedirective: somevalue',
826+
'#+title: test',
827+
'* TODO Headline 1',
828+
})
829+
assert.are.same('somevalue', file:get_directive('somedirective'))
830+
end)
818831
end)
819832
end)

0 commit comments

Comments
 (0)