Hello, Oh! Sorry, it seems I missed the last email.
Okay, in that case bounded re-search-forward up to the next paragraph should work. And as for maintenance, I think I can allocate some time for that. What activities are expected from a script maintainer? Best Regards, Slava Barinov Ihor Radchenko <yanta...@posteo.net> writes: > Ihor Radchenko <yanta...@posteo.net> writes: > >> I am not familiar with org-collector code, but (goto-char (point-min)) >> seems dangerous - what if current Org buffer has multiple tables with >> TBLFM lines? > > It has been a while since the last message in this thread. > Have you had a chance to look into my comment?
>From 89325fcedf063ac69500ce9915721352819f9133 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 | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lisp/org-collector.el b/lisp/org-collector.el index b645d3a..ff1753d 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 @@ -148,7 +149,19 @@ preceding the dblock, then update the contents of the dblock." (while (setq line (pop content-lines)) (when (string-match "^#" line) (insert "\n" line))) - (goto-char pos) + (when tblfm + (save-excursion + (let ((search-end (progn + (forward-paragraph) + (point)))) + (goto-char pos) + (when (re-search-forward "^#\\+TBLFM:" search-end t) + (setq tblfm-pos (match-beginning 0)) + (delete-region tblfm-pos (line-end-position))))) + (unless (looking-back "\n" 1) + (insert "\n")) + (insert (concat "#+TBLFM:" tblfm))) + (goto-char pos) (org-table-recalculate 'all)) (org-collector-error (widen) (error "%s" er)) (error (widen) (error "%s" er)))) -- 2.48.1