3

I'm trying to get how many times a task has been re-scheduled (the Sched.00x: you see in org-agenda for "today tasks"). But so far, I don't know how to extract information from the structure returned by org-agenda-get-day-entries.

My original plan was to regexp the hell out of the title, since it carries the information I'm looking, but I don't even know how to obtain from the data structure for the title of the entry. It doesn't seems like the number of times an entry was re-scheduled comes within the data structure.

This is my current code:

(let* ((files (org-agenda-files))
         (due-todos 0)
         (due-older 0)
         (today (calendar-current-date)))
    (dolist (file files)
      (let* ((entries (org-agenda-get-day-entries file today :scheduled :deadline)))
        (dolist (entry entries)
          ;; Get how many times the task was re-scheduled, and count it
          ))))
1

Suggesting another approach since org-agenda-get-day-entries parses more than you asked for:

(let (res)
  (dolist (i org-agenda-files)
    (with-current-buffer (get-file-buffer i)
      (org-with-wide-buffer
       (goto-char (point-min))
       (while (re-search-forward org-heading-regexp nil t)
         (push (cons
                (match-string-no-properties 2)
                (- (org-today) (time-to-days (org-get-scheduled-time (point)))))
               res)))))
  (seq-filter (lambda (x) (> (cdr x) 0)) res))

Alternatively, to retrieve the Sched.00x: strings, use get-text-property:

(mapcar (lambda (x) (get-text-property 0 'extra x))
        (org-agenda-get-day-entries
         file
         (calendar-current-date) :scheduled))
  • isn't better to let org-agenda-get-day-entries do the hard work of parsing the files? I don't mind if the function returns more information than I'm asking, I would like to know how to manipulate and extract the stuff is inside it. – shackra Oct 6 '16 at 21:27

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.