In my gradesheets I use overlays to display the grade property in headlines -- that way I can see at a glance approximately how my students are doing:
;; still imperfect, but good enough for me.
(defun org-grading-overlay-headings ()
"Show grades at end of headlines that have a 'GRADE' property."
(interactive)
(require 'ov)
(org-map-entries
(lambda ()
(when (org-entry-get (point) "GRADE")
(ov-clear (- (line-end-position) 1)
(+ 0 (line-end-position)))
(setq ov (make-overlay (- (line-end-position) 1)
(+ 0 (line-end-position))))
(setq character (buffer-substring (- (line-end-position) 1) (line-end-position)))
(overlay-put
ov 'display
(format "%s GRADE: %s CHITS: %s" character (org-entry-get (point) "GRADE") (org-entry-get (point) "CHITS")))
(overlay-put ov 'name "grading")
(message "%s" (overlay-get ov "name")))))
)
This mostly works, except that I've noticed that, when I regenerate the overlays after changes, certain folded trees end up with a duplicate overlay, for reasons that I don't quite understand (maybe because the ellipses at the end of the fold interfere with my counting somehow)?
I ould like to be able to find the named overlays and remove them all at once, something like this:
(defun matt-clear-overlay ()
(interactive)
(let ((all-overlays (overlays-in (point-min) (point-max))))
(dolist (x all-overlays)
(if (string= (overlay-get x "name") "grading")
(delete-overlay x)