orgmode
orgmode copied to clipboard
Custom or more Agenda views
Does this feature exist in Emacs orgmode core?
Yes
Orgmode link
https://orgmode.org/manual/Custom-Agenda-Views.html
Feature value
This would allow the user “to store and quickly access frequently used TODO and tags searches, and to create special composite agenda buffers”. My particular use case would be a “dailies” view for a GTD workflow. Show the normal agenda for the current day on a 1-day span and beneath that, all non-scheduled TODOs filtered by some tag and sorted by the priority. But I would also use this to compose weekly review views filtered by properties and sorted by, for example entry date. Ideally, this would be as flexible as in Emacs with custom commands to view saved filters and searches (can already be done with the API, i.e. require("orgmode".api.agenda).todos({ filter = "refile+TAG" }), but this approach is not built-in, flexible enough and does not work with TODOS because the query stills pops up) and the "block agenda", where several views can be combined.
Also, I would love to see a column view, but this is better tackled in another issue.
Additional context
A minimal non-working example for my usecase is
local agenda = require("orgmode").instance().agenda
local AgendaTodosView = require('orgmode.agenda.views.todos')
local AgendaView = require('orgmode.agenda.views.agenda')
local utils = require("orgmode.utils")
agenda:open_window()
agenda.win_width = utils.winwidth()
local view1 = AgendaView:new(vim.tbl_deep_extend('force', opts or {}, {
filters = agenda.filters,
win_width = agenda.win_width,
})):build()
local view2 = AgendaTodosView:new(vim.tbl_deep_extend('force', opts or {}, {
filters = agenda.filters,
win_width = agenda.win_width,
})):build()
agenda.views = { view1, view2 }
vim.b.org_agenda_type = type
return agenda:_render()
This produces the wanted agenda ("calendar") + TODOs view, but the highlighting is off, it seems the TODOs highlighting is applied to the whole buffer as if only the TODOs were present.
Some video references:
- https://www.youtube.com/watch?v=-9rpQA6O3aM
- https://www.youtube.com/watch?v=8BOiRmjw5aU
Sorry to bump this thread just to ask a question, but does this request imply, that it currently isn't possible to f.ex. display more than one week via the agenda shortcut / function? I'm trying to find this option, but had no luck so far
f.ex. display more than one week via the agenda shortcut
I think I don't exactly understand what you want to achieve. Could you please elaborate? Thanks :)
@nilsdev if you still around, it's possible, although the original issue is more about combining multiple agenda views which is not that easy.
There actually a simple way to save and bind commonly used match queries (oam and oaM) and agenda views overriding options. In case of match query or keyword search agenda you need to press Enter to show the agenda, it will just prefill the query for you.
So, if you like me stumbled across this issue trying to find a way to setup custom match queries in you vim config, there are a few examples of how you can do that.
A full example for match query:
local org = require('orgmode').setup({ ... })
vim.keymap.set('n', '<leader>cor', function() org.agenda:tags({ todo_only = true, search = 'recurring' }) end)
search- the desired query to match, in the example it isrecurringtagtodo_only- query only TODO items
An example for agenda query function:
function() org.agenda:agenda({ org_agenda_start_day = '-3d', show_clock_report = true }) end
And a little bit more complex function would work for keywords search query (you can one line it if you like):
function()
local AgendaSearchView = require('orgmode.agenda.views.search')
org.agenda:open_agenda_view(AgendaSearchView, 'search', { search = 'install' })
end
To see the list of available options for different views, you can check constructors here. Refer to function *:new(opts), everything that comes from opts can be customized.
UPD: A few cents regarding the topic of the original issue comparing to Orgmode Custom Agenda Views:
- Storing searches - possible, not very native
- Setting options for custom commands - also possible, but limited options
- Block agenda - hard to do natively, but it's always possible to save a few queries and open multiple vim instances, I honestly don't see many difference
Thanks @acmilanfan for your insightful answer, I've tried tweaking it for my case but I'm a little bit lost, I hope someone can guide me a bit.
I'm trying to show an agenda view of elements that match a search criteria +inbox for example. I've seen that the AgendaView doesn't have a search opts. I've tried building the filters object to match the +inbox but found no way to do this. So far I have;
local org = require('orgmode').setup({ ... })
local AgendaView = require('orgmode.agenda.views.agenda')
local AgendaFilter = require('orgmode.agenda.filter')
vim.keymap.set(
'n',
'gi',
function()
local filter = AgendaFilter:new()
filter:parse('+inbox')
org.agenda:open_agenda_view(
AgendaView,
'agenda',
{
org_agenda_start_day = "-0d",
span = 3,
filters = filter
})
end
)
But it doesn't work :(. Any idea of how to make this work?
Thanks!
@lyz-code Thank you for your comment! There is another option for agenda, which in your case would be easier to use, it is provided in this location.
The agenda function to bind will be as simple as this:
function()
require('orgmode.api.agenda').agenda({
span = 3,
filters = '+inbox'
})
end
UPD: this agenda API does not support org_agenda_start_day offset, only from date, so I removed it from the example.
Amazing, it works! thank you so much
I don't understand why but adding the local AgendaView = require('orgmode.agenda.views.agenda') line in my configuration breaks the concealment of links :S