emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Jarmo Hurri <jarmo.hurri@iki.fi>
To: emacs-orgmode@gnu.org
Subject: Re: Org src blocks and multiline macros
Date: Fri, 03 Aug 2018 09:16:41 +0300	[thread overview]
Message-ID: <87ftzw0yba.fsf@iki.fi> (raw)
In-Reply-To: 6B6655B0-6A17-4A8A-AA8F-BF830D54D3D9@ucsd.edu

"Berry, Charles" <ccberry@ucsd.edu> writes:

> ob-org does not provide for variables AFAICS. 

I have been trying to advocate for multiline macros for years, because
those are the _only_ thing I am really missing in org, again and
again. For example, right now I am writing teaching material where I
need to reuse certain parametrised org snippets across multiple files. I
_could_ use noweb. I _could_ use elisp code. But having a tool similar
to \newcommand in Latex would be so useful that every once in a while I
find myself bringing it up again.

The latest idea was to introduce variables into org blocks in hope it
would implement the desired functionality

> But using emacs-lisp with a :results drawer to render the output as
> org should help:
>
> #+header: :results drawer :exports results
> #+begin_src emacs-lisp :var val1="foo" :var val2="bar" 
>    (concat "Currently this gives me ~" val1 val2 "~ indeed!")
> #+END_SRC
>
> #+RESULTS:
> :results:
> Currently this gives me ~foobar~ indeed!
> :end:

Ok, this will work too. But my real document string contains multiple
paragraphs, org lists etc. In terms of readability and maintainability,
embedding that text as an argument in an elisp call is not a very clean
solution.

> BTW, if you really do need a long or multiline MACRO, there is the
> possibility of using an `eval' style macro with a custom elisp
> function. e.g.
>
> #+MACRO: longish-macro (eval (my-really-long-macro-def $1 $2 $3))
>
> (info "(org) Macro Replacement")
>
> But this carries the burden of having to defun
> `my-really-long-macro-def' before exporting your document.

Yes, this too will work, with similar reservations as in the previous
case.

Thanks for all the tips!

Jarmo

      reply	other threads:[~2018-08-03  6:16 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-02  6:33 Org src blocks and multiline macros Jarmo Hurri
2018-08-02 11:24 ` Kaushal Modi
2018-08-02 12:32   ` Jarmo Hurri
2018-08-02 16:50     ` Berry, Charles
2018-08-03  6:16       ` Jarmo Hurri [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=87ftzw0yba.fsf@iki.fi \
    --to=jarmo.hurri@iki.fi \
    --cc=emacs-orgmode@gnu.org \
    /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).