* Problem when tangling source blocks with custom coderefs
@ 2022-01-18 22:20 Luis Osa
2022-01-19 1:33 ` Tom Gillespie
2022-11-10 6:27 ` Ihor Radchenko
0 siblings, 2 replies; 5+ messages in thread
From: Luis Osa @ 2022-01-18 22:20 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 1408 bytes --]
Dear all,
I would like to tangle source code blocks that contain coderefs. I have
found that the coderefs are correctly filtered out from the tangled files
if they follow the default format, i.e. "(ref:%s)", but not if I try to
customize the format using the documented "-l" switch [1] to change them to
something else, e.g. "|%s|".
Here is an example:
#+begin_src python -r -l "|%s|" :tangle example.py
try:
sys.exit(app.run())
except: |\label{line:except}\ding{182}|
sys.exit(1)
#+end_src
In line \ref{line:except}, marked \ding{182}, we are catching all
exceptions ...
After using `org-babel-tangle`, I would expect `example.py` to not have any
of the text between the `||` characters, but it is there and it makes the
file invalid to run.
I have found a thread in this mail list [2] where the coderef format used
during tangle is streamlined to use the function `org-src-coderef-regexp`.
That seems to be correct, but the behavior I am seeing does not recognize
the custom format correctly. Can someone please tell me if I am doing
something wrong? Or is that function not doing what it is intended to do?
I am running Org mode version 9.6 on top of GNU Emacs 27.2.
Thank you,
Luis
References:
[1] https://orgmode.org/manual/Literal-Examples.html
[2]
https://list.orgmode.org/CA+G3_PONzfmfB-UpUcE3jzPw5fVsbjzTeCCO4UkToa9NeUUU-w@mail.gmail.com/#R
[-- Attachment #2: Type: text/html, Size: 2124 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Problem when tangling source blocks with custom coderefs
2022-01-18 22:20 Problem when tangling source blocks with custom coderefs Luis Osa
@ 2022-01-19 1:33 ` Tom Gillespie
2022-01-19 21:00 ` Luis Osa
2022-10-23 5:37 ` Ihor Radchenko
2022-11-10 6:27 ` Ihor Radchenko
1 sibling, 2 replies; 5+ messages in thread
From: Tom Gillespie @ 2022-01-19 1:33 UTC (permalink / raw)
To: Luis Osa; +Cc: emacs-orgmode, Nicolas Goaziou
Hi Luis,
I don't think you are doing anything wrong. IIRC the portion of the
patch that allowed the customization to propagate to the tangled code
was not included. Given that I am no longer the only one who is
looking for/expecting this behavior, maybe it is worth revisiting the
decision. The simplest fix right now would be to prepend your coderef
with the python comment symbols # |hello| so that at the very least it
won't break your tangled files. I would like to see this implemented,
so let's see what Nicolas has to say. Best!
Tom
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Problem when tangling source blocks with custom coderefs
2022-01-19 1:33 ` Tom Gillespie
@ 2022-01-19 21:00 ` Luis Osa
2022-10-23 5:37 ` Ihor Radchenko
1 sibling, 0 replies; 5+ messages in thread
From: Luis Osa @ 2022-01-19 21:00 UTC (permalink / raw)
To: Tom Gillespie; +Cc: emacs-orgmode, Nicolas Goaziou
[-- Attachment #1: Type: text/plain, Size: 701 bytes --]
Hi Tom,
The simplest fix right now would be to prepend your coderef
> with the python comment symbols # |hello| so that at the very least it
> won't break your tangled files.
Actually, that is exactly what I have done as a quick fix. It has a minor
inconvenience: anything else included on the line is colored as if it were
a comment in the final PDF, and I intended to add a symbol to mark the
reference. Not a big deal, but it looks different than intended.
I would like to see this implemented,
> so let's see what Nicolas has to say.
I would like to contribute something. Maybe a test to show what is the
behavior to expect. Thanks for your reassurance that this is not an error
on my side!
[-- Attachment #2: Type: text/html, Size: 1265 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Problem when tangling source blocks with custom coderefs
2022-01-19 1:33 ` Tom Gillespie
2022-01-19 21:00 ` Luis Osa
@ 2022-10-23 5:37 ` Ihor Radchenko
1 sibling, 0 replies; 5+ messages in thread
From: Ihor Radchenko @ 2022-10-23 5:37 UTC (permalink / raw)
To: Tom Gillespie; +Cc: Luis Osa, emacs-orgmode, Nicolas Goaziou
Tom Gillespie <tgbugs@gmail.com> writes:
> I don't think you are doing anything wrong. IIRC the portion of the
> patch that allowed the customization to propagate to the tangled code
> was not included. Given that I am no longer the only one who is
> looking for/expecting this behavior, maybe it is worth revisiting the
> decision. The simplest fix right now would be to prepend your coderef
> with the python comment symbols # |hello| so that at the very least it
> won't break your tangled files. I would like to see this implemented,
> so let's see what Nicolas has to say. Best!
Could you please provide a link to the relevant discussion?
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Problem when tangling source blocks with custom coderefs
2022-01-18 22:20 Problem when tangling source blocks with custom coderefs Luis Osa
2022-01-19 1:33 ` Tom Gillespie
@ 2022-11-10 6:27 ` Ihor Radchenko
1 sibling, 0 replies; 5+ messages in thread
From: Ihor Radchenko @ 2022-11-10 6:27 UTC (permalink / raw)
To: Luis Osa; +Cc: emacs-orgmode
Luis Osa <luis.osa.gdc@gmail.com> writes:
> I would like to tangle source code blocks that contain coderefs. I have
> found that the coderefs are correctly filtered out from the tangled files
> if they follow the default format, i.e. "(ref:%s)", but not if I try to
> customize the format using the documented "-l" switch [1] to change them to
> something else, e.g. "|%s|".
I have looked through the ML archives and a similar issue appears to be
fixed already. See
https://orgmode.org/list/878s5rt81v.fsf@nicolasgoaziou.fr
> Here is an example:
>
> #+begin_src python -r -l "|%s|" :tangle example.py
> try:
> sys.exit(app.run())
> except: |\label{line:except}\ding{182}|
> sys.exit(1)
> #+end_src
>
> In line \ref{line:except}, marked \ding{182}, we are catching all
> exceptions ...
Note that we only allow _-A-Za-z0-9 in the labels. So, your example will
not work even after the fix.
Not sure if we need to do anything about this.
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-11-10 6:29 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-01-18 22:20 Problem when tangling source blocks with custom coderefs Luis Osa
2022-01-19 1:33 ` Tom Gillespie
2022-01-19 21:00 ` Luis Osa
2022-10-23 5:37 ` Ihor Radchenko
2022-11-10 6:27 ` 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).