emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* source block evaluation in #+DATE line
@ 2022-05-10 11:50 Andreas Leha
  2022-05-10 20:11 ` Jeremie Juste
  2022-05-11 17:12 ` Timothy
  0 siblings, 2 replies; 8+ messages in thread
From: Andreas Leha @ 2022-05-10 11:50 UTC (permalink / raw)
  To: emacs-orgmode

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



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: source block evaluation in #+DATE line
  2022-05-10 11:50 source block evaluation in #+DATE line Andreas Leha
@ 2022-05-10 20:11 ` Jeremie Juste
  2022-05-10 20:26   ` Kaushal Modi
  2022-05-11 17:12 ` Timothy
  1 sibling, 1 reply; 8+ messages in thread
From: Jeremie Juste @ 2022-05-10 20:11 UTC (permalink / raw)
  To: Andreas Leha; +Cc: emacs-orgmode

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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: source block evaluation in #+DATE line
  2022-05-10 20:11 ` Jeremie Juste
@ 2022-05-10 20:26   ` Kaushal Modi
  2022-05-11  3:15     ` Andreas Leha
  0 siblings, 1 reply; 8+ messages in thread
From: Kaushal Modi @ 2022-05-10 20:26 UTC (permalink / raw)
  To: Jeremie Juste; +Cc: Andreas Leha, emacs-org list

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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: source block evaluation in #+DATE line
  2022-05-10 20:26   ` Kaushal Modi
@ 2022-05-11  3:15     ` Andreas Leha
  2022-05-11 16:50       ` Eric S Fraga
  0 siblings, 1 reply; 8+ messages in thread
From: Andreas Leha @ 2022-05-11  3:15 UTC (permalink / raw)
  To: emacs-orgmode

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



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: source block evaluation in #+DATE line
  2022-05-11  3:15     ` Andreas Leha
@ 2022-05-11 16:50       ` Eric S Fraga
  2022-05-11 17:07         ` Eric S Fraga
  0 siblings, 1 reply; 8+ messages in thread
From: Eric S Fraga @ 2022-05-11 16:50 UTC (permalink / raw)
  To: Andreas Leha; +Cc: emacs-orgmode

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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: source block evaluation in #+DATE line
  2022-05-11 16:50       ` Eric S Fraga
@ 2022-05-11 17:07         ` Eric S Fraga
  2022-05-12  7:53           ` Andreas Leha
  0 siblings, 1 reply; 8+ messages in thread
From: Eric S Fraga @ 2022-05-11 17:07 UTC (permalink / raw)
  To: Org Mode List

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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: source block evaluation in #+DATE line
  2022-05-10 11:50 source block evaluation in #+DATE line Andreas Leha
  2022-05-10 20:11 ` Jeremie Juste
@ 2022-05-11 17:12 ` Timothy
  1 sibling, 0 replies; 8+ messages in thread
From: Timothy @ 2022-05-11 17:12 UTC (permalink / raw)
  To: Andreas Leha; +Cc: emacs-orgmode

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: source block evaluation in #+DATE line
  2022-05-11 17:07         ` Eric S Fraga
@ 2022-05-12  7:53           ` Andreas Leha
  0 siblings, 0 replies; 8+ messages in thread
From: Andreas Leha @ 2022-05-12  7:53 UTC (permalink / raw)
  To: emacs-orgmode

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



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-05-12  7:54 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-05-10 11:50 source block evaluation in #+DATE line Andreas Leha
2022-05-10 20:11 ` Jeremie Juste
2022-05-10 20:26   ` Kaushal Modi
2022-05-11  3:15     ` Andreas Leha
2022-05-11 16:50       ` Eric S Fraga
2022-05-11 17:07         ` Eric S Fraga
2022-05-12  7:53           ` Andreas Leha
2022-05-11 17:12 ` Timothy

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