emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Can I wrap a Babel call inside a macro?
@ 2014-01-23 22:42 Sebastien Vauban
  2014-01-24  8:29 ` Nicolas Goaziou
  0 siblings, 1 reply; 6+ messages in thread
From: Sebastien Vauban @ 2014-01-23 22:42 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

Hello,

I did the following test, not fully successfull:

--8<---------------cut here---------------start------------->8---
#+name: current-time
#+begin_src sh
echo "$(date '+%Y%m%d.%H%M')"
#+end_src

#+results: current-time
: 20140123.2339

Date/time:
#+CALL: current-time()

#+results:
: 20140123.2339

#+MACRO: ct #+CALL: current-time()

The current date and time is:
{{{ct}}}.
--8<---------------cut here---------------end--------------->8---

as the HTML export gives:

--8<---------------cut here---------------start------------->8---
    <div id="outline-container-sec-1" class="outline-2">
      <h2 id="sec-1"><span class="section-number-2">1</span> Tests</h2>

      <div class="outline-text-2" id="text-1">
        <div class="org-src-container">
          <pre class="src src-sh" id="current-time">
<span style="color: #006FE0;">echo</span> <span style=
"color: #036A07;">"$(date '+%Y%m%d.%H%M')"</span>
</pre>
        </div>

        <p>Date/time:</p>
        <pre class="example">
20140123.2338
</pre>

        <p>The current date and time is: #+CALL: current-time().</p>
      </div>                             ^^^^^^^^^^^^^^^^^^^^^^
    </div>
--8<---------------cut here---------------end--------------->8---

As macros are expanded _before_ Babel calls are executed, I'd think this
is possible, but I must miss something...

Best regards,
  Seb

-- 
Sebastien Vauban

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Can I wrap a Babel call inside a macro?
  2014-01-23 22:42 Can I wrap a Babel call inside a macro? Sebastien Vauban
@ 2014-01-24  8:29 ` Nicolas Goaziou
  2014-01-24  8:47   ` Nicolas Goaziou
  0 siblings, 1 reply; 6+ messages in thread
From: Nicolas Goaziou @ 2014-01-24  8:29 UTC (permalink / raw)
  To: Sebastien Vauban; +Cc: public-emacs-orgmode-mXXj517/zsQ



Hello,

"Sebastien Vauban" <sva-news-D0wtAvR13HarG/iDocfnWg@public.gmane.org>
writes:

> I did the following test, not fully successfull:
>
> #+name: current-time
> #+begin_src sh
> echo "$(date '+%Y%m%d.%H%M')"
> #+end_src
>
> #+results: current-time
> : 20140123.2339
>
> Date/time:
> #+CALL: current-time()
>
> #+results:
> : 20140123.2339
>
> #+MACRO: ct #+CALL: current-time()
>
> The current date and time is:
> {{{ct}}}.
>
> as the HTML export gives:
>
>     <div id="outline-container-sec-1" class="outline-2">
>       <h2 id="sec-1"><span class="section-number-2">1</span> Tests</h2>
>
>       <div class="outline-text-2" id="text-1">
>         <div class="org-src-container">
>           <pre class="src src-sh" id="current-time">
> <span style="color: #006FE0;">echo</span> <span style=
> "color: #036A07;">"$(date '+%Y%m%d.%H%M')"</span>
> </pre>
>         </div>
>
>         <p>Date/time:</p>
>         <pre class="example">
> 20140123.2338
> </pre>
>
>         <p>The current date and time is: #+CALL: current-time().</p>
>       </div>                             ^^^^^^^^^^^^^^^^^^^^^^
>     </div>
>
> As macros are expanded _before_ Babel calls are executed, I'd think this
> is possible, but I must miss something...

FWIW, I couldn't reproduce your problem in either maint or master
branch.


Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Can I wrap a Babel call inside a macro?
  2014-01-24  8:29 ` Nicolas Goaziou
@ 2014-01-24  8:47   ` Nicolas Goaziou
  2014-01-24  9:04     ` Sebastien Vauban
  0 siblings, 1 reply; 6+ messages in thread
From: Nicolas Goaziou @ 2014-01-24  8:47 UTC (permalink / raw)
  To: Sebastien Vauban; +Cc: public-emacs-orgmode-mXXj517/zsQ



Nicolas Goaziou <n.goaziou@gmail.com> writes:

>> The current date and time is:
>> {{{ct}}}.

BTW, the period seems dubious here.

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Can I wrap a Babel call inside a macro?
  2014-01-24  8:47   ` Nicolas Goaziou
@ 2014-01-24  9:04     ` Sebastien Vauban
  2014-01-24  9:14       ` Nicolas Goaziou
  0 siblings, 1 reply; 6+ messages in thread
From: Sebastien Vauban @ 2014-01-24  9:04 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

Hello Nicolas,

Nicolas Goaziou wrote:
> Nicolas Goaziou <n.goaziou-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:
>
>>> The current date and time is:
>>> {{{ct}}}.
>
> BTW, the period seems dubious here.

What do you mean?  That, because the macro will ultimately make a Babel
call, it can't be inserted inline in some text, right?

I'd have to write:

>>> The current date and time is:
>>> {{{ct}}}
>>> .

Is this what you mean?

Best regards,
  Seb

PS- I'll have to look why it works for you and not for me...

-- 
Sebastien Vauban

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Can I wrap a Babel call inside a macro?
  2014-01-24  9:04     ` Sebastien Vauban
@ 2014-01-24  9:14       ` Nicolas Goaziou
  2014-01-24 10:51         ` Sebastien Vauban
  0 siblings, 1 reply; 6+ messages in thread
From: Nicolas Goaziou @ 2014-01-24  9:14 UTC (permalink / raw)
  To: Sebastien Vauban; +Cc: public-emacs-orgmode-mXXj517/zsQ



"Sebastien Vauban" <sva-news-D0wtAvR13HarG/iDocfnWg@public.gmane.org>
writes:

>> Nicolas Goaziou <n.goaziou-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:
>>
>>>> The current date and time is:
>>>> {{{ct}}}.
>>
>> BTW, the period seems dubious here.
>
> What do you mean?  That, because the macro will ultimately make a Babel
> call, it can't be inserted inline in some text, right?

Correct. After macro expansion, this will become:

  #+CALL: current-time().

which isn't valid Babel syntax, AFAIK.


Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Can I wrap a Babel call inside a macro?
  2014-01-24  9:14       ` Nicolas Goaziou
@ 2014-01-24 10:51         ` Sebastien Vauban
  0 siblings, 0 replies; 6+ messages in thread
From: Sebastien Vauban @ 2014-01-24 10:51 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

Hello Nicolas,

Nicolas Goaziou wrote:
> "Sebastien Vauban" writes:
>>> Nicolas Goaziou <n.goaziou-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:
>>>
>>>>> The current date and time is:
>>>>> {{{ct}}}.
>>>
>>> BTW, the period seems dubious here.
>>
>> What do you mean?  That, because the macro will ultimately make a Babel
>> call, it can't be inserted inline in some text, right?
>
> Correct. After macro expansion, this will become:
>
>   #+CALL: current-time().
>
> which isn't valid Babel syntax, AFAIK.

OK. New tests confirm that, definitively.

So, when you said it worked for you, it wasn't with the exact same ECM,
then. Case closed. Thanks!

Best regards,
  Seb

-- 
Sebastien Vauban

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-01-24 10:51 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-23 22:42 Can I wrap a Babel call inside a macro? Sebastien Vauban
2014-01-24  8:29 ` Nicolas Goaziou
2014-01-24  8:47   ` Nicolas Goaziou
2014-01-24  9:04     ` Sebastien Vauban
2014-01-24  9:14       ` Nicolas Goaziou
2014-01-24 10:51         ` Sebastien Vauban

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).