I have this code:
(defun org-get-logbook-notes ()
(save-excursion
(unless (org-at-heading-p)
(outline-previous-heading))
(when (re-search-forward ":LOGBOOK:" (save-excursion
(outline-next-heading)
(point))
t)
(let* ((elt (org-element-property-drawer-parser nil))
(beg (org-element-property :contents-begin elt))
(end (org-element-property :contents-end elt)))
(buffer-substring-no-properties beg end)))))
(require 's)
(defun my/org-rotten-set ()
(interactive "P")
(setq lognotes (org-get-logbook-notes))
(setq numresched (number-to-string (s-count-matches "Rescheduled from" lognotes)))
(org-entry-put nil "ROTTEN" numresched ))
What it should do is simply the following task:
- Get the contents of the :LOGBOOK: drawer
- Count how many times the string "Rescheduled from" occurs
- Transform this into a number and create a property "ROTTEN" with this number as a value
If I use IELM, place the point inside a single entry in my orgfile and execute
ELISP> (my/org-rotten-set)
This works perfectly fine. The occurences of "Rescheduled from" will be count, the "ROTTEN" property will be created.
Now if I try to use this function together with org-map-entries it doesn't work.
ELISP> (org-map-entries 'my/org-rotten-set)
*** Eval error *** Wrong type argument: char-or-string-p, nil
What am I doing wrong here? It seems to be related to the org-get-logbook-notes function that I defined a the beginning, but I have no idea why?