Hello,

Okay, agreed.  

Best Regards,
Slava Barinov

Ihor Radchenko <yanta...@posteo.net> writes:

> Slava Barinov <raysl...@gmail.com> writes:
>
>> Ah! At last I've got the concern.
>>
>> You said about the situation where we want to save the manually inserted 
>> TBLFM
>> when regenerating the table?
>
> Yup. That's what people expect in Org dynamic blocks.
>
>> +    (when tblfm
>> +      (unless (looking-back "\n" 1)
>
> `looking-back' is generally slow.
> I suggest `char-before'.
>From 2336e951cbc5424ab7fd4636a5ab0f6cdf7952d0 Mon Sep 17 00:00:00 2001
From: Slava Barinov <raysl...@gmail.com>
Date: Fri, 21 Feb 2025 20:45:41 +0900
Subject: [PATCH] lisp/org-collector.el (org-dblock-write:propview): Add
 support for the :tblfm keyword.

---
 lisp/org-collector.el | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/lisp/org-collector.el b/lisp/org-collector.el
index b645d3a..d5b97ac 100644
--- a/lisp/org-collector.el
+++ b/lisp/org-collector.el
@@ -122,6 +122,7 @@ preceding the dblock, then update the contents of the dblock."
 	    (noquote (plist-get params :noquote))
 	    (colnames (plist-get params :colnames))
 	    (defaultval (plist-get params :defaultval))
+	    (tblfm (plist-get params :tblfm))
 	    (content-lines (org-split-string (plist-get params :content) "\n"))
 	    id table line pos idpos stringformat)
 	(save-excursion
@@ -147,7 +148,13 @@ preceding the dblock, then update the contents of the dblock."
 	(message (format "point-%d" pos))
 	(while (setq line (pop content-lines))
 	  (when (string-match "^#" line)
-	    (insert "\n" line)))
+	    (unless (and tblfm
+			 (string-match "^#\\+TBLFM:" line))
+	      (insert "\n" line))))
+	(when tblfm
+	  (unless (eq (char-before) ?\n)
+	    (insert "\n"))
+	  (insert (concat "#+TBLFM:" tblfm)))
 	(goto-char pos)
 	(org-table-recalculate 'all))
     (org-collector-error (widen) (error "%s" er))
-- 
2.48.1

Reply via email to