Hi all, how can I have a source block result in a #+Date line? I am creating a beamer presentation. While the code works and the results get exported nicely at any other position, in the #+Date line only the code is exported. Here is the MWE: ------------------------- #+TITLE: MWE #+AUTHOR: Me #+EMAIL: me@all #+DATE: Only Code Exported: src_sh[:exports results :results output wrap replace]{date} #+LaTeX_CLASS: beamer #+OPTIONS: H:2 * Demonstration ** Inline Code Blocks Are Not Executed Everywhere - Here, the results are correctly exported: src_sh[:exports results :results output wrap replace]{date} - But in the =#+DATE:= line only the code is exported ------------------------- Thanks in advance! Best, Andreas - GNU Emacs 29.0.50 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.30, cairo version 1.16.0) of 2022-03-08 - Org mode version 9.5.3
Hello Andreas, On Tuesday, 10 May 2022 at 13:50, Andreas Leha wrote: > Hi all, > > how can I have a source block result in a #+Date line? > > I am creating a beamer presentation. While the code works and the > results get exported nicely at any other position, in the #+Date line > only the code is exported. > #+DATE: Only Code Exported: src_sh[:exports results :results > output wrap replace]{date} I'm not sure I undersand, why you would want to use the shell to specify a date. Could you please explain? Are you looking for a particular date format? The example below, taken from the org documentation produces the current date when exported to BEAMER. #+TITLE: Example Presentation #+AUTHOR: Carsten Dominik #+OPTIONS: H:2 toc:t num:t #+LATEX_CLASS: beamer #+LATEX_CLASS_OPTIONS: [presentation] #+BEAMER_THEME: Madrid #+COLUMNS: %45ITEM %10BEAMER_ENV(Env) %10BEAMER_ACT(Act) %4BEAMER_COL(Col) * This is the first structural section ** Frame 1 *** Thanks to Eric Fraga :B_block: :PROPERTIES: :BEAMER_COL: 0.48 :BEAMER_ENV: block :END: for the first viable Beamer setup in Org *** Thanks to everyone else :B_block: :PROPERTIES: :BEAMER_COL: 0.48 :BEAMER_ACT: <2-> :BEAMER_ENV: block :END: for contributing to the discussion **** This will be formatted as a beamer note :B_note: :PROPERTIES: :BEAMER_env: note :END: ** Frame 2 (where we will not use columns) *** Request Please test this stuff! HTH, Jeremie
Also check out the {{{time}}} macro if you want complete control on the formatting of the date string. Example Org snippet: ===== #+date: {{{time(%Y-%m-%d)}}} #+options: toc:nil author:nil See the ~{{{time}}}~ macro in [[info:org#Macro Replacement][org#Macro Replacement]]. The format passed to the ~time~ macro is same as that understood by [[help:format-time-string]]. - Note :: Remember to escape the commas. \\ Example: ~#+date: {{{time(%b %e %Y\, %a)}}}~. #+begin_src emacs-lisp (org-export-as 'ascii) #+end_src =====
Hi Kaushal and Jeremie,
Thanks for the comments. And sorry for the misleading example. I do not
want to use source blocks to insert a date. In fact I want to include
the current git commit hash on the title slide.
So, something like this:
src_sh[:exports results :results output wrap replace]{git describe --always --dirty}
But that is not evaluated...
Any hint?
Thanks,
Andreas
Kaushal Modi <kaushal.modi@gmail.com> writes:
> Also check out the {{{time}}} macro if you want complete control on
> the formatting of the date string.
>
> Example Org snippet:
>
> =====
>
> #+date: {{{time(%Y-%m-%d)}}}
> #+options: toc:nil author:nil
>
>
> See the ~{{{time}}}~ macro in [[info:org#Macro Replacement][org#Macro
> Replacement]].
>
> The format passed to the ~time~ macro is same as that understood by
> [[help:format-time-string]].
>
> - Note :: Remember to escape the commas. \\
> Example: ~#+date: {{{time(%b %e %Y\, %a)}}}~.
>
> #+begin_src emacs-lisp
> (org-export-as 'ascii)
> #+end_src
>
> =====
On Wednesday, 11 May 2022 at 05:15, Andreas Leha wrote:
> Thanks for the comments. And sorry for the misleading example. I do not
> want to use source blocks to insert a date. In fact I want to include
> the current git commit hash on the title slide.
I do this by:
--8<---------------cut here---------------start------------->8---
#+NAME: mydateline
#+BEGIN_SRC emacs-lisp
(format "#+DATE: \\copyright{} %s\n" *this*)
#+END_SRC
src_shell[:post mydateline() :results raw]{echo -n $(date +%Y) '@@latex:\\ \vspace*{0.1cm} \tiny \color{gray}@@' version $(git log --format=format:"%ad %h" --date=short | head -1 )}
--8<---------------cut here---------------end--------------->8---
HTH,
eric
--
: Eric S Fraga, with org release_9.5.3-481-gaea24b in Emacs 29.0.50
On Wednesday, 11 May 2022 at 17:50, Eric S Fraga wrote:
> ⚠️ Caution: External sender
>
>
> On Wednesday, 11 May 2022 at 05:15, Andreas Leha wrote:
>> Thanks for the comments. And sorry for the misleading example. I do not
>> want to use source blocks to insert a date. In fact I want to include
>> the current git commit hash on the title slide.
>
> I do this by:
[...] which I now realise uses a src block so probably not what you
want/need.
--
: Eric S Fraga, with org release_9.5.3-481-gaea24b in Emacs 29.0.50
[-- Attachment #1: Type: text/plain, Size: 341 bytes --] Hi Andreas, > how can I have a source block result in a #+Date line? Short version: you can’t as `#+date' is not a [parsed keyword]. Individual export backends do limited processing, and IIRC you should be able to use a macro. All the best, Timothy [parsed keyword] <https://orgmode.org/worg/dev/org-syntax.html#fnr.6>
Dear Eric,
Eric S Fraga <e.fraga@ucl.ac.uk> writes:
> On Wednesday, 11 May 2022 at 17:50, Eric S Fraga wrote:
>> ⚠️ Caution: External sender
>>
>>
>> On Wednesday, 11 May 2022 at 05:15, Andreas Leha wrote:
>>> Thanks for the comments. And sorry for the misleading example. I do not
>>> want to use source blocks to insert a date. In fact I want to include
>>> the current git commit hash on the title slide.
>>
>> I do this by:
>
> [...] which I now realise uses a src block so probably not what you
> want/need.
On the contrary. This is brilliant! I had not thought getting the full
#+DATE line to be generated via a code block. I've adopted your idea to
my needs and it works perfectly now.
Thanks a lot.
Best,
Andreas