* :EXPORT_FILE_NAME: containing a date-stamp
@ 2018-02-07 15:31 Karl Voit
2018-02-07 16:41 ` Kaushal Modi
2018-02-07 17:05 ` Berry, Charles
0 siblings, 2 replies; 5+ messages in thread
From: Karl Voit @ 2018-02-07 15:31 UTC (permalink / raw)
To: emacs-orgmode
Hi,
Is there a possibility to define an export file name of a heading so
that the resulting file contains a date-stamp?
What I want to achieve:
*** My Report
:PROPERTIES:
:EXPORT_FILE_NAME: (format-time-string "%Y-%m-%d") Project Status.html
:END:
... which results in the file: "2018-02-07 Project Status.html"
No, this does not work this way at the moment (Orgmode from git
maint, d3f7309cb from 9 weeks ago).
--
get mail|git|SVN|photos|postings|SMS|phonecalls|RSS|CSV|XML into Org-mode:
> get Memacs from https://github.com/novoid/Memacs <
Personal Information Management > http://Karl-Voit.at/tags/pim/
Emacs-related > http://Karl-Voit.at/tags/emacs/
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: :EXPORT_FILE_NAME: containing a date-stamp
2018-02-07 15:31 :EXPORT_FILE_NAME: containing a date-stamp Karl Voit
@ 2018-02-07 16:41 ` Kaushal Modi
2018-02-07 17:05 ` Berry, Charles
1 sibling, 0 replies; 5+ messages in thread
From: Kaushal Modi @ 2018-02-07 16:41 UTC (permalink / raw)
To: Karl Voit; +Cc: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 1451 bytes --]
On Wed, Feb 7, 2018 at 10:33 AM Karl Voit <devnull@karl-voit.at> wrote:
> :EXPORT_FILE_NAME: (format-time-string "%Y-%m-%d") Project Status.html
>
Yes, you cannot do that (How would Org know that you do not want to name
your file literally like that? :)).
Also you do not need to (should not?) provide the file extension there..
the correct extension is added based on the exporter you use.
That said, I quickly tested this out, and it works:
(defun modi/org-advice-prefix-export-file-name-with-date (orig-fun &rest
args)
"Prefix the output file name with current date."
(let* ((date-format "%Y-%m-%d") ;Customize this variable as you like
(date-file-separator "-") ;Customize this variable as you like
(orig-output-file-name (apply orig-fun args))
(orig-output-dir (file-name-directory orig-output-file-name))
(orig-output-just-file-name (file-name-nondirectory
orig-output-file-name))
(date (format-time-string date-format (current-time))))
(concat orig-output-dir date date-file-separator
orig-output-just-file-name)))
(advice-add 'org-export-output-file-name :around
#'modi/org-advice-prefix-export-file-name-with-date)
;; (advice-remove 'org-export-output-file-name
#'modi/org-advice-prefix-export-file-name-with-date)
After evaluating the above, current date will be prefixed to the exported
file name, whether you export the whole file or just a subtree.
--
Kaushal Modi
[-- Attachment #2: Type: text/html, Size: 2023 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: :EXPORT_FILE_NAME: containing a date-stamp
2018-02-07 15:31 :EXPORT_FILE_NAME: containing a date-stamp Karl Voit
2018-02-07 16:41 ` Kaushal Modi
@ 2018-02-07 17:05 ` Berry, Charles
2018-02-07 17:37 ` Kaushal Modi
1 sibling, 1 reply; 5+ messages in thread
From: Berry, Charles @ 2018-02-07 17:05 UTC (permalink / raw)
To: Karl Voit; +Cc: emacs-orgmode@gnu.org
> On Feb 7, 2018, at 7:31 AM, Karl Voit <devnull@Karl-Voit.at> wrote:
>
> What I want to achieve:
>
> *** My Report
> :PROPERTIES:
> :EXPORT_FILE_NAME: (format-time-string "%Y-%m-%d") Project Status.html
> :END:
>
> ... which results in the file: "2018-02-07 Project Status.html"
Use an `eval' macro.
In a more recent version than you use, this works:
* abc
:PROPERTIES:
:EXPORT_TITLE: {{{etitle(my title)}}}
:END:
#+macro: etitle (eval (concat (format-time-string "%Y-%m-%d") " " $1))
...
You might need to quote the `$1'. The quoting convention was changed recently.
HTH,
Chuck
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: :EXPORT_FILE_NAME: containing a date-stamp
2018-02-07 17:05 ` Berry, Charles
@ 2018-02-07 17:37 ` Kaushal Modi
2018-02-07 18:06 ` Berry, Charles
0 siblings, 1 reply; 5+ messages in thread
From: Kaushal Modi @ 2018-02-07 17:37 UTC (permalink / raw)
To: Berry, Charles; +Cc: Karl Voit, emacs-orgmode@gnu.org
[-- Attachment #1: Type: text/plain, Size: 527 bytes --]
On Wed, Feb 7, 2018 at 12:22 PM Berry, Charles <ccberry@ucsd.edu> wrote:
> Use an `eval' macro.
>
> In a more recent version than you use, this works:
>
> * abc
> :PROPERTIES:
> :EXPORT_TITLE: {{{etitle(my title)}}}
> :END:
>
> #+macro: etitle (eval (concat (format-time-string "%Y-%m-%d") " " $1))
>
That works for EXPORT_TITLE!
So I tried for EXPORT_FILE_NAME, but it doesn't work there, because
org-export-output-file-name should be getting called internally *before*
the macro expansion is done.
--
Kaushal Modi
[-- Attachment #2: Type: text/html, Size: 958 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: :EXPORT_FILE_NAME: containing a date-stamp
2018-02-07 17:37 ` Kaushal Modi
@ 2018-02-07 18:06 ` Berry, Charles
0 siblings, 0 replies; 5+ messages in thread
From: Berry, Charles @ 2018-02-07 18:06 UTC (permalink / raw)
To: Kaushal Modi; +Cc: Karl Voit, emacs-orgmode@gnu.org
> On Feb 7, 2018, at 9:37 AM, Kaushal Modi <kaushal.modi@gmail.com> wrote:
>
> On Wed, Feb 7, 2018 at 12:22 PM Berry, Charles <ccberry@ucsd.edu> wrote:
> Use an `eval' macro.
>
> In a more recent version than you use, this works:
>
> * abc
> :PROPERTIES:
> :EXPORT_TITLE: {{{etitle(my title)}}}
> :END:
>
> #+macro: etitle (eval (concat (format-time-string "%Y-%m-%d") " " $1))
>
> That works for EXPORT_TITLE!
>
> So I tried for EXPORT_FILE_NAME, but it doesn't work there, because org-export-output-file-name should be getting called internally *before* the macro expansion is done.
I missed that.
Further, `org-export-file-name' gets called before `org-export-as' so there is no hope of using export hooks or filters or other gambits like that.
I don't see a clean way to do date stamp the file name without writing your own export-to-file function that handles date-stamping the file arg sent to `org-export-to-file' or replacing/advicing `org-export-file-name' to do that.
Chuck
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-02-07 18:06 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-07 15:31 :EXPORT_FILE_NAME: containing a date-stamp Karl Voit
2018-02-07 16:41 ` Kaushal Modi
2018-02-07 17:05 ` Berry, Charles
2018-02-07 17:37 ` Kaushal Modi
2018-02-07 18:06 ` Berry, Charles
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).