orgmode icon indicating copy to clipboard operation
orgmode copied to clipboard

Filtering the agenda using the API ignores categories

Open mdietrich16 opened this issue 2 years ago • 0 comments

Describe the bug

Using the normal agenda and TODO views, filtering can be done on tags and categories. When using the API, filtering seems to ignore categories. When the TODO-list has been brought up before and a filter was applied, using the API to bring up the TODOs and set the filter ignores the categories and applies them on reapplying the filter. However, when no filter was applied beforehand, using the API breaks the filtering system completely until the "normal" way of bringing up the TODOs und filtering resets the filter. Also, the API agenda and TODOs only work after the normal agenda was pulled up before.

Steps to reproduce

Bringing up the TODOs with <leader>oat, then filtering with / with a query of -@tag-category filters successfully. Quitting the TODO view and bringing up the to-dos with

require("orgmode.api.agenda").todos({ filters = "-@tag-category" })

filters out the @tag-tag, but not the category. If you bring up the filter again with / and simply press <CR>, the filter gets applied with the categories filtered.

However, after restarting Neovim, and only bringing up the TODOs with <leader>oat, not filtering leads to a different outcome. Quitting the view and bringing up the to-dos with

require("orgmode.api.agenda").todos({ filters = "-@tag-category" })

filters out the @tag-tag, but not the category, but upon bringing up the filtering prompt again and just reapplying with <CR> the filtering is reset and does not work anymore. Only bringing up the usual TODO view and applying a different filter solves this.

Expected behavior

Tags as well as categories should be filtered when using the API to access the agenda, like when using the normal filtering with an opened agenda.

Emacs functionality

No response

Minimal init.lua

local status_ok, orgmode = pcall(require, "orgmode")
if not status_ok then
    return
end

orgmode.setup_ts_grammar()

orgmode.setup({
    org_agenda_files = { '~/Sync/org/gtd.org', '~/Sync/org/inbox.org', '~/Sync/org/calendar.org',
        '~/Sync/org/someday.org',
        '~/Sync/org/reference/*.org' },
    org_default_notes_file = '~/Sync/org/inbox.org',
    org_todo_keywords = { 'TODO(t)', 'WAITING(w)', 'NEXT(n)', '|', 'DONE(d)', 'CANCELLED(c)', 'DEFERRED(f)' },
    org_todo_keyword_faces = {
        NEXT = ":foreground white :background red :weight bold",
        WAITING = ":underline on",
    },
    org_capture_templates = {
        t = {
            description = 'Task',
            template = '** TODO %^{Brief Description:|Declarative Verb}\n    :PROPERTIES:\n    :CREATED: %U\n    :END:\n\n    %?\n',
            target = '~/Sync/org/inbox.org',
        },
    },
    org_agenda_skip_scheduled_if_done = true,
    org_agenda_skip_deadline_if_done = true,
    org_priority_highest = 'A',
    org_priority_default = 'C',
    org_priority_lowest = 'D',
    org_hide_emphasis_markers = true,
    org_highlight_latex_and_related = "entities",
    org_indent_mode = 'indent',
    org_edit_src_content_indentation = 2,
    win_split_mode = 'vertical',
    notifications = {
        enabled = true,
        cron_enabled = true,
        repeater_reminder_time = { 30, 5, 1, 0 },
        deadline_warning_reminder_time = { 30, 0 },
        reminder_time = { 30, 5, 1, 0 },
        deadline_reminder = true,
        scheduled_reminder = true,
    },
    mappings = {
        org = {
            org_refile = false,
        },
    },
})

require("org-bullets").setup({})

Screenshots and recordings

No response

OS / Distro

Arch Linux

Neovim version/commit

0.8.2

Additional context

The only difference I could find between the API and the agenda filtering is in this line. Maybe this should get called when using the API as well?

mdietrich16 avatar Jan 05 '23 12:01 mdietrich16