* macro with inline source does not work in table cells
@ 2018-04-10 18:09 kabriel
2018-04-11 10:52 ` Nicolas Goaziou
0 siblings, 1 reply; 5+ messages in thread
From: kabriel @ 2018-04-10 18:09 UTC (permalink / raw)
To: emacs-orgmode; +Cc: kabriel
Hi,
I have defined a macro that uses an emacs-lisp inline source code. It
works fine in all the usual places, except table cells. A more standard
macro (that does not use a source code block) works fine. I have tried
looking through the source code in the exporter, but cannot quite figure
out why this isn't working.
Would anyone have an idea of how to get the expected behavior? Below is
an example.
<<< begin example org-mode file>>>
* Test: macro fails in table cell
#+MACRO: kw src_emacs-lisp[:exports results :results raw]{(concat "=" (upcase "$1") "=")}
#+MACRO: ku =$1=
Try "hello {{{kw(world)}}}," but let's put it in a table [[tab:eg]]
#+NAME: tab:eg
#+CAPTION: Test table with "hello {{{kw(world)}}}"
| Statement | Object |
|------------+-----------------|
| hello | {{{kw(world)}}} |
| this macro | {{{ku(works)}}} |
<<< end >>>
Org mode version 9.1.1 (9.1.1-17-g24ea1b-elpaplus)
GNU Emacs 25.3.1
-- Kabriel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: macro with inline source does not work in table cells
2018-04-10 18:09 macro with inline source does not work in table cells kabriel
@ 2018-04-11 10:52 ` Nicolas Goaziou
2018-04-12 18:32 ` Severin Kempf
0 siblings, 1 reply; 5+ messages in thread
From: Nicolas Goaziou @ 2018-04-11 10:52 UTC (permalink / raw)
To: kabriel; +Cc: emacs-orgmode
kabriel@3imail.com writes:
> Hi,
>
> I have defined a macro that uses an emacs-lisp inline source code. It
> works fine in all the usual places, except table cells. A more standard
> macro (that does not use a source code block) works fine. I have tried
> looking through the source code in the exporter, but cannot quite figure
> out why this isn't working.
>
> Would anyone have an idea of how to get the expected behavior? Below is
> an example.
inline source code is not supported in tables. You are expected to use `org-sbe'.
Regards,
--
Nicolas Goaziou
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: macro with inline source does not work in table cells
2018-04-11 10:52 ` Nicolas Goaziou
@ 2018-04-12 18:32 ` Severin Kempf
2018-04-12 18:40 ` Nicolas Goaziou
0 siblings, 1 reply; 5+ messages in thread
From: Severin Kempf @ 2018-04-12 18:32 UTC (permalink / raw)
To: Nicolas Goaziou; +Cc: emacs-orgmode, kabriel
Hi,
on [2018-04-11] at 06:52:42 AM -0400, Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:
> inline source code is not supported in tables. You are expected to use `org-sbe'.
>
> Regards,
Thanks for your suggestion. After some trial and error, I figured out
how to do this using babel:
<<< begin example org-mode file >>>
#+MACRO: kw src_emacs-lisp[:exports results :results raw]{(concat "=" (upcase "$1") "=")}
#+MACRO: ku =$1=
#+NAME: kwt
#+BEGIN_SRC emacs-lisp :var kw="keyword"
(concat "=" (upcase kw) "=")
#+END_SRC
Try "hello {{{kw(world)}}}," but let's put it in a table [[tab:eg]]
#+NAME: tab:eg
#+CAPTION: Test table with "hello {{{kw(world)}}}"
| Statement | Object |
|---------------+-----------------|
| hello | {{{kw(world)}}} |
| this macro | {{{ku(works)}}} |
| this function | =KIND-OF-WORKS= |
#+TBLFM: @4$2='(org-sbe kwt (kw \"kind-of-works\"))
<<< end >>>
This is very cumbersome for my particular document, which has a large
number of cells that I am working with. I could add an additional column
to facilitate this, but I don't see a good way to hide that column from
the exporter -- I only want the result, not the data needed to generate
the result.
That being said, the documentation states that macro expansion takes
place, among other places, in table cells
(https://orgmode.org/manual/Macro-replacement.html#Macro-replacement).
When I look at ox.el, org-macro-replace-all is run prior to
org-babel-exp-process-buffer, and it looks to me like
org-babel-exp-process-buffer also includes inline blocks, obviously the
case because this process works in the document text and in the table
caption. What is preventing it from working in the table cell? What is
allowing a simpler macro expansion to work inside of a table cell?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: macro with inline source does not work in table cells
2018-04-12 18:32 ` Severin Kempf
@ 2018-04-12 18:40 ` Nicolas Goaziou
2018-04-12 21:02 ` Severin Kempf
0 siblings, 1 reply; 5+ messages in thread
From: Nicolas Goaziou @ 2018-04-12 18:40 UTC (permalink / raw)
To: Severin Kempf; +Cc: emacs-orgmode
Hello,
Severin Kempf <kabriel@3imail.com> writes:
> This is very cumbersome for my particular document, which has a large
> number of cells that I am working with. I could add an additional column
> to facilitate this, but I don't see a good way to hide that column from
> the exporter -- I only want the result, not the data needed to generate
> the result.
You can pass header arguments to the `org-sbe' call. It may be possible
to get the results without the data.
> What is preventing it from working in the table cell? What is
> allowing a simpler macro expansion to work inside of a table cell?
The parser. Inline Babel code is not parsed in table cells. This could
conflict with TBLFM lines.
Regards,
--
Nicolas Goaziou
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: macro with inline source does not work in table cells
2018-04-12 18:40 ` Nicolas Goaziou
@ 2018-04-12 21:02 ` Severin Kempf
0 siblings, 0 replies; 5+ messages in thread
From: Severin Kempf @ 2018-04-12 21:02 UTC (permalink / raw)
To: Nicolas Goaziou; +Cc: emacs-orgmode, Severin Kempf
Hi
on [2018-04-12] at 02:40:13 PM -0400, Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:
> The parser. Inline Babel code is not parsed in table cells. This could
> conflict with TBLFM lines.
I found where these restrictions are set in org-element.el; and the
comments state exactly what you said ("Ignore inline babel call and
inline src block as formulas are possible."). Can you think of an
example of this conflict?
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-04-12 21:02 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-04-10 18:09 macro with inline source does not work in table cells kabriel
2018-04-11 10:52 ` Nicolas Goaziou
2018-04-12 18:32 ` Severin Kempf
2018-04-12 18:40 ` Nicolas Goaziou
2018-04-12 21:02 ` Severin Kempf
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).