emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nicolas Goaziou <mail@nicolasgoaziou.fr>
To: Rasmus <rasmus@gmx.us>
Cc: emacs-orgmode@gnu.org
Subject: Re: [patch] Formatting of {{{DATE}}}
Date: Mon, 09 Feb 2015 00:37:32 +0100	[thread overview]
Message-ID: <87mw4oq8jn.fsf@nicolasgoaziou.fr> (raw)
In-Reply-To: <8761bc85pm.fsf@gmx.us> (rasmus@gmx.us's message of "Sun, 08 Feb 2015 22:16:05 +0100")

Hello,

Rasmus <rasmus@gmx.us> 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

  reply	other threads:[~2015-02-08 23:36 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-08 21:16 [patch] Formatting of {{{DATE}}} Rasmus
2015-02-08 23:37 ` Nicolas Goaziou [this message]
2015-02-09  0:05   ` Nicolas Goaziou
2015-02-09  0:55     ` Rasmus
2015-02-09  8:28       ` Nicolas Goaziou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87mw4oq8jn.fsf@nicolasgoaziou.fr \
    --to=mail@nicolasgoaziou.fr \
    --cc=emacs-orgmode@gnu.org \
    --cc=rasmus@gmx.us \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).