diff --git a/org.el b/org.el index 8b57f7b..7463fbe 100644 --- a/org.el +++ b/org.el @@ -17430,15 +17430,20 @@ printf a printf format for computed values" ;;; Dynamic block for Column view -(defun org-columns-capture-view () - "Get the column view of the current buffer and return it as a list. -The list will contains the title row and all other rows. Each row is -a list of fields." +(defun org-columns-capture-view (&optional limit) + "Get the column view of the current buffer or subtree. +An optional argument LIMIT sets the level depth limit. +This function returns a list containing the title row and all +other rows. Each row is a list of fields." (save-excursion (let* ((title (mapcar 'cadr org-columns-current-fmt-compiled)) (n (length title)) row tbl) (goto-char (point-min)) - (while (re-search-forward "^\\*+ " nil t) + (while (and (re-search-forward "^\\(\\*+\\) " nil t) + (or (null limit) + (>= limit (if org-odd-levels-only + (/ (1+ (length (match-string 1))) 2) + (length (match-string 1)))))) (when (get-char-property (match-beginning 0) 'org-columns-key) (setq row nil) (loop for i from 0 to (1- n) do @@ -17466,6 +17471,7 @@ PARAMS is a property list of parameters: (let ((pos (move-marker (make-marker) (point))) (hlines (plist-get params :hlines)) (vlines (plist-get params :vlines)) + (limit (plist-get params :limit)) tbl id idpos nfields tmp) (save-excursion (save-restriction @@ -17477,7 +17483,7 @@ PARAMS is a property list of parameters: (goto-char idpos)) (t (error "Cannot find entry with :ID: %s" id)))) (org-columns) - (setq tbl (org-columns-capture-view)) + (setq tbl (org-columns-capture-view limit)) (setq nfields (length (car tbl))) (org-columns-quit))) (goto-char pos)