alphapapa / org-super-agenda

Supercharge your Org daily/weekly agenda by grouping items
GNU General Public License v3.0
1.35k stars 107 forks source link

A question relating the use of predicates #158

Closed djelenc closed 4 years ago

djelenc commented 4 years ago

Thank you for making such a nice piece of software. I am a beginner in elisp and I have a question regarding the use of :pred.

My tasks are organized into projects using hierarchical structure, like the following.

* Project 1 title
** DONE Task A
** TODO Task B
** TODO Task C

* Project 2 title
** TODO Task 1
** TODO Task 2

When generating the daily agenda, I'd like to display only the first TODO task for each project. So for this example, I'd like to list only Task B and Task 1.

I was thinking of using predicates, but I was unable to get a solution.

Actually I am tying to achieve the same as described here. The relevant part---there implemented as skipping condition---is the following code snippet.

(setq org-agenda-custom-commands 
      '(("o" "At the office" tags-todo "@office"
         ((org-agenda-overriding-header "Office")
          (org-agenda-skip-function #'my-org-agenda-skip-all-siblings-but-first)))))

(defun my-org-agenda-skip-all-siblings-but-first ()
  "Skip all but the first non-done entry."
  (let (should-skip-entry)
    (unless (org-current-is-todo)
      (setq should-skip-entry t))
    (save-excursion
      (while (and (not should-skip-entry) (org-goto-sibling t))
        (when (org-current-is-todo)
          (setq should-skip-entry t))))
    (when should-skip-entry
      (or (outline-next-heading)
          (goto-char (point-max))))))

(defun org-current-is-todo ()
  (string= "TODO" (org-get-todo-state)))

I tried to use the code directly (by modifying the function signature to take a single argument), but it does not work. Any help would be greatly appreciated.

alphapapa commented 4 years ago

Thanks for the kind words. I'm glad this package is useful to you.

Your request is not necessarily related to this package, but is about designing and implementing Org Agenda-like views in general. Packages like org-super-agenda and org-ql may be helpful for doing so, perhaps in concert with some Org Agenda features.

I prefer not to attempt to offer open-ended tech support here, because only I can respond to it, which places the burden solely on me, and only you can benefit from the responses, which deprives the wider community of learning. Please consider asking this question on a more appropriate forum, like https://old.reddit.com/r/orgmode, https://old.reddit.com/r/emacs, the Org mailing list, the emacs-help list, etc. If you do ask on Reddit, you can tag me as u/github-alphapapa, and I may be able to offer some help there.

djelenc commented 4 years ago

Thank you for you response. I understand and I'll ask on reddit as suggested.