emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* What is the best way to set #+DATE to today's date?
@ 2015-08-06 16:33 Kaushal
  2015-08-06 16:44 ` Rasmus
  2015-08-06 18:12 ` Nick Dokos
  0 siblings, 2 replies; 22+ messages in thread
From: Kaushal @ 2015-08-06 16:33 UTC (permalink / raw)
  To: emacs-org list

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

Hi all,

There are quite few documents in which I want to update the date stamp to
the last update time.

I like that #+DATE keyword value is used aptly in latex/pdf and html
exports.

But I couldn't find an elegant way for that date to be updated to today's
(last updated) date.

I came up with the below. But please let me know if there's an inbuilt way
to do the same.


PART 1: Config in init.el

    ;; Update TODAY macro with current date
    (defun modi/org-update-TODAY-macro (&rest ignore)
      "Update TODAY macro to hold string with current date."
      (interactive)
      (when (derived-mode-p 'org-mode)
        (save-excursion
          (goto-char (point-min))
          (while (re-search-forward
                  "^\\s-*#\\+MACRO:\\s-+TODAY"
                  nil 'noerror)
            (forward-line 0)
            (when (looking-at ".*TODAY\\(.*\\)")
              (replace-match
               (concat " "
                       (format-time-string "%b %d %Y, %a" (current-time)))
               :fixedcase :literal nil 1))))))
    (add-hook 'org-export-before-processing-hook
#'modi/org-update-TODAY-macro)


PART 2: org document where I want the #+DATE to auto update

    #+MACRO: TODAY [current date is auto-inserted when exporting]
    #+DATE: {{{TODAY}}}


--
Kaushal Modi

[-- Attachment #2: Type: text/html, Size: 5138 bytes --]

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

* Re: What is the best way to set #+DATE to today's date?
  2015-08-06 16:33 What is the best way to set #+DATE to today's date? Kaushal
@ 2015-08-06 16:44 ` Rasmus
  2015-08-06 17:00   ` Kaushal
  2015-08-06 18:12 ` Nick Dokos
  1 sibling, 1 reply; 22+ messages in thread
From: Rasmus @ 2015-08-06 16:44 UTC (permalink / raw)
  To: emacs-orgmode

Kaushal <kaushal.modi@gmail.com> writes:

> Hi all,
>
> There are quite few documents in which I want to update the date stamp to
> the last update time.
>
> I like that #+DATE keyword value is used aptly in latex/pdf and html
> exports.
>
> But I couldn't find an elegant way for that date to be updated to today's
> (last updated) date.
>
> I came up with the below. But please let me know if there's an inbuilt way
> to do the same.
>
>
> PART 1: Config in init.el
>
>     ;; Update TODAY macro with current date
>     (defun modi/org-update-TODAY-macro (&rest ignore)
>       "Update TODAY macro to hold string with current date."
>       (interactive)
>       (when (derived-mode-p 'org-mode)
>         (save-excursion
>           (goto-char (point-min))
>           (while (re-search-forward
>                   "^\\s-*#\\+MACRO:\\s-+TODAY"
>                   nil 'noerror)
>             (forward-line 0)
>             (when (looking-at ".*TODAY\\(.*\\)")
>               (replace-match
>                (concat " "
>                        (format-time-string "%b %d %Y, %a" (current-time)))
>                :fixedcase :literal nil 1))))))
>     (add-hook 'org-export-before-processing-hook
> #'modi/org-update-TODAY-macro)
>
>
> PART 2: org document where I want the #+DATE to auto update
>
>     #+MACRO: TODAY [current date is auto-inserted when exporting]
>     #+DATE: {{{TODAY}}}

Why don't you just use a timestamp?

    #+date: <2015-08-06>

You can update whenever you want or using

    (org-insert-time-stamp (current-time))

at the right spot.

Rasmus

-- 
Sådan en god dansk lagereddike kan man slet ikke bruge mere

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

* Re: What is the best way to set #+DATE to today's date?
  2015-08-06 16:44 ` Rasmus
@ 2015-08-06 17:00   ` Kaushal
  2015-08-06 17:41     ` Rasmus
                       ` (2 more replies)
  0 siblings, 3 replies; 22+ messages in thread
From: Kaushal @ 2015-08-06 17:00 UTC (permalink / raw)
  To: Rasmus; +Cc: emacs-org list

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

> Why don't you just use a timestamp?

But that would need me to insert the timestamp manually each time before
exports

> You can update whenever you want or using
>    (org-insert-time-stamp (current-time))
> at the right spot.

Wouldn't that too need manual navigation to #+date: and then eval that
elisp form?


--
Kaushal Modi

On Thu, Aug 6, 2015 at 12:44 PM, Rasmus <rasmus@gmx.us> wrote:

> Kaushal <kaushal.modi@gmail.com> writes:
>
> > Hi all,
> >
> > There are quite few documents in which I want to update the date stamp to
> > the last update time.
> >
> > I like that #+DATE keyword value is used aptly in latex/pdf and html
> > exports.
> >
> > But I couldn't find an elegant way for that date to be updated to today's
> > (last updated) date.
> >
> > I came up with the below. But please let me know if there's an inbuilt
> way
> > to do the same.
> >
> >
> > PART 1: Config in init.el
> >
> >     ;; Update TODAY macro with current date
> >     (defun modi/org-update-TODAY-macro (&rest ignore)
> >       "Update TODAY macro to hold string with current date."
> >       (interactive)
> >       (when (derived-mode-p 'org-mode)
> >         (save-excursion
> >           (goto-char (point-min))
> >           (while (re-search-forward
> >                   "^\\s-*#\\+MACRO:\\s-+TODAY"
> >                   nil 'noerror)
> >             (forward-line 0)
> >             (when (looking-at ".*TODAY\\(.*\\)")
> >               (replace-match
> >                (concat " "
> >                        (format-time-string "%b %d %Y, %a"
> (current-time)))
> >                :fixedcase :literal nil 1))))))
> >     (add-hook 'org-export-before-processing-hook
> > #'modi/org-update-TODAY-macro)
> >
> >
> > PART 2: org document where I want the #+DATE to auto update
> >
> >     #+MACRO: TODAY [current date is auto-inserted when exporting]
> >     #+DATE: {{{TODAY}}}
>
> Why don't you just use a timestamp?
>
>     #+date: <2015-08-06>
>
> You can update whenever you want or using
>
>     (org-insert-time-stamp (current-time))
>
> at the right spot.
>
> Rasmus
>
> --
> Sådan en god dansk lagereddike kan man slet ikke bruge mere
>
>
>

[-- Attachment #2: Type: text/html, Size: 4481 bytes --]

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

* Re: What is the best way to set #+DATE to today's date?
  2015-08-06 17:00   ` Kaushal
@ 2015-08-06 17:41     ` Rasmus
  2015-08-06 18:18     ` John Kitchin
  2015-08-07  4:31     ` Suvayu Ali
  2 siblings, 0 replies; 22+ messages in thread
From: Rasmus @ 2015-08-06 17:41 UTC (permalink / raw)
  To: emacs-orgmode

Kaushal <kaushal.modi@gmail.com> writes:

>> Why don't you just use a timestamp?
>
> But that would need me to insert the timestamp manually each time before
> exports

If you *always* want the current date you don't need to set date.

>> You can update whenever you want or using
>>    (org-insert-time-stamp (current-time))
>> at the right spot.
>
> Wouldn't that too need manual navigation to #+date: and then eval that
> elisp form?

Sure, but that's easy to find (untested): 

    (defun rasmus/update-date ()
      "update #+date keyword"
      (org-with-wide-buffer
       (let ((case-fold-search t))
         (goto-char (point-min))
         (search-forward-regexp "^#+date: ?")
         (delete-region (point) (line-end-position))
         (org-insert-time-stamp (current-time)))))

My point was that I don't understand the need for your today macro...

Rasmus

-- 
History is what should never happen again

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

* Re: What is the best way to set #+DATE to today's date?
  2015-08-06 16:33 What is the best way to set #+DATE to today's date? Kaushal
  2015-08-06 16:44 ` Rasmus
@ 2015-08-06 18:12 ` Nick Dokos
  1 sibling, 0 replies; 22+ messages in thread
From: Nick Dokos @ 2015-08-06 18:12 UTC (permalink / raw)
  To: emacs-orgmode

Kaushal <kaushal.modi@gmail.com> writes:

> Hi all,
>
> There are quite few documents in which I want to update the date stamp to the last update time.
>
> I like that #+DATE keyword value is used aptly in latex/pdf and html exports.
>
> But I couldn't find an elegant way for that date to be updated to today's (last updated) date.
>
> I came up with the below. But please let me know if there's an inbuilt way to do the same.
>
> PART 1: Config in init.el
>
>     ;; Update TODAY macro with current date
>     (defun modi/org-update-TODAY-macro (&rest ignore)
>       "Update TODAY macro to hold string with current date."
>       (interactive)
>       (when (derived-mode-p 'org-mode)
>         (save-excursion
>           (goto-char (point-min))
>           (while (re-search-forward
>                   "^\\s-*#\\+MACRO:\\s-+TODAY"
>                   nil 'noerror)
>             (forward-line 0)
>             (when (looking-at ".*TODAY\\(.*\\)")
>               (replace-match
>                (concat " "
>                        (format-time-string "%b %d %Y, %a" (current-time)))
>                :fixedcase :literal nil 1))))))
>     (add-hook 'org-export-before-processing-hook #'modi/org-update-TODAY-macro)
>
> PART 2: org document where I want the #+DATE to auto update
>
>     #+MACRO: TODAY [current date is auto-inserted when exporting]
>     #+DATE: {{{TODAY}}}
>

There is a built-in-macro - try e.g.

#+DATE: {{{time(%Y-%m-%d)}}}

See

        (info "(org) Macro replacement")
-- 
Nick

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

* Re: What is the best way to set #+DATE to today's date?
  2015-08-06 17:00   ` Kaushal
  2015-08-06 17:41     ` Rasmus
@ 2015-08-06 18:18     ` John Kitchin
  2015-08-06 19:25       ` Kaushal
  2015-08-07  4:31     ` Suvayu Ali
  2 siblings, 1 reply; 22+ messages in thread
From: John Kitchin @ 2015-08-06 18:18 UTC (permalink / raw)
  To: Kaushal; +Cc: emacs-org list, Rasmus

I use a function like that here:
https://github.com/jkitchin/jmax/blob/master/techela/techela-grade.el#L182

and to set the filetag as you suggest you would call it like this:

#+BEGIN_SRC emacs-lisp
(gb-set-filetag "DATE" (format-time-string "%b %d %Y, %a" (current-time)))
#+END_SRC

You could put that in some hook function if you like.

Kaushal writes:

>> Why don't you just use a timestamp?
>
> But that would need me to insert the timestamp manually each time before
> exports
>
>> You can update whenever you want or using
>>    (org-insert-time-stamp (current-time))
>> at the right spot.
>
> Wouldn't that too need manual navigation to #+date: and then eval that
> elisp form?

--
Professor John Kitchin
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu

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

* Re: What is the best way to set #+DATE to today's date?
  2015-08-06 18:18     ` John Kitchin
@ 2015-08-06 19:25       ` Kaushal
  2015-08-06 19:45         ` Kaushal
  0 siblings, 1 reply; 22+ messages in thread
From: Kaushal @ 2015-08-06 19:25 UTC (permalink / raw)
  To: John Kitchin, ndokos; +Cc: emacs-org list, Rasmus

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

@Nick That works! Thank you!

I used the below instead (learned that I needed to escape that comma).

#+DATE: {{{time(%b %d %Y\, %a)}}}

I had read about {{{date}}} but assumed that {{{time}}} does the same thing
as {{{date}}} because they are put together with the same description. The
documentation actually doesn't tell what {{{time}}} does:
http://orgmode.org/manual/Macro-replacement.html


@John: Looks like I will not need any elisp hacks :)



--
Kaushal Modi

On Thu, Aug 6, 2015 at 2:18 PM, John Kitchin <jkitchin@andrew.cmu.edu>
wrote:

> I use a function like that here:
> https://github.com/jkitchin/jmax/blob/master/techela/techela-grade.el#L182
>
> and to set the filetag as you suggest you would call it like this:
>
> #+BEGIN_SRC emacs-lisp
> (gb-set-filetag "DATE" (format-time-string "%b %d %Y, %a" (current-time)))
> #+END_SRC
>
> You could put that in some hook function if you like.
>
> Kaushal writes:
>
> >> Why don't you just use a timestamp?
> >
> > But that would need me to insert the timestamp manually each time before
> > exports
> >
> >> You can update whenever you want or using
> >>    (org-insert-time-stamp (current-time))
> >> at the right spot.
> >
> > Wouldn't that too need manual navigation to #+date: and then eval that
> > elisp form?
>
> --
> Professor John Kitchin
> Doherty Hall A207F
> Department of Chemical Engineering
> Carnegie Mellon University
> Pittsburgh, PA 15213
> 412-268-7803
> @johnkitchin
> http://kitchingroup.cheme.cmu.edu
>

[-- Attachment #2: Type: text/html, Size: 3105 bytes --]

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

* Re: What is the best way to set #+DATE to today's date?
  2015-08-06 19:25       ` Kaushal
@ 2015-08-06 19:45         ` Kaushal
  2015-08-06 19:50           ` Thomas S. Dye
  0 siblings, 1 reply; 22+ messages in thread
From: Kaushal @ 2015-08-06 19:45 UTC (permalink / raw)
  To: John Kitchin, ndokos; +Cc: emacs-org list, Rasmus

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

Actually the documentation does say what {{{time}}} does; I just didn't
read it all this time.

{{{date}}}{{{date(FORMAT)}}}{{{time(FORMAT)}}}{{{modification-time(FORMAT
)}}}
"These macros refer to the #+DATE keyword, *the current date*, and the
modification time of the file being exported, respectively."

Apologies.

And thanks to everyone for giving their time to reply to this.


--
Kaushal Modi

On Thu, Aug 6, 2015 at 3:25 PM, Kaushal <kaushal.modi@gmail.com> wrote:

> @Nick That works! Thank you!
>
> I used the below instead (learned that I needed to escape that comma).
>
> #+DATE: {{{time(%b %d %Y\, %a)}}}
>
> I had read about {{{date}}} but assumed that {{{time}}} does the same
> thing as {{{date}}} because they are put together with the same
> description. The documentation actually doesn't tell what {{{time}}} does:
> http://orgmode.org/manual/Macro-replacement.html
>
>
> @John: Looks like I will not need any elisp hacks :)
>
>
>
> --
> Kaushal Modi
>
> On Thu, Aug 6, 2015 at 2:18 PM, John Kitchin <jkitchin@andrew.cmu.edu>
> wrote:
>
>> I use a function like that here:
>> https://github.com/jkitchin/jmax/blob/master/techela/techela-grade.el#L182
>>
>> and to set the filetag as you suggest you would call it like this:
>>
>> #+BEGIN_SRC emacs-lisp
>> (gb-set-filetag "DATE" (format-time-string "%b %d %Y, %a" (current-time)))
>> #+END_SRC
>>
>> You could put that in some hook function if you like.
>>
>> Kaushal writes:
>>
>> >> Why don't you just use a timestamp?
>> >
>> > But that would need me to insert the timestamp manually each time before
>> > exports
>> >
>> >> You can update whenever you want or using
>> >>    (org-insert-time-stamp (current-time))
>> >> at the right spot.
>> >
>> > Wouldn't that too need manual navigation to #+date: and then eval that
>> > elisp form?
>>
>> --
>> Professor John Kitchin
>> Doherty Hall A207F
>> Department of Chemical Engineering
>> Carnegie Mellon University
>> Pittsburgh, PA 15213
>> 412-268-7803
>> @johnkitchin
>> http://kitchingroup.cheme.cmu.edu
>>
>
>

[-- Attachment #2: Type: text/html, Size: 6183 bytes --]

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

* Re: What is the best way to set #+DATE to today's date?
  2015-08-06 19:45         ` Kaushal
@ 2015-08-06 19:50           ` Thomas S. Dye
  2015-08-06 19:58             ` Kaushal
  0 siblings, 1 reply; 22+ messages in thread
From: Thomas S. Dye @ 2015-08-06 19:50 UTC (permalink / raw)
  To: Kaushal; +Cc: ndokos, emacs-org list, Rasmus, John Kitchin


Kaushal <kaushal.modi@gmail.com> writes:

> Actually the documentation does say what {{{time}}} does; I just didn't
> read it all this time.
>
> {{{date}}}{{{date(FORMAT)}}}{{{time(FORMAT)}}}{{{modification-time(FORMAT
> )}}}
> "These macros refer to the #+DATE keyword, *the current date*, and the
> modification time of the file being exported, respectively."
>
> Apologies.

Does it?  I count four macros and three references.  It's not clear to
me how they map to one another.  How should I read this?

All the best,
Tom

-- 
Thomas S. Dye
http://www.tsdye.com

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

* Re: What is the best way to set #+DATE to today's date?
  2015-08-06 19:50           ` Thomas S. Dye
@ 2015-08-06 19:58             ` Kaushal
  2015-08-06 20:51               ` [PATCH] " Thomas S. Dye
  0 siblings, 1 reply; 22+ messages in thread
From: Kaushal @ 2015-08-06 19:58 UTC (permalink / raw)
  To: Thomas S. Dye; +Cc: ndokos, emacs-org list, Rasmus, John Kitchin

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

Yeah, the documentation definitely needs refining.

{{{date}}} / {{{date(FORMAT)}}} [FORMAT is optional] - Inserts the
#+DATE keyword value;
optionally formats as per FORMAT (Refer `format-time-string` function for
syntax.){{{time(FORMAT)}}} - Inserts the current time stamp as per the
FORMAT {{{modification-time(FORMAT)}}} - Inserts modification time of the
file being exported as per the FORMAT


--
Kaushal Modi

On Thu, Aug 6, 2015 at 3:50 PM, Thomas S. Dye <tsd@tsdye.com> wrote:

>
> Kaushal <kaushal.modi@gmail.com> writes:
>
> > Actually the documentation does say what {{{time}}} does; I just didn't
> > read it all this time.
> >
> > {{{date}}}{{{date(FORMAT)}}}{{{time(FORMAT)}}}{{{modification-time(FORMAT
> > )}}}
> > "These macros refer to the #+DATE keyword, *the current date*, and the
> > modification time of the file being exported, respectively."
> >
> > Apologies.
>
> Does it?  I count four macros and three references.  It's not clear to
> me how they map to one another.  How should I read this?
>
> All the best,
> Tom
>
> --
> Thomas S. Dye
> http://www.tsdye.com
>

[-- Attachment #2: Type: text/html, Size: 3093 bytes --]

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

* [PATCH] Re: What is the best way to set #+DATE to today's date?
  2015-08-06 19:58             ` Kaushal
@ 2015-08-06 20:51               ` Thomas S. Dye
  2015-08-06 21:22                 ` Kaushal
  0 siblings, 1 reply; 22+ messages in thread
From: Thomas S. Dye @ 2015-08-06 20:51 UTC (permalink / raw)
  To: Kaushal; +Cc: ndokos, emacs-org list, Rasmus, John Kitchin

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

OK, here is a patch that tries to do that.

All the best,
Tom

Kaushal <kaushal.modi@gmail.com> writes:

> Yeah, the documentation definitely needs refining.
>
> {{{date}}} / {{{date(FORMAT)}}} [FORMAT is optional] - Inserts the
> #+DATE keyword value;
> optionally formats as per FORMAT (Refer `format-time-string` function for
> syntax.){{{time(FORMAT)}}} - Inserts the current time stamp as per the
> FORMAT {{{modification-time(FORMAT)}}} - Inserts modification time of the
> file being exported as per the FORMAT


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Patch for org.texi --]
[-- Type: text/x-patch, Size: 1468 bytes --]

From cf8ba2d13a4b733e358b28fe2ad8d83f0018fca9 Mon Sep 17 00:00:00 2001
From: tsdye <tsd@tsdye.com>
Date: Thu, 6 Aug 2015 10:47:07 -1000
Subject: [PATCH] Edit date and time macros

---
 doc/org.texi | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/doc/org.texi b/doc/org.texi
index d420259..b5ababb 100644
--- a/doc/org.texi
+++ b/doc/org.texi
@@ -10217,15 +10217,17 @@ export.
 @item @{@{@{date@}@}@}
 @itemx @{@{@{date(@var{FORMAT})@}@}@}
 @itemx @{@{@{time(@var{FORMAT})@}@}@}
-@itemx @{@{@{modification-time(@var{FORMAT})@}@}@}
 @cindex date, macro
 @cindex time, macro
-@cindex modification time, macro
-These macros refer to the @code{#+DATE} keyword, the current date, and the
-modification time of the file being exported, respectively.  @var{FORMAT}
+These macros refer to information associated with the @code{#+DATE} keyword.
+The @var{FORMAT} argument, which is optional for the @{@{@{date@}@}@} macro,
 should be a format string understood by @code{format-time-string}.  Note that
-@var{FORMAT} is an optional argument to the @code{@{@{@{date@}@}@}} macro,
-and that it will only be used if @code{#+DATE} is a single timestamp.
+it will only be used if @code{#+DATE} is a single timestamp.
+
+@itemx @{@{@{modification-time(@var{FORMAT})@}@}@}
+@cindex modification time, macro
+
+This macro refers to the modification time of the file being exported.
 
 @item @{@{@{input-file@}@}@}
 @cindex input file, macro
-- 
2.4.5


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


-- 
Thomas S. Dye
http://www.tsdye.com

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

* Re: [PATCH] Re: What is the best way to set #+DATE to today's date?
  2015-08-06 20:51               ` [PATCH] " Thomas S. Dye
@ 2015-08-06 21:22                 ` Kaushal
  2015-08-06 21:48                   ` Thomas S. Dye
  0 siblings, 1 reply; 22+ messages in thread
From: Kaushal @ 2015-08-06 21:22 UTC (permalink / raw)
  To: Thomas S. Dye; +Cc: Nick Dokos, emacs-org list, Rasmus, John Kitchin

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

I think you missed out explaining what {{{time(FORMAT)}}} does.


--
Kaushal Modi

On Thu, Aug 6, 2015 at 4:51 PM, Thomas S. Dye <tsd@tsdye.com> wrote:

> OK, here is a patch that tries to do that.
>
> All the best,
> Tom
>
> Kaushal <kaushal.modi@gmail.com> writes:
>
> > Yeah, the documentation definitely needs refining.
> >
> > {{{date}}} / {{{date(FORMAT)}}} [FORMAT is optional] - Inserts the
> > #+DATE keyword value;
> > optionally formats as per FORMAT (Refer `format-time-string` function for
> > syntax.){{{time(FORMAT)}}} - Inserts the current time stamp as per the
> > FORMAT {{{modification-time(FORMAT)}}} - Inserts modification time of the
> > file being exported as per the FORMAT
>
>
>
> --
> Thomas S. Dye
> http://www.tsdye.com
>
>

[-- Attachment #2: Type: text/html, Size: 1513 bytes --]

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

* Re: [PATCH] Re: What is the best way to set #+DATE to today's date?
  2015-08-06 21:22                 ` Kaushal
@ 2015-08-06 21:48                   ` Thomas S. Dye
  2015-08-06 21:54                     ` Fabrice Niessen
  0 siblings, 1 reply; 22+ messages in thread
From: Thomas S. Dye @ 2015-08-06 21:48 UTC (permalink / raw)
  To: Kaushal; +Cc: Nick Dokos, emacs-org list, Rasmus, John Kitchin

Doesn't it get its information from a timestamp in #+DATE?

Kaushal <kaushal.modi@gmail.com> writes:

> I think you missed out explaining what {{{time(FORMAT)}}} does.

-- 
Thomas S. Dye
http://www.tsdye.com

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

* Re: [PATCH] Re: What is the best way to set #+DATE to today's date?
  2015-08-06 21:48                   ` Thomas S. Dye
@ 2015-08-06 21:54                     ` Fabrice Niessen
  2015-08-06 22:12                       ` Thomas S. Dye
  0 siblings, 1 reply; 22+ messages in thread
From: Fabrice Niessen @ 2015-08-06 21:54 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

> Doesn't it get its information from a timestamp in #+DATE?
>
>> I think you missed out explaining what {{{time(FORMAT)}}} does.

You might be interested by `date', `time' and `modification-time',
depending on what you want to achieve. I've put some examples in my
Org-macros project about those:

  https://github.com/fniessen/org-macros

Best regards,
Fabrice

-- 
Fabrice Niessen
Leuven, Belgium
http://www.pirilampo.org/

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

* Re: [PATCH] Re: What is the best way to set #+DATE to today's date?
  2015-08-06 21:54                     ` Fabrice Niessen
@ 2015-08-06 22:12                       ` Thomas S. Dye
  2015-08-07  8:53                         ` Nicolas Goaziou
  0 siblings, 1 reply; 22+ messages in thread
From: Thomas S. Dye @ 2015-08-06 22:12 UTC (permalink / raw)
  To: Fabrice Niessen; +Cc: emacs-orgmode

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

Thanks Fabrice, very helpful.

A second patch is attached.

All the best,
Tom

Fabrice Niessen <fni-news@pirilampo.org> writes:

>> Doesn't it get its information from a timestamp in #+DATE?
>>
>>> I think you missed out explaining what {{{time(FORMAT)}}} does.
>
> You might be interested by `date', `time' and `modification-time',
> depending on what you want to achieve. I've put some examples in my
> Org-macros project about those:
>
>   https://github.com/fniessen/org-macros
>
> Best regards,
> Fabrice


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Second patch --]
[-- Type: text/x-patch, Size: 1666 bytes --]

From cb30697627afacc8950ef85b839f47d48371f39b Mon Sep 17 00:00:00 2001
From: tsdye <tsd@tsdye.com>
Date: Thu, 6 Aug 2015 12:08:34 -1000
Subject: [PATCH 2/2] More date and time macro edits

---
 doc/org.texi | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/doc/org.texi b/doc/org.texi
index b5ababb..30c1987 100644
--- a/doc/org.texi
+++ b/doc/org.texi
@@ -10216,18 +10216,21 @@ export.
 
 @item @{@{@{date@}@}@}
 @itemx @{@{@{date(@var{FORMAT})@}@}@}
-@itemx @{@{@{time(@var{FORMAT})@}@}@}
 @cindex date, macro
-@cindex time, macro
-These macros refer to information associated with the @code{#+DATE} keyword.
-The @var{FORMAT} argument, which is optional for the @{@{@{date@}@}@} macro,
-should be a format string understood by @code{format-time-string}.  Note that
-it will only be used if @code{#+DATE} is a single timestamp.
+This macro refers to information associated with the @code{#+DATE} keyword.
+The optional @var{FORMAT} argument should be a format string understood by
+@code{format-time-string}.  Note that it will only be used if @code{#+DATE}
+is a single timestamp.
 
+@itemx @{@{@{time(@var{FORMAT})@}@}@}
 @itemx @{@{@{modification-time(@var{FORMAT})@}@}@}
 @cindex modification time, macro
+@cindex time, macro
 
-This macro refers to the modification time of the file being exported.
+These macros refer to the current date and time when the document is being
+exported and to the modification time of the file being exported,
+respectively.  The @var{FORMAT} argument should be a format string understood
+by @code{format-time-string}.
 
 @item @{@{@{input-file@}@}@}
 @cindex input file, macro
-- 
2.4.5


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


-- 
Thomas S. Dye
http://www.tsdye.com

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

* Re: What is the best way to set #+DATE to today's date?
  2015-08-06 17:00   ` Kaushal
  2015-08-06 17:41     ` Rasmus
  2015-08-06 18:18     ` John Kitchin
@ 2015-08-07  4:31     ` Suvayu Ali
  2 siblings, 0 replies; 22+ messages in thread
From: Suvayu Ali @ 2015-08-07  4:31 UTC (permalink / raw)
  To: emacs-orgmode

On Thu, Aug 06, 2015 at 01:00:31PM -0400, Kaushal wrote:
> > Why don't you just use a timestamp?
> 
> But that would need me to insert the timestamp manually each time before
> exports
> 
> > You can update whenever you want or using
> >    (org-insert-time-stamp (current-time))
> > at the right spot.
> 
> Wouldn't that too need manual navigation to #+date: and then eval that
> elisp form?

Why are you setting it if you want it to be today?  If no DATE field is
set, date is today, at least for LaTeX export.

-- 
Suvayu

Open source is the future. It sets us free.

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

* Re: [PATCH] Re: What is the best way to set #+DATE to today's date?
  2015-08-06 22:12                       ` Thomas S. Dye
@ 2015-08-07  8:53                         ` Nicolas Goaziou
  2015-08-07 14:01                           ` Kaushal
  2015-08-11 18:40                           ` Thomas S. Dye
  0 siblings, 2 replies; 22+ messages in thread
From: Nicolas Goaziou @ 2015-08-07  8:53 UTC (permalink / raw)
  To: Thomas S. Dye; +Cc: Fabrice Niessen, emacs-orgmode

Hello,

Thomas S. Dye <tsd@tsdye.com> writes:

> A second patch is attached.

Thank you.

> From cb30697627afacc8950ef85b839f47d48371f39b Mon Sep 17 00:00:00 2001
> From: tsdye <tsd@tsdye.com>
> Date: Thu, 6 Aug 2015 12:08:34 -1000
> Subject: [PATCH 2/2] More date and time macro edits

I think the commit message is confusing ("more"?). Also, I cannot apply
the patch on maint branch. Could you rebase it on top of that branch?

Regards,

-- 
Nicolas Goaziou

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

* Re: [PATCH] Re: What is the best way to set #+DATE to today's date?
  2015-08-07  8:53                         ` Nicolas Goaziou
@ 2015-08-07 14:01                           ` Kaushal
  2015-08-07 14:20                             ` Suvayu Ali
  2015-08-11 18:40                           ` Thomas S. Dye
  1 sibling, 1 reply; 22+ messages in thread
From: Kaushal @ 2015-08-07 14:01 UTC (permalink / raw)
  To: Thomas S. Dye, Fabrice Niessen, emacs-org list, fatkasuvayu+linux

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

@Fabrice Thanks for sharing your examples!

@Suvayu I tried removing #+DATE: line.. but with that I don't see the date
stamp in html exports. The advantage of {{{time(FORMAT)}}} is that I can
also control the formatting of the date-time stamp.


--
Kaushal Modi

On Fri, Aug 7, 2015 at 4:53 AM, Nicolas Goaziou <mail@nicolasgoaziou.fr>
wrote:

> Hello,
>
> Thomas S. Dye <tsd@tsdye.com> writes:
>
> > A second patch is attached.
>
> Thank you.
>
> > From cb30697627afacc8950ef85b839f47d48371f39b Mon Sep 17 00:00:00 2001
> > From: tsdye <tsd@tsdye.com>
> > Date: Thu, 6 Aug 2015 12:08:34 -1000
> > Subject: [PATCH 2/2] More date and time macro edits
>
> I think the commit message is confusing ("more"?). Also, I cannot apply
> the patch on maint branch. Could you rebase it on top of that branch?
>
> Regards,
>
> --
> Nicolas Goaziou
>
>

[-- Attachment #2: Type: text/html, Size: 1800 bytes --]

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

* Re: [PATCH] Re: What is the best way to set #+DATE to today's date?
  2015-08-07 14:01                           ` Kaushal
@ 2015-08-07 14:20                             ` Suvayu Ali
  2015-08-07 14:52                               ` Kaushal
  0 siblings, 1 reply; 22+ messages in thread
From: Suvayu Ali @ 2015-08-07 14:20 UTC (permalink / raw)
  To: emacs-org list

On Fri, Aug 07, 2015 at 10:01:42AM -0400, Kaushal wrote:
> @Fabrice Thanks for sharing your examples!
> 
> @Suvayu I tried removing #+DATE: line.. but with that I don't see the date
> stamp in html exports. The advantage of {{{time(FORMAT)}}} is that I can
> also control the formatting of the date-time stamp.

I just tested it, I get the following at the end of the exported html
document:

<div id="postamble" class="status">
<p class="author">Author: Suvayu Ali</p>
<p class="date">Created: 2015-08-07 Fri 16:14</p>
<p class="validation"><a href="http://validator.w3.org/check?uri=referer">Validate</a></p>

I don't know any html, were you expecting something else?  About the
format, take a look at org-time-stamp-custom-formats and
org-time-stamp-formats; eventhough they are for timestamps in the
document, maybe they honour the document creation timestamp.

-- 
Suvayu

Open source is the future. It sets us free.

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

* Re: [PATCH] Re: What is the best way to set #+DATE to today's date?
  2015-08-07 14:20                             ` Suvayu Ali
@ 2015-08-07 14:52                               ` Kaushal
  0 siblings, 0 replies; 22+ messages in thread
From: Kaushal @ 2015-08-07 14:52 UTC (permalink / raw)
  To: emacs-org list

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

Aha.. I am using a custom postamble for html:

            (setq org-html-postamble t) ; default value = 'auto
            (setq org-html-postamble-format
                  `(("en"
                     ,(concat "Exported using "
                              ;; "%c" is replaced with
`org-html-creator-string'
                              ;; Emacs <VERSION> (Org mode <VERSION>)
                              "<div style=\"display: inline\"
class=\"creator\">"
                              "%c</div> "
                              "by %e. — "
                              "<div style=\"display: inline\"
class=\"date\">"
                              "%d</div>"))))

So it looks like "%d" returns an empty string if #+DATE: is omitted
altogether; but if org-html-postamble is 'auto, today's date is entered if
#+DATE: is omitted.



--
Kaushal Modi

On Fri, Aug 7, 2015 at 10:20 AM, Suvayu Ali <fatkasuvayu+linux@gmail.com>
wrote:

> On Fri, Aug 07, 2015 at 10:01:42AM -0400, Kaushal wrote:
> > @Fabrice Thanks for sharing your examples!
> >
> > @Suvayu I tried removing #+DATE: line.. but with that I don't see the
> date
> > stamp in html exports. The advantage of {{{time(FORMAT)}}} is that I can
> > also control the formatting of the date-time stamp.
>
> I just tested it, I get the following at the end of the exported html
> document:
>
> <div id="postamble" class="status">
> <p class="author">Author: Suvayu Ali</p>
> <p class="date">Created: 2015-08-07 Fri 16:14</p>
> <p class="validation"><a href="http://validator.w3.org/check?uri=referer
> ">Validate</a></p>
>
> I don't know any html, were you expecting something else?  About the
> format, take a look at org-time-stamp-custom-formats and
> org-time-stamp-formats; eventhough they are for timestamps in the
> document, maybe they honour the document creation timestamp.
>
> --
> Suvayu
>
> Open source is the future. It sets us free.
>
>

[-- Attachment #2: Type: text/html, Size: 3697 bytes --]

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

* Re: [PATCH] Re: What is the best way to set #+DATE to today's date?
  2015-08-07  8:53                         ` Nicolas Goaziou
  2015-08-07 14:01                           ` Kaushal
@ 2015-08-11 18:40                           ` Thomas S. Dye
  2015-08-11 22:59                             ` Nicolas Goaziou
  1 sibling, 1 reply; 22+ messages in thread
From: Thomas S. Dye @ 2015-08-11 18:40 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: Fabrice Niessen, emacs-orgmode

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

Aloha Nicolas,

The attached patch is based on current maint branch.

Let me know if you have questions.

All the best,
Tom


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Patch for org.texi --]
[-- Type: text/x-patch, Size: 1621 bytes --]

From e5ab2427af7095db8c7f080dc8f9457021a10544 Mon Sep 17 00:00:00 2001
From: tsdye <tsd@tsdye.com>
Date: Tue, 11 Aug 2015 08:34:50 -1000
Subject: [PATCH] Edit date and time macros

---
 doc/org.texi | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/doc/org.texi b/doc/org.texi
index e9c7cf1..710f102 100644
--- a/doc/org.texi
+++ b/doc/org.texi
@@ -10216,16 +10216,20 @@ export.
 
 @item @{@{@{date@}@}@}
 @itemx @{@{@{date(@var{FORMAT})@}@}@}
+@cindex date, macro
+This macro refers to the @code{#+DATE} keyword. @var{FORMAT} is an optional
+argument to the @code{@{@{@{date@}@}@}} macro that will be used only if
+@code{#+DATE} is a single timestamp.  @var{FORMAT} should be a format string
+understood by @code{format-time-string}.
+
 @itemx @{@{@{time(@var{FORMAT})@}@}@}
 @itemx @{@{@{modification-time(@var{FORMAT})@}@}@}
-@cindex date, macro
 @cindex time, macro
 @cindex modification time, macro
-These macros refer to the @code{#+DATE} keyword, the current date, and the
-modification time of the file being exported, respectively.  @var{FORMAT}
-should be a format string understood by @code{format-time-string}.  Note that
-@var{FORMAT} is an optional argument to the @code{@{@{@{date@}@}@}} macro,
-and that it will only be used if @code{#+DATE} is a single timestamp.
+These macros refer to the date and time when the document is exported and to
+the modification date and time of the file being exported, respectively.
+@var{FORMAT} should be a format string understood by
+@code{format-time-string}.
 
 @item @{@{@{input-file@}@}@}
 @cindex input file, macro
-- 
2.5.0


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


Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:

> Hello,
>
> Thomas S. Dye <tsd@tsdye.com> writes:
>
>> A second patch is attached.
>
> Thank you.
>
>> From cb30697627afacc8950ef85b839f47d48371f39b Mon Sep 17 00:00:00 2001
>> From: tsdye <tsd@tsdye.com>
>> Date: Thu, 6 Aug 2015 12:08:34 -1000
>> Subject: [PATCH 2/2] More date and time macro edits
>
> I think the commit message is confusing ("more"?). Also, I cannot apply
> the patch on maint branch. Could you rebase it on top of that branch?
>
> Regards,

-- 
Thomas S. Dye
http://www.tsdye.com

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

* Re: [PATCH] Re: What is the best way to set #+DATE to today's date?
  2015-08-11 18:40                           ` Thomas S. Dye
@ 2015-08-11 22:59                             ` Nicolas Goaziou
  0 siblings, 0 replies; 22+ messages in thread
From: Nicolas Goaziou @ 2015-08-11 22:59 UTC (permalink / raw)
  To: Thomas S. Dye; +Cc: Fabrice Niessen, emacs-orgmode

Thomas S. Dye <tsd@tsdye.com> writes:

> Aloha Nicolas,
>
> The attached patch is based on current maint branch.

Applied. Thank you.

Regards,

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

end of thread, other threads:[~2015-08-11 22:57 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-06 16:33 What is the best way to set #+DATE to today's date? Kaushal
2015-08-06 16:44 ` Rasmus
2015-08-06 17:00   ` Kaushal
2015-08-06 17:41     ` Rasmus
2015-08-06 18:18     ` John Kitchin
2015-08-06 19:25       ` Kaushal
2015-08-06 19:45         ` Kaushal
2015-08-06 19:50           ` Thomas S. Dye
2015-08-06 19:58             ` Kaushal
2015-08-06 20:51               ` [PATCH] " Thomas S. Dye
2015-08-06 21:22                 ` Kaushal
2015-08-06 21:48                   ` Thomas S. Dye
2015-08-06 21:54                     ` Fabrice Niessen
2015-08-06 22:12                       ` Thomas S. Dye
2015-08-07  8:53                         ` Nicolas Goaziou
2015-08-07 14:01                           ` Kaushal
2015-08-07 14:20                             ` Suvayu Ali
2015-08-07 14:52                               ` Kaushal
2015-08-11 18:40                           ` Thomas S. Dye
2015-08-11 22:59                             ` Nicolas Goaziou
2015-08-07  4:31     ` Suvayu Ali
2015-08-06 18:12 ` Nick Dokos

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