From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: [patch] Formatting of {{{DATE}}} Date: Mon, 09 Feb 2015 00:37:32 +0100 Message-ID: <87mw4oq8jn.fsf@nicolasgoaziou.fr> References: <8761bc85pm.fsf@gmx.us> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:39524) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YKbOw-0002nV-0y for emacs-orgmode@gnu.org; Sun, 08 Feb 2015 18:36:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YKbOs-0005Xc-Qu for emacs-orgmode@gnu.org; Sun, 08 Feb 2015 18:36:29 -0500 Received: from relay6-d.mail.gandi.net ([2001:4b98:c:538::198]:43414) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YKbOs-0005XQ-Kn for emacs-orgmode@gnu.org; Sun, 08 Feb 2015 18:36:26 -0500 In-Reply-To: <8761bc85pm.fsf@gmx.us> (rasmus@gmx.us's message of "Sun, 08 Feb 2015 22:16:05 +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: Rasmus Cc: emacs-orgmode@gnu.org Hello, Rasmus writes: > 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? I have no objection, but please document it in the manual and add appropriate tests. > (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)))) I suggest (cons "date" (format "(eval (if (org-string-nw-p \"$1\") %s %S))" "(org-export-get-date info \"$1\")" (or (org-element-interpret-data (plist-get info :date)) ""))) instead. Regards, -- Nicolas Goaziou