Function: org-columns--capture-view

org-columns--capture-view is a byte-compiled function defined in org-colview.el.gz.

Signature

(org-columns--capture-view MAXLEVEL MATCH SKIP-EMPTY EXCLUDE-TAGS FORMAT LOCAL)

Documentation

Get the column view of the current buffer.

MAXLEVEL sets the level limit. SKIP-EMPTY tells whether to skip empty rows, an empty row being one where all the column view specifiers but ITEM are empty. EXCLUDE-TAGS is a list of tags that will be excluded from the resulting view. FORMAT is a format string for columns, or nil. When LOCAL is non-nil, only capture headings in current subtree.

This function returns a list containing the title row and all other rows. Each row is a list of fields, as strings, or hline.

Source Code

;; Defined in /usr/src/emacs/lisp/org/org-colview.el.gz
;;; Dynamic block for Column view

(defun org-columns--capture-view (maxlevel match skip-empty exclude-tags format local)
  "Get the column view of the current buffer.

MAXLEVEL sets the level limit.  SKIP-EMPTY tells whether to skip
empty rows, an empty row being one where all the column view
specifiers but ITEM are empty.  EXCLUDE-TAGS is a list of tags
that will be excluded from the resulting view.  FORMAT is a
format string for columns, or nil.  When LOCAL is non-nil, only
capture headings in current subtree.

This function returns a list containing the title row and all
other rows.  Each row is a list of fields, as strings, or
`hline'."
  (org-columns (not local) format)
  (goto-char org-columns-top-level-marker)
  (let ((columns (length org-columns-current-fmt-compiled))
	(has-item (assoc "ITEM" org-columns-current-fmt-compiled))
	table)
    (org-map-entries
     (lambda ()
       (when (get-char-property (point) 'org-columns-key)
	 (let (row)
	   (dotimes (i columns)
	     (let* ((col (+ (line-beginning-position) i))
		    (p (get-char-property col 'org-columns-key)))
	       (push (org-quote-vert
		      (get-char-property col
					 (if (string= p "ITEM")
					     'org-columns-value
					   'org-columns-value-modified)))
		     row)))
	   (unless (or
		    (and skip-empty
			 (let ((r (delete-dups (remove "" row))))
			   (or (null r) (and has-item (= (length r) 1)))))
		    (and exclude-tags
			 (cl-some (lambda (tag) (member tag exclude-tags))
				  (org-get-tags))))
	     (push (cons (org-reduced-level (org-current-level)) (nreverse row))
		   table)))))
     (if match
         (concat match (and maxlevel (format "+LEVEL<=%d" maxlevel)))
       (and maxlevel (format "LEVEL<=%d" maxlevel)))
     (and local 'tree)
     'archive 'comment)
    (org-columns-quit)
    ;; Add column titles and a horizontal rule in front of the table.
    (cons (mapcar #'cadr org-columns-current-fmt-compiled)
	  (cons 'hline (nreverse table)))))