reddit / emacs

org-agenda-custom-commands and hiding future scheduled tasks

pragmat1c1 · 2022-04-29 11:57
I have set my `org-agenda-custom-commands` to (among others) this: ```elisp (setq org-agenda-custom-commands `( ("x" "Scheduled tasks with Prio" ((tags-todo "+PRIORITY={A}" ((org-agenda-overriding-header "Scheduled Prio-A TODOs") (org-agenda-skip-function '(org-agenda-skip-entry-if 'unscheduled)))) (tags-todo "+PRIORITY={B}" ((org-agenda-overriding-header "Scheduled Prio-B TODOs") (org-agenda-skip-function '(org-agenda-skip-entry-if 'unscheduled)))) (tags-todo "+PRIORITY={C}" ((org-agenda-overriding-header "Scheduled Prio-C TODOs") (org-agenda-skip-function '(org-agenda-skip-entry-if 'unscheduled)))) (tags-todo "+PRIORITY={D}" ((org-agenda-overriding-header "Scheduled Prio-D TODOs") (org-agenda-skip-function '(org-agenda-skip-entry-if 'unscheduled)))) (agenda))) ;; snip ``` Now I would like to hide all tasks scheduled in the future. I can do this via ``` (progn (setq org-agenda-todo-ignore-scheduled 'future) (setq org-agenda-tags-todo-honor-ignore-options t)) ``` But this affects all of my other `org-agenda-custom-commands`. I would like to limit it to just one custom command. So how can I modify my custom command so that it hides the future tasks? ## Edit I have created a function to toggle future entries, but I'd like to incorporate it in the custom-command, if possible. Here is my function for toggling future items: ```elisp (defun ugt-org-toggle-future-items-in-agenda-view () "Show/hide future items in org-agenda views." (interactive) (if org-agenda-todo-ignore-scheduled (progn (setq org-agenda-todo-ignore-scheduled nil) (setq org-agenda-tags-todo-honor-ignore-options nil) (org-agenda-redo) (message "Showing future scheduled items in org-agenda.")) (progn (setq org-agenda-todo-ignore-scheduled 'future) (setq org-agenda-tags-todo-honor-ignore-options t) (org-agenda-redo) (message "Hiding future scheduled items in org-agenda.")))) ```
yantar92 · 2022-04-29 14:24
> I have created a function to toggle future entries, but I'd like to incorporate it in the custom-command, if possible. Variable assignments in the custom commands are executed during agenda build time. So, you can assign e.g. `org-agenda-todo-ignore-scheduled` to your custom variable (say, `ugt-org-ignore-future-items-in-agenda-view`), toggle that variable any time you wish and get agenda respect the new value after refreshing.