Hi,

Here is an updated version of the patch.

Changes since v1:

- Remove a leftover `setq-local' of `org-columns-global': its only
  consumer is `org-columns-redo', which is unreachable during capture
  since column view is never rendered.
- Clear row markers once they are consumed.
- Compare markers directly with `<' and `=' instead of going through
  `marker-position'.

Best,
-- 
Slawomir Grochowski
>From ba69c8f3a0e6d66ae601211ecd0546bdba9c3c2a Mon Sep 17 00:00:00 2001
From: Slawomir Grochowski <[email protected]>
Date: Sun, 31 May 2026 21:55:29 +0200
Subject: [PATCH v2] 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 | 37 +++++++++++++++++++++----------------
 1 file changed, 21 insertions(+), 16 deletions(-)

diff --git a/lisp/org-colview.el b/lisp/org-colview.el
index a831278b4..4cfb97efd 100644
--- a/lisp/org-colview.el
+++ b/lisp/org-colview.el
@@ -1649,23 +1649,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)
+  (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 (< (caar rows) (point)))
+	 (set-marker (caar rows) nil)
+	 (pop rows))
+       (when-let* ((triplets (and rows
+				  (= (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))))
@@ -1673,13 +1677,14 @@ 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)))
        (and maxlevel (format "LEVEL<=%d" maxlevel)))
      (and local 'tree)
      'archive 'comment)
+    (dolist (row rows) (set-marker (car row) nil))
     (org-columns-quit)
     ;; Add column titles and a horizontal rule in front of the table.
     (cons (mapcar #'org-columns--spec-title org-columns-current-fmt-compiled)
-- 
2.39.5

Reply via email to