diff --git a/ORGWEBPAGE/Changes.org b/ORGWEBPAGE/Changes.org index 3136ea8e6..bcf7e539d 100644 --- a/ORGWEBPAGE/Changes.org +++ b/ORGWEBPAGE/Changes.org @@ -32,6 +32,13 @@ ** Details +*** Column view capture tables can have formulas and plotting instructions + If you attach formulas and plotting instructions to a table + capturing column view, these extra lines will now survive an + update of the coloumn view capture, and any formulas will be + re-applied to the captured table. This works be keeping any + continuous block of comments bfore an after the actual table. + *** The note buffer for clocking out now mentions the task This was a request by Peter Frings. diff --git a/doc/org.texi b/doc/org.texi index 2597ea683..d9a5ad711 100644 --- a/doc/org.texi +++ b/doc/org.texi @@ -4100,6 +4100,11 @@ Update all dynamic blocks (@pxref{Dynamic blocks}). This is useful if you have several clock table blocks in a buffer. @end table +You can add formulas to the column view table and you may add plotting +instructions in front of the table - these will survive an update of the +block. If there is a @code{#+TBLFM:} after the table, the table will actually +be recalculated automatically after an update. + @node Property API, , Column view, Properties and Columns @section The Property API @cindex properties, API diff --git a/lisp/org-colview.el b/lisp/org-colview.el index de2ee3c78..761309e1a 100644 --- a/lisp/org-colview.el +++ b/lisp/org-colview.el @@ -1059,8 +1059,9 @@ PARAMS is a property list of parameters: (hlines (plist-get params :hlines)) (vlines (plist-get params :vlines)) (maxlevel (plist-get params :maxlevel)) + (content-lines (org-split-string (plist-get params :content) "\n")) (skip-empty-rows (plist-get params :skip-empty-rows)) - tbl id idpos nfields tmp) + tbl id idpos nfields tmp recalc line) (save-excursion (save-restriction (when (setq id (plist-get params :id)) @@ -1095,12 +1096,22 @@ PARAMS is a property list of parameters: tbl)) (setq tbl (append tbl (list (cons "/" (make-list nfields "<>")))))) (setq pos (point)) + (when content-lines + (while (string-match "^#" (car content-lines)) + (insert (pop content-lines) "\n"))) (insert (org-listtable-to-string tbl)) (when (plist-get params :width) (insert "\n|" (mapconcat (lambda (x) (format "<%d>" (max 3 x))) org-columns-current-widths "|"))) - (goto-char pos) - (org-table-align)))) + (while (setq line (pop content-lines)) + (when (string-match "^#" line) + (insert "\n" line) + (when (string-match "^#\\+TBLFM" line) + (setq recalc t)))) + (if recalc + (progn (goto-char pos) (org-table-recalculate 'all)) + (goto-char pos) + (org-table-align))))) (defun org-listtable-to-string (tbl) "Convert a listtable TBL to a string that contains the Org-mode table. diff --git a/lisp/org.el b/lisp/org.el index 684892af5..26e8117d1 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -13149,7 +13149,7 @@ This command does many different things, depending on context: ((save-excursion (beginning-of-line 1) (looking-at "#\\+BEGIN:")) ;; Dynamic block (beginning-of-line 1) - (org-update-dblock)) + (save-excursion (org-update-dblock))) ((save-excursion (beginning-of-line 1) (looking-at "#\\+\\([A-Z]+\\)")) (cond ((equal (match-string 1) "TBLFM")