Hello, Yes, the block is cleaned but the #+TBLFM line is included into `content-lines' so it's duplicated unless removed manually.
The solution with `save-excursion' looks more reliable but we can use just `looking-back' in the end of block to check if the last line is a #+TBLFM. Not sure if #+TBLFM can be placed in some other line though. And I'll check the ELPA rules and what should I do to prepare the correct package for org-collector. Best Regards, Slava Barinov Ihor Radchenko <yanta...@posteo.net> writes: > Slava Barinov <raysl...@gmail.com> writes: > >> Okay, in that case bounded re-search-forward up to the next paragraph should >> work. > > Hmm. I am wondering why you need that re-search-forward at all. > AFAIK, dblock write function is called with dynamic block body emptied: > > #+BEGIN: ... > <point> > > #+END: > > There should be no TBLFM present in there unless I miss something. > >> And as for maintenance, I think I can allocate some time for that. >> What activities are expected from a script maintainer? > > 1. You will need to create a separate repository for org-collector, > write readme there, setup issue tracker or mailing list (depending on > what you prefer) > 2. You will need to publish org-collector as a package on ELPA, or > nonGNU ELPA. Ideally, it should be ELPA because all the significant > contributors to org-collector signed FSF copyright, but that depends > on you willing to do the assignment yourself. > 3. You will need to reply to bug reports and patches from users. From > history, that's a few per year. If you do accept patches/fix bugs, > you will also need to make new releases.
>From f7ce82e02a1d7619186c9451be22fc6fef27eba2 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..b6f9532 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,13 @@ 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 + (if (looking-back "^#\\+TBLFM:.*$" (line-beginning-position)) + (delete-region (match-beginning 0) (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