@@ -306,17 +306,29 @@ function Agenda:search(clear_search)
306
306
end
307
307
308
308
-- TODO: Add PROP/TODO Query
309
- function Agenda :tags (clear_search )
310
- if clear_search then
309
+ function Agenda :tags (opts )
310
+ opts = opts or {}
311
+ local tags = opts .tags
312
+
313
+ if opts .clear_search then
311
314
self .last_search = ' '
312
315
end
313
- local tags = vim .fn .input (' Match: ' , self .last_search , ' customlist,v:lua.orgmode.autocomplete_agenda_filter_tags' )
316
+
317
+ if not tags then
318
+ tags = vim .fn .input (' Match: ' , self .last_search , ' customlist,v:lua.orgmode.autocomplete_agenda_filter_tags' )
319
+ end
314
320
if vim .trim (tags ) == ' ' then
315
321
return utils .echo_warning (' Invalid tag.' )
316
322
end
317
323
local headlines = {}
318
324
for _ , orgfile in ipairs (Files .all ()) do
319
- for _ , headline in ipairs (orgfile :get_headlines_with_tags (tags )) do
325
+ local headlines_filtered
326
+ if opts .todo_only then
327
+ headlines_filtered = orgfile :get_unfinished_todo_entries_with_tags (tags )
328
+ else
329
+ headlines_filtered = orgfile :get_headlines_with_tags (tags )
330
+ end
331
+ for _ , headline in ipairs (headlines_filtered ) do
320
332
table.insert (headlines , headline )
321
333
end
322
334
end
@@ -376,7 +388,8 @@ function Agenda:prompt()
376
388
{ label = ' ' , separator = ' -' , length = 34 },
377
389
{ label = ' Agenda for current week or day' , key = ' a' , action = function () return self :agenda () end },
378
390
{ label = ' List of all TODO entries' , key = ' t' , action = function () return self :todos () end },
379
- { label = ' Match a TAGS query' , key = ' m' , action = function () return self :tags (true ) end },
391
+ { label = ' Match a TAGS query' , key = ' m' , action = function () return self :tags ({clear_search = true , tags = nil , todo_only = false }) end },
392
+ { label = ' Like m, but only TODO entries' , key = ' M' , action = function () return self :tags ({clear_search = true , tags = nil , todo_only = true }) end },
380
393
{ label = ' Search for keywords' , key = ' s' , action = function () return self :search (true ) end },
381
394
{ label = ' Quit' , key = ' q' },
382
395
{ label = ' ' , separator = ' ' , length = 1 },
0 commit comments