Hello, Okay, in that case we can just merge two loops into one and filter out the #+TBLFM line. This version works for me.
Best Regards, Slava Barinov Ihor Radchenko <yanta...@posteo.net> writes: > Slava Barinov <raysl...@gmail.com> writes: > >> 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. > > Maybe a simpler approach would be modifying > > (while (setq line (pop content-lines)) > (when (string-match "^#" line) > (insert "\n" line))) > > to skip inserting TBLFM lines when :tblfm parameter is provided. > >> And I'll check the ELPA rules and what should I do to prepare the correct >> package for org-collector. > > The rules are in > https://git.savannah.gnu.org/cgit/emacs/elpa.git/plain/README > ("To add a package" section) > > But in the nutshell, you simply need to write to emacs-de...@gnu.org > sharing your code repo and expressing your interest to get the package > on ELPA. They will guide you along then. > > For org-collector specifically, please also CC me, so that I confirm > that Org mode project is ok with the transfer.
>From 3760ced8e0e20036758b7d834b2607cbe2779c3f 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 | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lisp/org-collector.el b/lisp/org-collector.el index b645d3a..926d768 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 @@ -140,14 +141,15 @@ preceding the dblock, then update the contents of the dblock." (if colnames colnames cols)) stringformat))) (widen)) (setq pos (point)) - (when content-lines - (while (string-match "^#" (car content-lines)) - (insert (pop content-lines) "\n"))) - (insert table) (insert "\n|--") (org-cycle) (move-end-of-line 1) - (message (format "point-%d" pos)) (while (setq line (pop content-lines)) - (when (string-match "^#" line) - (insert "\n" line))) + (when (and (string-match-p "^#" (substring-no-properties line)) + (not (string-match-p "^#\\+TBLFM:" (substring-no-properties line)))) + (insert line "\n"))) + (insert table) (insert "\n|--") (org-cycle) (move-end-of-line 1) + (when tblfm + (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)) -- 2.48.1