From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Abrahamsen Subject: Re: nested macro expansion? Date: Wed, 19 Aug 2015 23:03:36 +0800 Message-ID: <871tez1fsn.fsf@ericabrahamsen.net> References: <87io8bo6uv.fsf@ericabrahamsen.net> <87egizo6mc.fsf@ericabrahamsen.net> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:34664) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZS4u5-0007tE-Ed for emacs-orgmode@gnu.org; Wed, 19 Aug 2015 11:03:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZS4u1-0007Dl-EZ for emacs-orgmode@gnu.org; Wed, 19 Aug 2015 11:03:49 -0400 Received: from mail-io0-f172.google.com ([209.85.223.172]:35486) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZS4u1-0007Bm-An for emacs-orgmode@gnu.org; Wed, 19 Aug 2015 11:03:45 -0400 Received: by iodt126 with SMTP id t126so12104254iod.2 for ; Wed, 19 Aug 2015 08:03:43 -0700 (PDT) In-Reply-To: (Pip Cet's message of "Wed, 19 Aug 2015 14:43:41 +0000") 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: Pip Cet Cc: emacs-orgmode@gnu.org On 08/19/15 14:43 PM, Pip Cet wrote: > Hi Eric, > I know this doesn't answer your actual question about nested macro > expansion, but writing some elisp might help you get the TIMESTAMP > property, at least: both > > #+MACRO: bubba (eval (org-entry-get nil "TIMESTAMP")) > > and > > #+MACRO: bubba (eval (org-macro-expand "{{{property(TIMESTAMP)}}}" > org-macro-templates)) > > appear to produce the current timestamp, and both can be fed to > another function, but not `format-time-string': the result of > (org-entry-get...) is a string of the form "<2014-08-19>", which would > need to be passed to `org-parse-time-string' first. Hey, that does the trick, thank you! I guess I should have thought of that. Sure, the example as I gave it would have errored had it done anything, but the main thing was just getting the right values in the right place. Off to write the function... Thanks again, Eric > On 8/19/15, Eric Abrahamsen wrote: >> Eric Abrahamsen writes: >> >>> What I'm trying to do is have a macro that takes the computed TIMESTAMP >>> property for an entry, and then runs it through a custom function that >>> breaks out the start/end times, and produces a nicely formatted string >>> from that. >>> >>> I don't see how to write a macro that feeds the value of a computed >>> special property to a function. >>> >>> Right now my testing version looks like this: >>> >>> #+MACRO: bubba (eval (format-time-string "%Y" "$1")) >>> >>> and I'm calling it like this: >>> >>> {{{bubba({{{property(TIMESTAMP)}}})}}} >>> >>> That doesn't expand the interior "{{{property(TIMESTAMP)}}}" clause. >>> What `format-time-string' ends up seeing is "{{{property(TIMESTAMP", >>> without the final braces etc. >>> >>> Is there any way to get that value expanded first, and then passed to >>> `format-time-string' (or, eventually, my custom function)? >> >> After googling for a while, I also thought this might work: >> >> #+MACRO: bubba (eval (format-time-string "%Y" property{{{TIMESTAMP}}})) >> >> {{{bubba}}} >> >> But the nested definition isn't expanded, either with or without quotes. >> >> E >> >> >>