orgmode icon indicating copy to clipboard operation
orgmode copied to clipboard

Dynamically add files to `org_agenda_files`

Open gzagatti opened this issue 1 year ago • 4 comments

Does this feature exist in Emacs orgmode core?

N/A

Orgmode link

No response

Feature value

I usually take project notes using org, and I will keep those notes in the project folder.

It would be useful to add or drop a particular folder from org_agenda_files whenever needed. That way we do not bloat the amount of notes parsed by the plugin and allow the user to focus on the notes she/he needs at the moment.

Additional context

My guess would be to create a lua function (maybe in my init.lua) that would:

  1. change org_agenda_files
  2. call Config:get_all_files
  3. call File:reload().

Is that the way to go? Would I be missing something important?

gzagatti avatar Jul 13 '22 15:07 gzagatti

If you keep your projects in some specific folder, you could just do this:

org_agenda_files = { '~/main-org-files/**/*', '~/projects/**/*' }

This can be potentially slow if you have a lot of projects with lots of files, and if you don't ignore some vendor folders like node_modules and such. For that, make sure to use wildignore (see :help 'wildignore')

Another potential solution (haven't tried it, might have some issues), is to have a project specific setup (see :help exrc), and just call the setup for each project:

require('orgmode').setup({
  org_agenda_files = {'/path/to/this/project/**/*.org'}
})

kristijanhusak avatar Jul 13 '22 15:07 kristijanhusak

Would relative files work for you? In a project I have a readme.org or to do.org, I haven't tried it, but a relative path would mean your main agenda could be parsed and all local ones in the cwd


From: Kristijan Husak @.> Sent: Wednesday, July 13, 2022 11:51:02 AM To: nvim-orgmode/orgmode @.> Cc: Subscribed @.***> Subject: Re: [nvim-orgmode/orgmode] Dynamically add files to org_agenda_files (Issue #365)

If you keep your projects in some specific folder, you could just do this:

org_agenda_files = { '~/main-org-files//*', '~/projects//*' }

This can be potentially slow if you have a lot of projects with lots of files, and if you don't ignore some vendor folders like node_modules and such. For that, make sure to use wildignore (see :help 'wildignore')

Another potential solution (haven't tried it, might have some issues), is to have a project specific setup (see :help exrc), and just call the setup for each project:

require('orgmode').setup({ org_agenda_files = {'/path/to/this/project/**/*.org'} })

— Reply to this email directly, view it on GitHubhttps://github.com/nvim-orgmode/orgmode/issues/365#issuecomment-1183393512, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACQDVVYSMYZNMHGZNGMHCQDVT3QWNANCNFSM53PECZUQ. You are receiving this because you are subscribed to this thread.Message ID: @.***>

aareman avatar Jul 13 '22 22:07 aareman

Thanks for the suggestions.

I have tried adding the ~/projects/**/* to the table, but I find that it just gets too messy when looking for files. Maybe I just need a better organization system.

I have also tried with relative paths, but then when I open vim from my home directory it just takes forever to load everything.

Anyway, I will explore further with the options above and maybe write a custom function. Once I have a solution that works for me, I will report back.

gzagatti avatar Jul 14 '22 02:07 gzagatti

If you are opening nvim from the project folder (I do that 99.9% of the time), you can update your orgmode setup to this:

require('orgmode').setup({
  org_agenda_files = {'~/main-orgfiles', ('%s/*.org'):format(vim.fn.getcwd()) }
})

When you open up Neovim, it will additionally load all org files from the root project folder. If you need it nested, replace *.org with **/*.org, but that might cause some slowness, since it potentially goes through a lot of files.

kristijanhusak avatar Jul 14 '22 08:07 kristijanhusak