Skip to content

Commit 6d23709

Browse files
feat: Rename search arguments to agenda views
1 parent c6afbb2 commit 6d23709

File tree

2 files changed

+20
-19
lines changed

2 files changed

+20
-19
lines changed

lua/orgmode/agenda/types/search.lua

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
local OrgAgendaTodosType = require('orgmode.agenda.types.todo')
33

44
---@class OrgAgendaSearchTypeOpts:OrgAgendaTodosTypeOpts
5-
---@field headline_search? string
5+
---@field headline_query? string
66

77
---@class OrgAgendaSearchType:OrgAgendaTodosType
8-
---@field headline_search? string
8+
---@field headline_query? string
99
local OrgAgendaSearchType = {}
1010
OrgAgendaSearchType.__index = OrgAgendaSearchType
1111

@@ -16,27 +16,27 @@ function OrgAgendaSearchType:new(opts)
1616
setmetatable(self, { __index = OrgAgendaTodosType })
1717
local obj = OrgAgendaTodosType:new(opts)
1818
setmetatable(obj, self)
19-
obj.headline_search = self.headline_search
20-
if not opts.headline_search or opts.headline_search == '' then
21-
obj.headline_search = self:get_search_term()
19+
obj.headline_query = self.headline_query
20+
if not opts.headline_query or opts.headline_query == '' then
21+
obj.headline_query = self:get_search_term()
2222
end
2323
return obj
2424
end
2525

2626
function OrgAgendaSearchType:get_file_headlines(file)
27-
return file:find_headlines_matching_search_term(self.headline_search or '', false, true)
27+
return file:find_headlines_matching_search_term(self.headline_query or '', false, true)
2828
end
2929

3030
function OrgAgendaSearchType:get_search_term()
31-
return vim.fn.OrgmodeInput('Enter search term: ', self.headline_search or '')
31+
return vim.fn.OrgmodeInput('Enter search term: ', self.headline_query or '')
3232
end
3333

3434
function OrgAgendaSearchType:redo()
3535
-- Skip prompt for custom views
3636
if self.is_custom then
3737
return self
3838
end
39-
self.headline_search = self:get_search_term()
39+
self.headline_query = self:get_search_term()
4040
return self
4141
end
4242

lua/orgmode/agenda/types/tags.lua

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ local Search = require('orgmode.files.elements.search')
44
local OrgAgendaTodosType = require('orgmode.agenda.types.todo')
55

66
---@class OrgAgendaTagsTypeOpts:OrgAgendaTodosTypeOpts
7-
---@field search_query? string
7+
---@field match_query? string
88

99
---@class OrgAgendaTagsType:OrgAgendaTodosType
1010
local OrgAgendaTagsType = {}
@@ -14,29 +14,29 @@ OrgAgendaTagsType.__index = OrgAgendaTagsType
1414
function OrgAgendaTagsType:new(opts)
1515
opts.todo_only = opts.todo_only or false
1616
opts.subheader = 'Press "r" to update search'
17-
local search_query = opts.search_query
18-
if not search_query or search_query == '' then
19-
search_query = self:get_tags(opts.files)
20-
if not search_query then
17+
local match_query = opts.match_query
18+
if not match_query or match_query == '' then
19+
match_query = self:get_tags(opts.files)
20+
if not match_query then
2121
return nil
2222
end
2323
end
2424

2525
setmetatable(self, { __index = OrgAgendaTodosType })
2626
local obj = OrgAgendaTodosType:new(opts)
2727
setmetatable(obj, self)
28-
obj.search_query = search_query
29-
obj.header = 'Headlines with TAGS match: ' .. obj.search_query
28+
obj.match_query = match_query
29+
obj.header = 'Headlines with TAGS match: ' .. obj.match_query
3030
return obj
3131
end
3232

3333
function OrgAgendaTagsType:get_file_headlines(file)
34-
return file:apply_search(Search:new(self.search_query or ''), self.todo_only)
34+
return file:apply_search(Search:new(self.match_query or ''), self.todo_only)
3535
end
3636

3737
---@param files? OrgFiles
3838
function OrgAgendaTagsType:get_tags(files)
39-
local tags = vim.fn.OrgmodeInput('Match: ', self.search_query or '', function(arg_lead)
39+
local tags = vim.fn.OrgmodeInput('Match: ', self.match_query or '', function(arg_lead)
4040
return utils.prompt_autocomplete(arg_lead, (files or self.files):get_tags())
4141
end)
4242
if vim.trim(tags) == '' then
@@ -46,11 +46,12 @@ function OrgAgendaTagsType:get_tags(files)
4646
end
4747

4848
function OrgAgendaTagsType:redo()
49+
-- Skip prompt for custom views
4950
if self.is_custom then
5051
return self
5152
end
52-
self.search_query = self:get_tags() or ''
53-
self.header = 'Headlines with TAGS match: ' .. self.search_query
53+
self.match_query = self:get_tags() or ''
54+
self.header = 'Headlines with TAGS match: ' .. self.match_query
5455
return self
5556
end
5657

0 commit comments

Comments
 (0)