Hi,

In the preceding refactoring, I separated collecting column view data
from displaying it.

Displaying the rows is not necessary when exporting them to a column view
dynamic block.  I therefore propose using this separation to simplify
the data flow: prepare and collect the rows directly, without rendering
column overlays.

This patch updates `org-columns--capture-view' to call
`org-columns--prepare-rows' and read the values directly from the
collected rows.

Best,
-- 
Slawomir Grochowski
>From 2cf249e19b275fcc4c83a297a7b729efb31e68fe Mon Sep 17 00:00:00 2001
From: Slawomir Grochowski <[email protected]>
Date: Sun, 31 May 2026 21:55:29 +0200
Subject: [PATCH] org-colview: Capture column view without rendering overlays

* lisp/org-colview.el (org-columns--capture-view): Prepare rows directly
instead of enabling column view.  Read captured values from collected rows.

Dynamic block capture only needs the collected row data.  Use the
preparation helper directly and read captured values from collected rows
instead of properties stored on rendered column overlays.
---
 lisp/org-colview.el | 36 ++++++++++++++++++++----------------
 1 file changed, 20 insertions(+), 16 deletions(-)

diff --git a/lisp/org-colview.el b/lisp/org-colview.el
index f98dc21f2..fd4e6882f 100644
--- a/lisp/org-colview.el
+++ b/lisp/org-colview.el
@@ -1679,23 +1679,27 @@ to COLUMNS-FORMAT.  All subsequent lists each represent a body row as a
 list whose first element is an integer indicating the outline level of
 the entry, and whose remaining elements are strings with the contents
 for the columns according to COLUMNS-FORMAT."
-  (org-columns (not local) columns-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-columns-remove-overlays)
+  (setq-local org-columns-global (not local))
+  (let* ((rows (save-excursion
+		 (org-columns--prepare-rows (not local) columns-format)))
+	 (has-item (assoc "ITEM" org-columns-current-fmt-compiled))
+	 table)
+    (goto-char org-columns-top-level-marker)
     (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 (get-char-property col
-					(if (string= p "ITEM")
-					    'org-columns-value
-					  'org-columns-value-modified))
-		     row)))
+       (while (and rows (< (marker-position (caar rows)) (point)))
+	 (pop rows))
+       (when-let* ((triplets (and rows
+				  (= (marker-position (caar rows)) (point))
+				  (cdar rows))))
+	 (let ((row
+		(mapcar
+		 (pcase-lambda (`(,spec ,value ,displayed-value))
+		   (if (string= (org-columns--spec-property spec) "ITEM")
+		       value
+		     displayed-value))
+		 triplets)))
 	   (unless (or
 		    (and skip-empty
 			 (let ((r (delete-dups (remove "" row))))
@@ -1703,7 +1707,7 @@ for the columns according to COLUMNS-FORMAT."
 		    (and exclude-tags
 			 (cl-some (lambda (tag) (member tag exclude-tags))
 				  (org-get-tags))))
-	     (push (cons (org-reduced-level (org-current-level)) (nreverse row))
+	     (push (cons (org-reduced-level (org-current-level)) row)
 		   table)))))
      (if match
          (concat match (and maxlevel (format "+LEVEL<=%d" maxlevel)))
-- 
2.39.5

Reply via email to