Nicolas Goaziou <m...@nicolasgoaziou.fr> writes: > Hello, > > Stig Brautaset <s...@brautaset.org> writes: > >> I have the following column-mode defined in =~/org/Holidays.org=: >> >> #+BEGIN_SRC org >> ,#+COLUMNS: %TIMESTAMP(When) %ITEM(What) %CONFIRMED(Confirmed?){X/} >> %DAYS(Days){+} >> ,#+Confirmed_ALL: "[ ]" "[X]" >> ,#+TODO: TODO | DONE CANCELLED >> #+END_SRC >> >> Is it possible to have the =%DAYS(Days){+}= part only sum up rows that >> have an =[X]= in their =Confirmed?= property? > > Not out of the box. But you could write a function creating and updating > another property, e.g., CHECKED_DAYS and have columns view display this > instead.
Thank you! That's a great idea. I've managed to come up with the following, which works interactively: #+BEGIN_SRC emacs-lisp (defun sb/org-calc-confirmed-days () "For an entry with both a `CONFIRMED' and `DAYS' property, calculate `CONFIRMED_DAYS'" (let ((days (org-entry-get nil "DAYS")) (confirmed (org-entry-get nil "CONFIRMED"))) (when (and days (string= "[X]" confirmed)) (org-entry-put nil "CONFIRMED_DAYS" days)))) (defun sb/org-map-confirmed-days () "Map over entries and calculate confirmed days" (interactive) (org-map-entries #'sb/org-calc-confirmed-days)) #+END_SRC However, I would like to add an advice around =org-columns-compute-all= to run the =sb/org-map-confirmed-days= function, and this I have not been successful at. I've tried doing this: : (add-function :before org-columns-compute-all #'sb/org-map-confirmed-days) However, I keep getting the following error: : Use of gv-ref probably requires lexical-binding : advice--add-function: Symbol’s value as variable is void: org-columns-compute-all I would appreciate if anyone has any insight into solving this. Stig PS: I'm using Emacs and Org both installed from Git, on macOS.