Skip to content

Commit d053f86

Browse files
Fix parsing archive location.
1 parent 2a0dfed commit d053f86

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

lua/orgmode/parser/file.lua

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ local utils = require('orgmode.utils')
1616
---@field sections_by_line table<number, Section>
1717
---@field source_code_filetypes string[]
1818
---@field is_archive_file boolean
19+
---@field archive_location string
1920
---@field clocked_headline Section
2021
---@field tags string[]
2122
local File = {}
@@ -322,9 +323,8 @@ end
322323

323324
---@return string
324325
function File:get_archive_file_location()
325-
local matches = self:get_ts_matches('(document (directive (name) @name (value) @value (#eq? @name "ARCHIVE")))')
326-
if #matches > 0 then
327-
return config:parse_archive_location(self.filename, matches[1].value.text)
326+
if self.archive_location then
327+
return self.archive_location
328328
end
329329
return config:parse_archive_location(self.filename)
330330
end
@@ -384,9 +384,13 @@ function File:_parse_directives()
384384
local directives = self:get_ts_matches([[(directive name: (expr) @name value: (value) @value)]])
385385
local tags = {}
386386
for _, directive in ipairs(directives) do
387-
if directive.name.text:lower() == 'filetags' then
387+
local directive_name = directive.name.text:lower()
388+
if directive_name == 'filetags' then
388389
utils.concat(tags, utils.parse_tags_string(directive.value.text), true)
389390
end
391+
if directive_name == 'archive' then
392+
self.archive_location = config:parse_archive_location(self.filename, directive.value.text)
393+
end
390394
end
391395
self.tags = tags
392396
end

0 commit comments

Comments
 (0)