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: Nicolas Goaziou
Subject: Re: [O] New patches WAS Re: [PATCH] inline src block results can be removed
Date: Sun, 18 Jan 2015 23:34:11 +0100

Aaron Ecay <address@hidden> writes:

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

As I said above, even if you read :wrap parameter, this is ambiguous,
since the use can insert any "foo" macro after a ":wrap foo":

  src_emacs-lisp[:wrap foo]{(+ 1 1)} {{{foo(this is something else)}}}

> Probably a better solution is that the results macro could wrap the
> custom macro:
>
> {{{results({{{mymacro(foo)}}})}}}

You cannot nest macros.

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

No matter how appealing this feature sounds to you, it would be flawed
and is not strictly necessary. You probably can use some Babel code
instead.

Note that your hypothetical code would sometimes fail, too, as regular
macros are expanded before Babel code is executed. IOW, macros can
produce Babel code, but not the other way (at least not consistently).


Regards,



reply via email to

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