From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rasmus Subject: [patch] Formatting of {{{DATE}}} Date: Sun, 08 Feb 2015 22:16:05 +0100 Message-ID: <8761bc85pm.fsf@gmx.us> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:51219) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YKZDK-00084s-Ja for emacs-orgmode@gnu.org; Sun, 08 Feb 2015 16:16:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YKZDF-00069O-8Z for emacs-orgmode@gnu.org; Sun, 08 Feb 2015 16:16:22 -0500 Received: from plane.gmane.org ([80.91.229.3]:53367) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YKZDF-00069C-26 for emacs-orgmode@gnu.org; Sun, 08 Feb 2015 16:16:17 -0500 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1YKZDB-0003r9-SF for emacs-orgmode@gnu.org; Sun, 08 Feb 2015 22:16:13 +0100 Received: from 46.166.186.219 ([46.166.186.219]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 08 Feb 2015 22:16:13 +0100 Received: from rasmus by 46.166.186.219 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 08 Feb 2015 22:16:13 +0100 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Hi, I'd quite like to be able to pass a formatting argument to {{{date}}}, much like {{{time(FMT)}}}. This patch allows this. I think macros don't normally have optional arguments, but I find it OK here since it's time and modification-time works anyway... On the other hand there might be a good reason that I have overlooked for why this isn't already accepting a formatting argument. Any objections? —Rasmus -- Send from my Emacs --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0002-ox.el-Allow-date-formatting.patch >From f8de6c716e892e159f80d40d91737ff8ac983877 Mon Sep 17 00:00:00 2001 From: Rasmus Date: Sun, 8 Feb 2015 21:34:43 +0100 Subject: [PATCH 2/2] * ox.el: Allow {{{date}}} formatting * ox.el (org-export-as): Allow {{{date}}} to take formatting-argument. With optional argument, {{{date(FMT)}}} works like {{{time(FMT)}}} if \#+DATE is a timestamp. --- lisp/ox.el | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lisp/ox.el b/lisp/ox.el index ad3742c..baaab6b 100644 --- a/lisp/ox.el +++ b/lisp/ox.el @@ -2872,7 +2872,18 @@ Return code as a string." (list (cons "author" (org-element-interpret-data (plist-get info :author))) (cons "date" - (org-element-interpret-data (plist-get info :date))) + (let* ((date (plist-get info :date)) + (date-string (org-element-interpret-data date))) + ;; Interpret only single time-stamps. + (case (and (not (cdr date)) + (org-element-type (car date))) + (timestamp + (format + "(eval (if (org-element-property :args macro) + (org-export-get-date info \"$1\") + \"%s\"))" + date-string)) + (t date-string)))) ;; EMAIL is not a parsed keyword: store it as-is. (cons "email" (or (plist-get info :email) "")) (cons "title" -- 2.3.0 --=-=-=--