emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] lisp/org-collector.el: Add support for TBLFM
@ 2024-12-07  3:56 Slava Barinov
  0 siblings, 0 replies; only message in thread
From: Slava Barinov @ 2024-12-07  3:56 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: Slava Barinov

The :tblfm keyword adds formulas to the end of table so they are applied right
after collection is done and the table is generated.

* lisp/org-collector.el (org-dblock-write:propview): Add support for the
:tblfm keyword.
---
 lisp/org-collector.el | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/lisp/org-collector.el b/lisp/org-collector.el
index b645d3a..69f4e0f 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,6 +149,15 @@ preceding the dblock, then update the contents of the dblock."
 	(while (setq line (pop content-lines))
 	  (when (string-match "^#" line)
 	    (insert "\n" line)))
+	(when tblfm
+	  (save-excursion
+            (goto-char (point-min))
+            (when (re-search-forward "^#\\+TBLFM:" nil 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))
-- 
2.47.1



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2024-12-07  3:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-07  3:56 [PATCH] lisp/org-collector.el: Add support for TBLFM Slava Barinov

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).