From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jarmo Hurri Subject: Re: Org src blocks and multiline macros Date: Fri, 03 Aug 2018 09:16:41 +0300 Message-ID: <87ftzw0yba.fsf@iki.fi> References: <87effhb7lu.fsf@iki.fi> <871sbhaqyu.fsf@iki.fi> <6B6655B0-6A17-4A8A-AA8F-BF830D54D3D9@ucsd.edu> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:46149) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1flTOS-0000Uz-Rn for emacs-orgmode@gnu.org; Fri, 03 Aug 2018 02:16:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1flTON-0004Dm-Sd for emacs-orgmode@gnu.org; Fri, 03 Aug 2018 02:16:56 -0400 Received: from [195.159.176.226] (port=40297 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1flTON-0004BO-KQ for emacs-orgmode@gnu.org; Fri, 03 Aug 2018 02:16:51 -0400 Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1flTME-0000Fq-5m for emacs-orgmode@gnu.org; Fri, 03 Aug 2018 08:14:38 +0200 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" To: emacs-orgmode@gnu.org "Berry, Charles" 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