emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[FR] Transfer export attributes from dynamic block to its first child (w


From: Ihor Radchenko
Subject: [FR] Transfer export attributes from dynamic block to its first child (was: Bug: clocktable)
Date: Thu, 18 Jan 2024 15:26:35 +0000

<matthias@gnu.re> writes:

> J’ai un soucis avec le clocktable  qui semble être un bug car il n’accepte 
> pas les attributs latex avant la ligne BEGIN:

> #+ATTR_LATEX: :align Xll :width \textwidth
> #+BEGIN: clocktable :scope file :maxlevel 2

This is a commonly reported problem - when using dynamic blocks (in
particular, clocktable block), it is impossible to set export attributes
for the generated table. This is because the attributes of the dynamic
block have no effect on the table inside it.

I suggest to provide a standard dynamic block parameter that will make
Org mode prepend certain affiliated keywords to the generated contents:

#+attr_latex: :width \textwidth
#+begin: clocktable :scope file :maxlevel 2 :org-dblock-prepend (:attr_latex )
#+end:

will yield

#+attr_latex: :width \textwidth
#+begin: clocktable :scope file :maxlevel 2 :org-dblock-prepend (:attr_latex)
#+attr_latex: :width \textwidth
#+CAPTION: Clock summary at [2024-01-18 Thu 16:23]
| Headline   | Time    |
|------------+---------|
| *Total time* | *0h 0min* |
#+end:

Tentative patch is attached.

>From b6bfe67ed19b2c3a0c3744488f051c29e79a5b3d Mon Sep 17 00:00:00 2001
Message-ID: 
<b6bfe67ed19b2c3a0c3744488f051c29e79a5b3d.1705591555.git.yantar92@posteo.net>
From: Ihor Radchenko <yantar92@posteo.net>
Date: Thu, 18 Jan 2024 16:24:34 +0100
Subject: [PATCH] Allow transfering dblock affiliated keywords to its contents

* lisp/org.el (org-prepare-dblock): Use :org-dblock-prepend dblock
parameter and append the listed affiliated keywords before the
generated dynamic block contents.
---
 lisp/org.el | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/lisp/org.el b/lisp/org.el
index 8929a7217..585b9aa5b 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -8836,6 +8836,12 @@ (defun org-prepare-dblock ()
     (delete-region begdel (match-beginning 0))
     (goto-char begdel)
     (open-line 1)
+    (let ((prepend (plist-get params :org-dblock-prepend))
+          (dblock (org-element-at-point (1- (point))))
+          (affiliated (org-element-create 'paragraph)))
+      (dolist (prop prepend)
+        (org-element-put-property affiliated prop (org-element-property prop 
dblock))
+        (insert (org-element-interpret-data affiliated))))
     params))
 
 (defun org-map-dblocks (&optional command)
-- 
2.43.0

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>

reply via email to

[Prev in Thread] Current Thread [Next in Thread]