Function: org-agenda-colview-summarize

org-agenda-colview-summarize is a byte-compiled function defined in org-colview.el.gz.

Signature

(org-agenda-colview-summarize CACHE)

Documentation

Summarize the summarizable columns in column view in the agenda.

This will add overlays to the date lines, to show the summary for each day.

Source Code

;; Defined in /usr/src/emacs/lisp/org/org-colview.el.gz
(defun org-agenda-colview-summarize (cache)
  "Summarize the summarizable columns in column view in the agenda.
This will add overlays to the date lines, to show the summary for each day."
  (let ((fmt (mapcar
	      (lambda (spec)
		(pcase spec
		  (`(,property ,title ,width . ,_)
		   (if (member property '("CLOCKSUM" "CLOCKSUM_T"))
		       (list property title width ":" nil)
		     spec))))
	      org-columns-current-fmt-compiled)))
    ;; Ensure there's at least one summation column.
    (when (cl-some (lambda (spec) (nth 3 spec)) fmt)
      (goto-char (point-max))
      (catch :complete
	(while t
	  (when (or (get-text-property (point) 'org-date-line)
		    (eq (get-text-property (point) 'face)
			'org-agenda-structure))
	    ;; OK, this is a date line that should be used.
	    (let (entries)
	      (let (rest)
		(dolist (c cache)
		  (if (> (car c) (point))
		      (push c entries)
		    (push c rest)))
		(setq cache rest))
	      ;; ENTRIES contains entries below the current one.
	      ;; CACHE is the rest.  Compute the summaries for the
	      ;; properties we want, set nil properties for the rest.
	      (when (setq entries (mapcar #'cdr entries))
		(org-columns--display-here
		 (mapcar
		  (lambda (spec)
		    (pcase spec
		      (`("ITEM" . ,_)
		       ;; Replace ITEM with current date.  Preserve
		       ;; properties for fontification.
		       (let ((date (buffer-substring
				    (line-beginning-position)
				    (line-end-position))))
			 (list spec date date)))
		      (`(,_ ,_ ,_ nil ,_) (list spec "" ""))
		      (`(,_ ,_ ,_ ,operator ,printf)
		       (let* ((summarize (org-columns--summarize operator))
			      (values
			       ;; Use real values for summary, not
			       ;; those prepared for display.
			       (delq nil
				     (mapcar
				      (lambda (e) (org-string-nw-p
                                                   (nth 1 (assoc spec e))))
				      entries)))
			      (final (if values
					 (funcall summarize values printf)
				       "")))
			 (unless (equal final "")
			   (put-text-property 0 (length final)
					      'face 'bold final))
			 (list spec final final)))))
		  fmt)
		 'dateline))))
	  (if (bobp) (throw :complete t) (forward-line -1)))))))