emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] New patches WAS Re: [PATCH] inline src block results can be remo


From: Aaron Ecay
Subject: Re: [O] New patches WAS Re: [PATCH] inline src block results can be removed
Date: Sun, 18 Jan 2015 14:13:01 -0500
User-agent: Notmuch/0.19+20~g2bbe5e0 (http://notmuchmail.org) Emacs/25.0.50.2 (x86_64-unknown-linux-gnu)

Hi Nicolas,

2015ko urtarrilak 17an, Nicolas Goaziou-ek idatzi zuen:
> It would be more flexible, but it would also defeat the whole point of
> the "results" macro, that is to be able to mark /unambiguously/ the
> output of an inline block. Indeed, even if you can get the name of the
> macro from the parameter, you cannot be sure the macro was generated by
> the code block, unlike to a results macro.

Well, you could examine the code block’s :wrap header arg to determine
what kind of macro it generates, rather than hardcoding “results.”
(This would break when :wrap’s value was changed, though).

Probably a better solution is that the results macro could wrap the
custom macro:

{{{results({{{mymacro(foo)}}})}}}

> 
> Also, I don't think we really need this flexibility since any twist to
> the output can be made at the Babel level, or even using
> `org-babel-inline-result-wrap'.

o-b-inline-result-wrap can’t be specified on a per-block basis like
header args can.  And doing it within babel would lead to extra
verbosity.  As an example use case, I sometimes write things like:

src_R{round(100*78/7065,2)}

What I’m really interested in is the value 100*78/7065,¹ but I don’t want
it spilling its many decimal places into the exported document (I don’t
particularly mind them in the org file).  I think the following would be a
better way of writing things like this, since it separates the presentation
(round to two decimal places) from the content (100*78/7065):

src_R[:wrap round2]{100*78/7065}

I would write a round2 macro to arrange the rounding.  (round2 and
round0/truncate would probably cover 90+% of my use of inline R
blocks).  For latex, this would use one of the packages like siunitx
or pgfplots which offer number formatting (including other fancy
options like scientific notation for large numbers).  For other
backends, I’d probably use an eval-type macro to do the rounding in
elisp.

¹ This is just a particularly simple example; often the value is not
just the result of some arithmetic, but rather a coefficient extracted
from a statistical model by a series of function calls etc.

Thanks,

-- 
Aaron Ecay



reply via email to

[Prev in Thread] Current Thread [Next in Thread]