emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [BUG] Inline src blocks do not work for LaTeX [9.5.4 (release_9.5.4-3-g6dc785 @ /Users/salutis/src/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/)]
@ 2022-07-03  9:57 Rudolf Adamkovič
  2022-07-03 11:43 ` Ihor Radchenko
  0 siblings, 1 reply; 8+ messages in thread
From: Rudolf Adamkovič @ 2022-07-03  9:57 UTC (permalink / raw)
  To: emacs-orgmode

Hello folks,

the documentation at

https://orgmode.org/manual/Structure-of-Code-Blocks.html

says

"Org offers two ways to structure source code in Org documents: in a
source code block, and directly inline. Both specifications are shown
below."

and

"An inline code block conforms to this structure: src_<language>{<body>}
… or src_<language>[<header arguments>]{<body>}"

So, I write

> For instance, src_latex{a \qqtext{with} b} renders as "$a
> \qqtext{with} b$".

I expect syntax-highlighted "a \qqtext{with} b" followed by the rendered
version.  Both in HTML and LaTeX export, I do not see the former.

Have I stumbled upon a bug, or do I not understand the syntax?

P.S.  When I change "latex" to, for example, "bash", the in-line source
block appears, albeit incorrectly highlighted.

Rudy

Emacs : GNU Emacs 29.0.50 (build 20, aarch64-apple-darwin21.5.0, NS
 appkit-2113.50 Version 12.4 (Build 21F79)) of 2022-07-02 Package: Org
 mode version 9.5.4 (release_9.5.4-3-g6dc785 @ <censored>)
-- 
"Thinking is a momentary dismissal of irrelevancies."
-- Richard Buckminster Fuller, 1969

Rudolf Adamkovič <salutis@me.com> [he/him]
Studenohorská 25
84103 Bratislava
Slovakia


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [BUG] Inline src blocks do not work for LaTeX [9.5.4 (release_9.5.4-3-g6dc785 @ /Users/salutis/src/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/)]
  2022-07-03  9:57 [BUG] Inline src blocks do not work for LaTeX [9.5.4 (release_9.5.4-3-g6dc785 @ /Users/salutis/src/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/)] Rudolf Adamkovič
@ 2022-07-03 11:43 ` Ihor Radchenko
  2022-07-03 19:11   ` Rudolf Adamkovič
  2022-07-04  2:32   ` Timothy
  0 siblings, 2 replies; 8+ messages in thread
From: Ihor Radchenko @ 2022-07-03 11:43 UTC (permalink / raw)
  To: Rudolf Adamkovič; +Cc: emacs-orgmode

Rudolf Adamkovič <salutis@me.com> writes:

> the documentation at
>
> https://orgmode.org/manual/Structure-of-Code-Blocks.html
>
> says
>
> "Org offers two ways to structure source code in Org documents: in a
> source code block, and directly inline. Both specifications are shown
> below."
>
> and
>
> "An inline code block conforms to this structure: src_<language>{<body>}
> … or src_<language>[<header arguments>]{<body>}"
>
> So, I write
>
>> For instance, src_latex{a \qqtext{with} b} renders as "$a
>> \qqtext{with} b$".
>
> I expect syntax-highlighted "a \qqtext{with} b" followed by the rendered
> version.  Both in HTML and LaTeX export, I do not see the former.
>
> Have I stumbled upon a bug, or do I not understand the syntax?
>
> P.S.  When I change "latex" to, for example, "bash", the in-line source
> block appears, albeit incorrectly highlighted.

This is not a bug, but a misunderstanding + undocumented default.
Src blocks, including inline src blocks, can be exported as code,
results of evaluation, and both. (this is likely your misunderstanding)
By default, unlike ordinary src blocks, inline src blocks are only
exported as results - code is not exported, only the result is exported.
(undocumented default).
Further, because Org is not always able to evaluate src blocks (when the
relevant ob-*.el is not loaded), inline src blocks can sometimes be
exported as code. This is likely what happens when you change the blocks
type to bash (I guess).

The inline src block defaults should probably be documented. See
https://orgmode.org/list/87ee927emf.fsf@localhost
Patches are welcome.

The confusing behavior about exporting results for code blocks when the
corresponding ob-*.el is not loaded is trickier. We had a related
discussion on this topic in
https://orgmode.org/list/87mtknsdhm.fsf@localhost
Though I am not sure how we can improve the situation. Ideas are
welcome.

Best,
Ihor


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [BUG] Inline src blocks do not work for LaTeX [9.5.4 (release_9.5.4-3-g6dc785 @ /Users/salutis/src/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/)]
  2022-07-03 11:43 ` Ihor Radchenko
@ 2022-07-03 19:11   ` Rudolf Adamkovič
  2022-07-03 21:19     ` Christian Heinrich
  2022-07-04 12:08     ` Ihor Radchenko
  2022-07-04  2:32   ` Timothy
  1 sibling, 2 replies; 8+ messages in thread
From: Rudolf Adamkovič @ 2022-07-03 19:11 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: emacs-orgmode

Ihor Radchenko <yantar92@gmail.com> writes:

> […]  By default, unlike ordinary src blocks, inline src blocks are
> only exported as results - code is not exported, only the result is
> exported.  […]  Further, because Org is not always able to evaluate
> src blocks (when the relevant ob-*.el is not loaded), inline src
> blocks can sometimes be exported as code.

Dear Ihor,

Thank you for taking the time with your reply.

Oh, my!  I expected the exact opposite default for *inline* source,
namely show code and hide results.  But then, I noticed that these
"inline" elements do not work in tables, so I cannot use them to
syntax-highlight a table of LaTeX commands anyway.  Bummer!

So then, when should we use these "inline blocks" in Org?  I expected
them to provide inline (nicely rendered) code anywhere, including in the
tables, like LaTeX provides in-line (nicely rendered) math everywhere.

(I also keep wondering why the feature uses a "special" syntax with
underscores when everything else in Org uses dashes.)

P.S. I also experimented with the src_shell some more:

With #+PROPERTY: header-args+ :exports both, src_shell{ls} exports as
"ls".  I did not expect that.  Note that I executed a normal BEGIN_SRC
"shell" block seconds before, so Emacs must have loaded the relevant
Lisp code.  I then started 'emacs -Q' and tried again.  This time,Org
exported 'src' followed by a subscript 'shell'.

Completely and utterly confused,

Rudy
-- 
"I love deadlines.  I love the whooshing noise they make as they go by."
-- Douglas Adams, The Salmon of Doubt, 2002

Rudolf Adamkovič <salutis@me.com> [he/him]
Studenohorská 25
84103 Bratislava
Slovakia


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [BUG] Inline src blocks do not work for LaTeX [9.5.4 (release_9.5.4-3-g6dc785 @ /Users/salutis/src/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/)]
  2022-07-03 19:11   ` Rudolf Adamkovič
@ 2022-07-03 21:19     ` Christian Heinrich
  2022-07-08 20:23       ` Rudolf Adamkovič
  2022-07-04 12:08     ` Ihor Radchenko
  1 sibling, 1 reply; 8+ messages in thread
From: Christian Heinrich @ 2022-07-03 21:19 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 2312 bytes --]

Hi Rudolf,

as to your question when to use an inline src block:

I use it particularly in documents that present results from data sets. For instance, when you
calculate something (e.g., an average value), you can store it in a variable =foo= (e.g., in R,
python etc., just make sure you use the :session parameter) and access =foo= in an inline source
block (that uses the same :session parameter). This allows you to avoid having hardcoded numbers in
your documents - when the data changes, so do all the numbers in your text.

As to the naming: begin_src also uses underscores, so I guess the naming scheme is fine...

Hope this helps!

Best regards
Christian

On Sun, 2022-07-03 at 21:11 +0200, Rudolf Adamkovič wrote:
> Ihor Radchenko <yantar92@gmail.com> writes:
> 
> > […]  By default, unlike ordinary src blocks, inline src blocks are
> > only exported as results - code is not exported, only the result is
> > exported.  […]  Further, because Org is not always able to evaluate
> > src blocks (when the relevant ob-*.el is not loaded), inline src
> > blocks can sometimes be exported as code.
> 
> Dear Ihor,
> 
> Thank you for taking the time with your reply.
> 
> Oh, my!  I expected the exact opposite default for *inline* source,
> namely show code and hide results.  But then, I noticed that these
> "inline" elements do not work in tables, so I cannot use them to
> syntax-highlight a table of LaTeX commands anyway.  Bummer!
> 
> So then, when should we use these "inline blocks" in Org?  I expected
> them to provide inline (nicely rendered) code anywhere, including in the
> tables, like LaTeX provides in-line (nicely rendered) math everywhere.
> 
> (I also keep wondering why the feature uses a "special" syntax with
> underscores when everything else in Org uses dashes.)
> 
> P.S. I also experimented with the src_shell some more:
> 
> With #+PROPERTY: header-args+ :exports both, src_shell{ls} exports as
> "ls".  I did not expect that.  Note that I executed a normal BEGIN_SRC
> "shell" block seconds before, so Emacs must have loaded the relevant
> Lisp code.  I then started 'emacs -Q' and tried again.  This time,Org
> exported 'src' followed by a subscript 'shell'.
> 
> Completely and utterly confused,
> 
> Rudy

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [BUG] Inline src blocks do not work for LaTeX [9.5.4 (release_9.5.4-3-g6dc785 @ /Users/salutis/src/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/)]
  2022-07-03 11:43 ` Ihor Radchenko
  2022-07-03 19:11   ` Rudolf Adamkovič
@ 2022-07-04  2:32   ` Timothy
  2022-07-04 12:21     ` Ihor Radchenko
  1 sibling, 1 reply; 8+ messages in thread
From: Timothy @ 2022-07-04  2:32 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: Rudolf Adamkovič, emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 919 bytes --]

Hi Ihor,

Two comments on this:

> The inline src block defaults should probably be documented. See
> <https://orgmode.org/list/87ee927emf.fsf@localhost>
> Patches are welcome.

I think it would also be nice if one could set inline header args with
`#+properties' and `:PROPERTIES:' in the same manner as block header args.

> The confusing behavior about exporting results for code blocks when the
> corresponding ob-*.el is not loaded is trickier. We had a related
> discussion on this topic in
> <https://orgmode.org/list/87mtknsdhm.fsf@localhost>
> Though I am not sure how we can improve the situation. Ideas are
> welcome.

One of the nice things Doom does with Org is add lazy-auto-loading of ob-*
backends. I’ve been poking Henrik for a while to upstream this (and a bunch of
other things) to Org, and am tentatively hopeful it will happen some time this
year.

All the best,
Timothy

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [BUG] Inline src blocks do not work for LaTeX [9.5.4 (release_9.5.4-3-g6dc785 @ /Users/salutis/src/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/)]
  2022-07-03 19:11   ` Rudolf Adamkovič
  2022-07-03 21:19     ` Christian Heinrich
@ 2022-07-04 12:08     ` Ihor Radchenko
  1 sibling, 0 replies; 8+ messages in thread
From: Ihor Radchenko @ 2022-07-04 12:08 UTC (permalink / raw)
  To: Rudolf Adamkovič; +Cc: emacs-orgmode

Rudolf Adamkovič <salutis@me.com> writes:

> With #+PROPERTY: header-args+ :exports both, src_shell{ls} exports as
> "ls".  I did not expect that.  Note that I executed a normal BEGIN_SRC
> "shell" block seconds before, so Emacs must have loaded the relevant
> Lisp code.  I then started 'emacs -Q' and tried again.  This time,Org
> exported 'src' followed by a subscript 'shell'.

Can you please provide the detailed steps you executed starting from
emacs -Q? 

Best,
Ihor


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [BUG] Inline src blocks do not work for LaTeX [9.5.4 (release_9.5.4-3-g6dc785 @ /Users/salutis/src/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/)]
  2022-07-04  2:32   ` Timothy
@ 2022-07-04 12:21     ` Ihor Radchenko
  0 siblings, 0 replies; 8+ messages in thread
From: Ihor Radchenko @ 2022-07-04 12:21 UTC (permalink / raw)
  To: Timothy; +Cc: Rudolf Adamkovič, emacs-orgmode

Timothy <tecosaur@gmail.com> writes:

> Hi Ihor,
>
> Two comments on this:
>
>> The inline src block defaults should probably be documented. See
>> <https://orgmode.org/list/87ee927emf.fsf@localhost>
>> Patches are welcome.
>
> I think it would also be nice if one could set inline header args with
> `#+properties' and `:PROPERTIES:' in the same manner as block header args.

AFAIK, it is already the case. Only org-babel-default-inline-header-args
is distinct for the inline src blocks. Buffer-local header-args
property, if set, does apply to both inline and normal src blocks.

>> The confusing behavior about exporting results for code blocks when the
>> corresponding ob-*.el is not loaded is trickier. We had a related
>> discussion on this topic in
>> <https://orgmode.org/list/87mtknsdhm.fsf@localhost>
>> Though I am not sure how we can improve the situation. Ideas are
>> welcome.
>
> One of the nice things Doom does with Org is add lazy-auto-loading of ob-*
> backends. I’ve been poking Henrik for a while to upstream this (and a bunch of
> other things) to Org, and am tentatively hopeful it will happen some time this
> year.

Sounds promising :)

Best,
Ihor


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [BUG] Inline src blocks do not work for LaTeX [9.5.4 (release_9.5.4-3-g6dc785 @ /Users/salutis/src/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/)]
  2022-07-03 21:19     ` Christian Heinrich
@ 2022-07-08 20:23       ` Rudolf Adamkovič
  0 siblings, 0 replies; 8+ messages in thread
From: Rudolf Adamkovič @ 2022-07-08 20:23 UTC (permalink / raw)
  To: Christian Heinrich, Ihor Radchenko, emacs-orgmode

Christian and Ihor,

Thank you folks for taking the time to explain the matter to me.  Your
messages made me realize that I completely misunderstood inline source
blocks.  It all makes sense, and I have no bug to report!

Rudy
-- 
"Programming reliably -- must be an activity of an undeniably
mathematical nature […] You see, mathematics is about thinking, and
doing mathematics is always trying to think as well as possible."
-- Edsger W. Dijkstra, 1981

Rudolf Adamkovič <salutis@me.com> [he/him]
Studenohorská 25
84103 Bratislava
Slovakia


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-07-08 20:24 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-03  9:57 [BUG] Inline src blocks do not work for LaTeX [9.5.4 (release_9.5.4-3-g6dc785 @ /Users/salutis/src/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/)] Rudolf Adamkovič
2022-07-03 11:43 ` Ihor Radchenko
2022-07-03 19:11   ` Rudolf Adamkovič
2022-07-03 21:19     ` Christian Heinrich
2022-07-08 20:23       ` Rudolf Adamkovič
2022-07-04 12:08     ` Ihor Radchenko
2022-07-04  2:32   ` Timothy
2022-07-04 12:21     ` Ihor Radchenko

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