emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Macros or properties in source blocks
@ 2015-08-11 16:34 Gary Oberbrunner
  2015-08-12  0:41 ` Charles C. Berry
  0 siblings, 1 reply; 4+ messages in thread
From: Gary Oberbrunner @ 2015-08-11 16:34 UTC (permalink / raw)
  To: Orgmode Mailing List

[-- Attachment #1: Type: text/plain, Size: 642 bytes --]

I'd like to have either a macro or a property that controls some behavior
of an org-mode babel file:

#+PROPERTY: report_type All

and use that property inline: {{{property(report_type)}}} and in a source
block:

#+NAME: rtype
#+BEGIN_SRC emacs-lisp :results value
{{{property(report_type)}}}
#+END_SRC

And use that source block:

The report type is call_rtype()[:results raw]

But this doesn't work, I get "Symbol's value as variable is void:
{{{property

Is there any way to interpolate macros or properties into a source block
like this? Or is there a better way for me to set org-mode "global
variables" at the top of my file?

-- 
Gary

[-- Attachment #2: Type: text/html, Size: 958 bytes --]

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

* Re: Macros or properties in source blocks
  2015-08-11 16:34 Macros or properties in source blocks Gary Oberbrunner
@ 2015-08-12  0:41 ` Charles C. Berry
  2015-08-12  7:20   ` Sebastien Vauban
  0 siblings, 1 reply; 4+ messages in thread
From: Charles C. Berry @ 2015-08-12  0:41 UTC (permalink / raw)
  To: Gary Oberbrunner; +Cc: Orgmode Mailing List

On Tue, 11 Aug 2015, Gary Oberbrunner wrote:

> I'd like to have either a macro or a property that controls some behavior
> of an org-mode babel file:
>
> #+PROPERTY: report_type All
>
> and use that property inline: {{{property(report_type)}}} and in a source
> block:
>
> #+NAME: rtype
> #+BEGIN_SRC emacs-lisp :results value
> {{{property(report_type)}}}
> #+END_SRC
>
> And use that source block:
>
> The report type is call_rtype()[:results raw]
>
> But this doesn't work,

[snip]

BUT THIS DOES:

--8<---------------cut here---------------start------------->8---

#+NAME: rtype
#+header: :var prop=(org-entry-get (point) "report_type" t)
#+BEGIN_SRC emacs-lisp
prop
#+END_SRC

And use that source block:

The report type is call_rtype()[:results raw]

--8<---------------cut here---------------end--------------->8---

HTH,

Chuck

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

* Re: Macros or properties in source blocks
  2015-08-12  0:41 ` Charles C. Berry
@ 2015-08-12  7:20   ` Sebastien Vauban
  2015-08-12 13:06     ` Nicolas Goaziou
  0 siblings, 1 reply; 4+ messages in thread
From: Sebastien Vauban @ 2015-08-12  7:20 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

"Charles C. Berry" <ccberry-XkckGZ689+c@public.gmane.org> writes:
> On Tue, 11 Aug 2015, Gary Oberbrunner wrote:
>
>> I'd like to have either a macro or a property that controls some behavior
>> of an org-mode babel file:
>>
>> #+PROPERTY: report_type All
>>
>> and use that property inline: {{{property(report_type)}}} and in a source
>> block:
>>
>> #+NAME: rtype
>> #+BEGIN_SRC emacs-lisp :results value
>> {{{property(report_type)}}}
>> #+END_SRC
>>
>> And use that source block:
>>
>> The report type is call_rtype()[:results raw]
>>
>> But this doesn't work,
>
> BUT THIS DOES:
>
> #+NAME: rtype
> #+header: :var prop=(org-entry-get (point) "report_type" t)
> #+BEGIN_SRC emacs-lisp
> prop
> #+END_SRC
>
> And use that source block:
>
> The report type is call_rtype()[:results raw]

Though, I don't understand either why your example did not work, as --
during the export process -- macros are supposed to be expanded before
Babel code be evaluated.

There must be some restriction, then, on which part of a document
a macro can reside in.

Best regards,
  Seb

-- 
Sebastien Vauban

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

* Re: Macros or properties in source blocks
  2015-08-12  7:20   ` Sebastien Vauban
@ 2015-08-12 13:06     ` Nicolas Goaziou
  0 siblings, 0 replies; 4+ messages in thread
From: Nicolas Goaziou @ 2015-08-12 13:06 UTC (permalink / raw)
  To: Sebastien Vauban; +Cc: public-emacs-orgmode-mXXj517/zsQ



Hello,

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

> Though, I don't understand either why your example did not work, as --
> during the export process -- macros are supposed to be expanded before
> Babel code be evaluated.
>
> There must be some restriction, then, on which part of a document
> a macro can reside in.

According to the manual

  These references, called macros, can be inserted anywhere Org markup is
  recognized: paragraphs, headlines, verse blocks, tables cells and lists.

The innards of a source block do not belong to Org.

Regards,

-- 
Nicolas Goaziou

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

end of thread, other threads:[~2015-08-12 13:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-11 16:34 Macros or properties in source blocks Gary Oberbrunner
2015-08-12  0:41 ` Charles C. Berry
2015-08-12  7:20   ` Sebastien Vauban
2015-08-12 13:06     ` Nicolas Goaziou

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