I had built an org-mode agenda function that looked through one org file that was filled with projects I was tracking and then filtering an org-mode agenda based upon the state of those projects.
Every task in my agenda file is linked to a project using a category. When I added this function to my agenda originally I added an skip function that iterated through the my projects file to find applicable projects. This caused my agenda’s to move incredibly slow. The slow code looked like this.
Org agenda custom commands set all the variables under them using let. All the agenda functions run will be able to use this local scope when they run. This means that instead of calling my org-map-entries function on every run, I can just do it once and set it to a variable that my later agenda commands will reference. Here it is again with the function run only once.
This also means that I can re-use org-project-skip-project with different skip-project lists set. As a final note; much of this can be applied to pre-existing skip functions. I am excited to explore what kind of interesting things I can “break” by re-assigning global variables and functions when creating agendas.