emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Fraga, Eric" <e.fraga@ucl.ac.uk>
To: wlharvey4 via Emacs-orgmode <emacs-orgmode@gnu.org>
Cc: "wlharvey4@mac.com" <wlharvey4@mac.com>
Subject: Re: Inject value of macro into code using a variable
Date: Wed, 16 Oct 2019 06:23:48 +0000	[thread overview]
Message-ID: <87y2xlus24.fsf@ucl.ac.uk> (raw)
In-Reply-To: C7438D69-71A9-4159-8690-4CE57ECD9F4B@mac.com

On Tuesday, 15 Oct 2019 at 09:37, wlharvey4 via Emacs-orgmode wrote:
> Is it possible to inject the value of a macro into code using a variable?

I use properties for this, as in:

#+begin_src org
  ,#+property: version 2.0.5
  ,#+header: :var version=(esf/get-parameter "benzenefeed")
  [...]
  ,#+begin_src somelanguage
  [... code that uses version ...]
  ,#+end_src
#+end_src

where
#+begin_src emacs-lisp
  (defun esf/get-parameter (p)
    (let ((value (org-entry-get (point) p 'inherit)))
      (message "parameter %s value obtained %s" p value)
      (if value
          (if (string-match-p "^[-+ ]*[[:digit:].]+$" value)
              (string-to-number value)
            value)
        (error "Property parameter \"%s\" not known." p))))
#+end_src 

-- 
Eric S Fraga via Emacs 27.0.50, Org release_9.2.6-552-g8c5a78

      parent reply	other threads:[~2019-10-16  6:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-15 16:37 Inject value of macro into code using a variable wlharvey4 via Emacs-orgmode
2019-10-15 19:42 ` Nicolas Goaziou
2019-10-16  6:23 ` Fraga, Eric [this message]

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=87y2xlus24.fsf@ucl.ac.uk \
    --to=e.fraga@ucl.ac.uk \
    --cc=emacs-orgmode@gnu.org \
    --cc=wlharvey4@mac.com \
    /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).