emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* using header data in document
@ 2020-09-15 21:03 Emanuel Berg via General discussions about Org-mode.
  2020-09-15 21:41 ` Corwin Brust
  0 siblings, 1 reply; 10+ messages in thread
From: Emanuel Berg via General discussions about Org-mode. @ 2020-09-15 21:03 UTC (permalink / raw)
  To: emacs-orgmode

How can I use header data in the document?

E.g.,

#+AUTHOR: Emanuel Berg

[...]

\author I wrote this! # only that doesn't work

-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal



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

* Re: using header data in document
  2020-09-15 21:03 using header data in document Emanuel Berg via General discussions about Org-mode.
@ 2020-09-15 21:41 ` Corwin Brust
  2020-09-15 22:08   ` Emanuel Berg via General discussions about Org-mode.
  0 siblings, 1 reply; 10+ messages in thread
From: Corwin Brust @ 2020-09-15 21:41 UTC (permalink / raw)
  To: Emanuel Berg, emacs-orgmode

Greetings!

On Tue, Sep 15, 2020 at 4:05 PM Emanuel Berg via General discussions
about Org-mode. <emacs-orgmode@gnu.org> wrote:
>
> How can I use header data in the document?

MACRO seems to be the current means to expose these.

  https://orgmode.org/manual/Macro-Replacement.html

 | Org comes with following pre-defined macros:
 |
 |  ‘{{{keyword(NAME)}}}’
 | ‘{{{title}}}’
 | ‘{{{author}}}’
 | ‘{{{email}}}’

So you can use use, e.g. {{{author}}} in various places to get at data
from the header:

 | Org recognizes macro references in following Org markup areas:
 | paragraphs, headlines, verse blocks, tables cells and lists.
 | Org also recognizes macro references in keywords, such as
 | ‘CAPTION’, ‘TITLE’, ‘AUTHOR’, ‘DATE’, and for some back-end
 | specific export options.

Regards,
Corwin

> underground experts united
> http://user.it.uu.se/~embe8573
> https://dataswamp.org/~incal


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

* Re: using header data in document
  2020-09-15 21:41 ` Corwin Brust
@ 2020-09-15 22:08   ` Emanuel Berg via General discussions about Org-mode.
  2020-09-16 14:35     ` Eric S Fraga
  0 siblings, 1 reply; 10+ messages in thread
From: Emanuel Berg via General discussions about Org-mode. @ 2020-09-15 22:08 UTC (permalink / raw)
  To: emacs-orgmode

Corwin Brust wrote:

>  | Org comes with following pre-defined macros:
>  |
>  | ‘{{{keyword(NAME)}}}’
>  | ‘{{{title}}}’
>  | ‘{{{author}}}’
>  | ‘{{{email}}}’

Thanks, great!

> So you can use use, e.g. {{{author}}} in various
> places to get at data from the header:
>
>  | Org recognizes macro references in following Org markup areas:
>  | paragraphs, headlines, verse blocks, tables cells and lists.
>  | Org also recognizes macro references in keywords, such as
>  | ‘CAPTION’, ‘TITLE’, ‘AUTHOR’, ‘DATE’, and for some back-end
>  | specific export options.

Hm, date? Maybe that can be used to do a line like
the LaTeX's

  Last modified: \today

or how would one do that?

-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal



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

* Re: using header data in document
  2020-09-15 22:08   ` Emanuel Berg via General discussions about Org-mode.
@ 2020-09-16 14:35     ` Eric S Fraga
  2020-09-16 15:18       ` Emanuel Berg via General discussions about Org-mode.
  0 siblings, 1 reply; 10+ messages in thread
From: Eric S Fraga @ 2020-09-16 14:35 UTC (permalink / raw)
  To: emacs-orgmode

On Wednesday, 16 Sep 2020 at 00:08, Emanuel Berg via "General discussions about Org-mode." wrote:
> Hm, date? Maybe that can be used to do a line like
> the LaTeX's
>
>   Last modified: \today
>
> or how would one do that?

Check out the info manual: [[info:org#Macro Replacement]] 
but you should be able to use {{{date(%D)}}} to get the date.

-- 
: Eric S Fraga via Emacs 28.0.50, Org release_9.3.7-725-g7bc18e


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

* Re: using header data in document
  2020-09-16 14:35     ` Eric S Fraga
@ 2020-09-16 15:18       ` Emanuel Berg via General discussions about Org-mode.
  2020-09-16 15:34         ` Eric S Fraga
  0 siblings, 1 reply; 10+ messages in thread
From: Emanuel Berg via General discussions about Org-mode. @ 2020-09-16 15:18 UTC (permalink / raw)
  To: emacs-orgmode

Eric S Fraga wrote:

> On Wednesday, 16 Sep 2020 at 00:08, Emanuel Berg via
> "General discussions about Org-mode." wrote:
>
>> Hm, date? Maybe that can be used to do a line like
>> the LaTeX's
>>
>>   Last modified: \today
>>
>> or how would one do that?
>
> Check out the info manual: [[info:org#Macro
> Replacement]] but you should be able to use
> {{{date(%D)}}} to get the date.

{{{date()}}} works as does {{{date(%D)}}} in a sense,
only the format string doesn't seem to influence the
output, which is "September 16, 2020".

(info "(org) Macro replacement")

  ‘{{{date}}}’
  ‘{{{date(FORMAT)}}}’
       This macro refers to the ‘#+DATE’ keyword.  FORMAT is an optional
       argument to the ‘{{{date}}}’ macro that will be used only if
       ‘#+DATE’ is a single timestamp.  FORMAT should be a format string
       understood by ‘format-time-string’.

(describe-function #'format-time-string)

  [...]
  %D is like "%m/%d/%y".
  [...]

So it should work according to these parts of the
documentation...

-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal



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

* Re: using header data in document
  2020-09-16 15:18       ` Emanuel Berg via General discussions about Org-mode.
@ 2020-09-16 15:34         ` Eric S Fraga
  2020-09-16 15:56           ` Emanuel Berg via General discussions about Org-mode.
  0 siblings, 1 reply; 10+ messages in thread
From: Eric S Fraga @ 2020-09-16 15:34 UTC (permalink / raw)
  To: emacs-orgmode

On Wednesday, 16 Sep 2020 at 17:18, Emanuel Berg via "General discussions about Org-mode." wrote:
> {{{date()}}} works as does {{{date(%D)}}} in a sense,
> only the format string doesn't seem to influence the
> output, which is "September 16, 2020".

The documentation that you have in your post says that this works only
if the actual date given in the #+DATE directive is a single
timestamp.  So, what did you specify there?  If you give a time stamp,
like [2020-09-16 Wed], it works fine for me.  If you have something
else, e.g. September 16, 2020, the format string is ignored.

In any case, you may wish to use the {{{time(FORMAT)}}} macro instead as
this does not depend on the date you have specified explicitly. And, in
practice, I actually use {{{modification-time(FORMAT)}}}.  In both of
these cases, you need to specify the format.

-- 
: Eric S Fraga via Emacs 28.0.50, Org release_9.3.7-725-g7bc18e


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

* Re: using header data in document
  2020-09-16 15:34         ` Eric S Fraga
@ 2020-09-16 15:56           ` Emanuel Berg via General discussions about Org-mode.
  2020-09-16 16:02             ` Eric S Fraga
  0 siblings, 1 reply; 10+ messages in thread
From: Emanuel Berg via General discussions about Org-mode. @ 2020-09-16 15:56 UTC (permalink / raw)
  To: emacs-orgmode

Eric S Fraga wrote:

>> {{{date()}}} works as does {{{date(%D)}}} in
>> a sense, only the format string doesn't seem to
>> influence the output, which is "September 16,
>> 2020".
>
> The documentation that you have in your post says
> that this works only if the actual date given in
> the #+DATE directive is a single timestamp. So,
> what did you specify there?

I tried

  {{{date()}}}
  {{{date(%D)}}}
  {{{date(%F)}}}

all produced "September 16, 2020".

> And, in practice, I actually use
> {{{modification-time(FORMAT)}}}. In both of these
> cases, you need to specify the format.

Yes, {{{modification-time(%F)}}} works!

Thanks!

-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal



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

* Re: using header data in document
  2020-09-16 15:56           ` Emanuel Berg via General discussions about Org-mode.
@ 2020-09-16 16:02             ` Eric S Fraga
  2020-09-16 17:14               ` Emanuel Berg via General discussions about Org-mode.
  0 siblings, 1 reply; 10+ messages in thread
From: Eric S Fraga @ 2020-09-16 16:02 UTC (permalink / raw)
  To: emacs-orgmode

On Wednesday, 16 Sep 2020 at 17:56, Emanuel Berg via "General discussions about Org-mode." wrote:
> Eric S Fraga wrote:
>> The documentation that you have in your post says
>> that this works only if the actual date given in
>> the #+DATE directive is a single timestamp. So,
>> what did you specify there?
>
> I tried
>
>   {{{date()}}}
>   {{{date(%D)}}}
>   {{{date(%F)}}}
>
> all produced "September 16, 2020".

What I meant was: what does your #+date: line look like?  Is it a single
time stamp?  If it is not, all of the above would return the same thing.

> Yes, {{{modification-time(%F)}}} works!

Great.

-- 
: Eric S Fraga via Emacs 28.0.50, Org release_9.3.7-725-g7bc18e


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

* Re: using header data in document
  2020-09-16 16:02             ` Eric S Fraga
@ 2020-09-16 17:14               ` Emanuel Berg via General discussions about Org-mode.
  2020-09-17 12:29                 ` Eric S Fraga
  0 siblings, 1 reply; 10+ messages in thread
From: Emanuel Berg via General discussions about Org-mode. @ 2020-09-16 17:14 UTC (permalink / raw)
  To: emacs-orgmode

Eric S Fraga wrote:

> what does your #+date: line look like? Is it
> a single time stamp? If it is not, all of the above
> would return the same thing.

I don't have that line.

-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal



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

* Re: using header data in document
  2020-09-16 17:14               ` Emanuel Berg via General discussions about Org-mode.
@ 2020-09-17 12:29                 ` Eric S Fraga
  0 siblings, 0 replies; 10+ messages in thread
From: Eric S Fraga @ 2020-09-17 12:29 UTC (permalink / raw)
  To: emacs-orgmode

On Wednesday, 16 Sep 2020 at 19:14, Emanuel Berg via "General discussions about Org-mode." wrote:
> Eric S Fraga wrote:
>
>> what does your #+date: line look like? Is it
>> a single time stamp? If it is not, all of the above
>> would return the same thing.
>
> I don't have that line.

So there is no timestamp and the {{{date}}} macro cannot do anything
with no information.  

-- 
: Eric S Fraga via Emacs 28.0.50, Org release_9.3.7-725-g7bc18e


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

end of thread, other threads:[~2020-09-17 12:36 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-09-15 21:03 using header data in document Emanuel Berg via General discussions about Org-mode.
2020-09-15 21:41 ` Corwin Brust
2020-09-15 22:08   ` Emanuel Berg via General discussions about Org-mode.
2020-09-16 14:35     ` Eric S Fraga
2020-09-16 15:18       ` Emanuel Berg via General discussions about Org-mode.
2020-09-16 15:34         ` Eric S Fraga
2020-09-16 15:56           ` Emanuel Berg via General discussions about Org-mode.
2020-09-16 16:02             ` Eric S Fraga
2020-09-16 17:14               ` Emanuel Berg via General discussions about Org-mode.
2020-09-17 12:29                 ` Eric S Fraga

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