emacs-orgmode
[Top][All Lists]
Advanced

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

Re: inconsistency links and code line labels


From: Ihor Radchenko
Subject: Re: inconsistency links and code line labels
Date: Fri, 07 Jul 2023 09:48:19 +0000

Dan Drake <dan.drake@gmail.com> writes:

> Hello -- I'm wondering about my question from here:
>
> https://emacs.stackexchange.com/questions/77768/why-the-inconsistency-with-org-mode-code-line-labels-and-links
>
> Copying my question: in a source code special block, I can add code line
> labels, which have ref: in the label -- but when I make a link there, I
> have to omit the ref:. For example:
> ...
> 1047     bar = 5; //  (ref:my-code-line-label)
> ...
> There's a bug [[(my-code-line-label)][right here]].
>
> This seems inconsistent. Why do I have to omit the ref: bit? This always
> confuses me; it seems like it would be simpler to just make the label and
> the links to that line of code be exactly the same. I don't see any
> particular reference to this in the org manual (
> https://orgmode.org/manual/Internal-Links.html). Any insights?

The way coderefs appear in the code are completely configurable using
org-coderef-label-format ("(ref:%s)" by default) and using -l src code
switch.

> My idea would be to get rid of the special behavior for code line labels
> and just make this work with dedicated targets: in regular parts of my org
> file, I use <<link-target>> and can make links to that. It would be simple
> and consistent to make that also work the same when <<link-target>> is
> inside a code block.

If you examine 12.6 Literal Examples section of Org manual, you will see
that coderef links are exported specially:

       In literal examples, Org interprets strings like ‘(ref:name)’ as
    labels, and use them as targets for special hyperlinks like
    ‘[[(name)]]’—i.e., the reference name enclosed in single parenthesis.
    In HTML, hovering the mouse over such a link remote-highlights the
    corresponding code line, which is kind of cool.

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



reply via email to

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