0

I have currently a very simple custom agenda view, which displays a daily view, important tasks (those tasks with priority A), and pending tasks (those tasks whose todo keyword is WAITING).

I would like to add another category in this agenda view, which would be the "quick picks", i.e. those tasks whose effort estimates are lower than 0:15.

Until now, I have only managed to filter the tasks whose effort estimates are exactly equal to 0:15, and I struggle to find an easy solution for all tasks inferior to 0:15.

Here is the piece of code I use:

(defun perso/quickpick (arg)
  "Display entries that have effort estimate equal to ARG."
    (org-tags-view t
                   (format "Effort=\"%s\"" arg)))

(setq org-agenda-custom-commands
      '(("d" "Custom daily agenda"
         ((agenda "" ((org-agenda-span 'day)))
          (tags "PRIORITY=\"A\""
                ((org-agenda-skip-function '(org-agenda-skip-entry-if 'todo 'done))
                 (org-agenda-overriding-header "Important tasks")))
          (todo "WAITING"
                ((org-agenda-overriding-header "Pending tasks")))
          (perso/quickpick "0:15"
                     ((org-agenda-overriding-header "Quickies")))))))

Is there a simple solution to adapt perso/quickpick and/or org-agenda-custom-commands to get what I want?

Thanks!


Addendum: A MWE org file with one item per category:

#+PROPERTY: Effort_ALL 0:05 0:10 0:15 0:20 0:30 0:45 1:00 1:30 2:00 3:00

* TODO Wash the car
SCHEDULED: <2020-07-01>

* WAITING Fix a bug

* TODO A quick task
  :PROPERTIES:
  :Effort:   0:15
  :END:

* TODO [#A] An important task
  • 1
    So what happens if you modify the call to org-tags-view in perso/quickpick to use "Effort<=%f"? – NickD Jul 1 at 12:45
  • ... and also modify the call in the commands to drop the quotes around 0.15? – NickD Jul 1 at 12:46
  • Thanks! I tried with (format "Effort<=%f" arg) and (perso/quickpick 0.15 (etc.). All TODO items were displayed in the "Quickies" section, so it did not work. (But this is a central part of the question: I don't know how to treat effort estimates as floats, since they are basically [duration-]strings.) Maybe an additional precision: my effort estimates are set with #+PROPERTY: Effort_ALL 0:05 0:10 0:15 0:20 0:30 0:45 1:00 1:30 2:00 3:00. – Philopolis Jul 1 at 13:18
0

Maybe not really elegant, but I finally found a way to do this by writing two custom functions.

The first one simply extracts the property value "Effort" of a given org headline (maybe there was a built-in way to do this, but I could not find it):

(defun fs/org-get-effort-estimate ()
  "Return effort estimate when point is at a given org headline.
If no effort estimate is specified, return nil."
  (let ((limits (org-get-property-block)))
    (save-excursion
      (when (and limits                            ; when non-nil
                 (re-search-forward ":Effort:[ ]*" ; has effort estimate
                                    (cdr limits)
                                    t))
        (buffer-substring-no-properties (point)
                                        (re-search-forward "[0-9:]*"
                                                           (cdr limits)))))))

The second one is a function that will be passed to org-agenda-skip-function: it skips those org entries that do not have an effort estimate, or that have an effort estimate > 0:15.

(defun fs/org-search-for-quickpicks ()
  "Display entries that have effort estimates inferior to 15.
ARG is taken as a number."
  (let ((efforts (mapcar 'org-duration-from-minutes (number-sequence 1 15 1)))
        (next-entry (save-excursion (or (outline-next-heading) (point-max)))))
    (unless (member (fs/org-get-effort-estimate) efforts)
      next-entry)))

Finally, a custom agenda view which does the trick:

(setq org-agenda-custom-commands
      '(("d" "Custom daily agenda"
         ((agenda ""
                  ((org-agenda-span 'day))
                  (org-agenda-overriding-header "Agenda du jour"))
          (tags "PRIORITY=\"A\""
                ((org-agenda-skip-function '(org-agenda-skip-entry-if 'todo 'done))
                 (org-agenda-overriding-header "Tâches importantes à finaliser")))
          (todo "WAITING"
                ((org-agenda-overriding-header "Tâches en attente")))
          (alltodo ""
                  ((org-agenda-skip-function 'fs/org-search-for-quickpicks)
                   (org-agenda-overriding-header "Tâches rapides")))))))
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.