emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@posteo.net>
To: matthias@gnu.re
Cc: emacs-orgmode@gnu.org
Subject: [FR] Transfer export attributes from dynamic block to its first child (was: Bug: clocktable)
Date: Thu, 18 Jan 2024 15:26:35 +0000	[thread overview]
Message-ID: <871qaer7bo.fsf@localhost> (raw)
In-Reply-To: <000801d6959e$18d14e70$4a73eb50$@gnu.re>

[-- Attachment #1: Type: text/plain, Size: 1123 bytes --]

<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 )

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* |

Tentative patch is attached.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Allow-transfering-dblock-affiliated-keywords-to-its-.patch --]
[-- Type: text/x-patch, Size: 1221 bytes --]

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))))
 (defun org-map-dblocks (&optional command)

[-- Attachment #3: Type: text/plain, Size: 224 bytes --]

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	other threads:[~2024-01-18 16:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-28 13:48 Bug: clocktable matthias
2024-01-18 15:26 ` Ihor Radchenko [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=871qaer7bo.fsf@localhost \
    --to=yantar92@posteo.net \
    --cc=emacs-orgmode@gnu.org \
    --cc=matthias@gnu.re \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox


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).