Re: Expand macros in links

2022-12-27 Thread Ihor Radchenko
Michael Dauer  writes:

> Agree. How do you run such feature polls?

Change subject to something like

  [FR] [POLL] Allow expanding macros in link path like 
[[https://site-{{{macro}}}.com]]

Then see how many people reply.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: Expand macros in links

2022-12-27 Thread Michael Dauer
Agree. How do you run such feature polls?

Ihor Radchenko  schrieb am Di., 27. Dez. 2022, 17:20:

> Michael Dauer  writes:
>
> > I'm aware of this theoretical conflict. But I see the risk as very low
> > compared to the value of not having to make a lot of customizations for
> > export and internal link handling. It should just work out of the box.
>
> Even low risk does not justify impossible-to-use links when such problem
> occurs.
>
> > If you deem necessary there would still be the possibility to define a
> > global switch for this. This could then still have the 100% save default,
> > while still being easy to "configure".
>
> > If you want to go so far you could mitigate the risk of a conflict by
> > "escaping" the macro brackets. {{not-a-macro}} would be treated
> as
> > {{{not-a-marco}}} without expansion. Or any other escape sequence to
> bring
> > the conflict probability to 0.001.
>
> This is all indeed possible. The main question if whether it is
> justified to introduce all these complexities given the provided
> alternatives.
>
> Basically, we need more votes in favour to consider such feature.
>
> --
> Ihor Radchenko // yantar92,
> Org mode contributor,
> Learn more about Org mode at .
> Support Org development at ,
> or support my work at 
>


Re: Expand macros in links

2022-12-27 Thread Ihor Radchenko
Michael Dauer  writes:

> I'm aware of this theoretical conflict. But I see the risk as very low
> compared to the value of not having to make a lot of customizations for
> export and internal link handling. It should just work out of the box.

Even low risk does not justify impossible-to-use links when such problem
occurs.

> If you deem necessary there would still be the possibility to define a
> global switch for this. This could then still have the 100% save default,
> while still being easy to "configure".

> If you want to go so far you could mitigate the risk of a conflict by
> "escaping" the macro brackets. {{not-a-macro}} would be treated as
> {{{not-a-marco}}} without expansion. Or any other escape sequence to bring
> the conflict probability to 0.001.

This is all indeed possible. The main question if whether it is
justified to introduce all these complexities given the provided
alternatives.

Basically, we need more votes in favour to consider such feature.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: Expand macros in links

2022-12-27 Thread Michael Dauer
I'm aware of this theoretical conflict. But I see the risk as very low
compared to the value of not having to make a lot of customizations for
export and internal link handling. It should just work out of the box.

If you deem necessary there would still be the possibility to define a
global switch for this. This could then still have the 100% save default,
while still being easy to "configure".

If you want to go so far you could mitigate the risk of a conflict by
"escaping" the macro brackets. {{not-a-macro}} would be treated as
{{{not-a-marco}}} without expansion. Or any other escape sequence to bring
the conflict probability to 0.001.

Am Di., 27. Dez. 2022 um 16:51 Uhr schrieb Ihor Radchenko <
yanta...@posteo.net>:

> Michael Dauer  writes:
>
> > I mean something like:
> > * Heading
> > [[http:abc{{{input-file}}}]
> >
> > When exporting it to html then the link is not replaced.
>
> This is to be expected, and I do think that Org is doing it right by not
> replacing macros in links.
>
> You cannot exactly control what is inside link path - if an actual
> website link happens to contain {{{...}}} pattern, you will have no
> options left how to prevent Org from replacing that pattern.
>
> If you want to generate link paths programmatically, you can instead
> define custom links types or link abbreviations. See
> https://orgmode.org/manual/Link-Abbreviations.html and
> https://orgmode.org/manual/Adding-Hyperlink-Types.html
>
> You can control custom link export as well.
>
> --
> Ihor Radchenko // yantar92,
> Org mode contributor,
> Learn more about Org mode at .
> Support Org development at ,
> or support my work at 
>


Re: Expand macros in links

2022-12-27 Thread Ihor Radchenko
Michael Dauer  writes:

> I mean something like:
> * Heading
> [[http:abc{{{input-file}}}]
>
> When exporting it to html then the link is not replaced.

This is to be expected, and I do think that Org is doing it right by not
replacing macros in links.

You cannot exactly control what is inside link path - if an actual
website link happens to contain {{{...}}} pattern, you will have no
options left how to prevent Org from replacing that pattern.

If you want to generate link paths programmatically, you can instead
define custom links types or link abbreviations. See
https://orgmode.org/manual/Link-Abbreviations.html and
https://orgmode.org/manual/Adding-Hyperlink-Types.html

You can control custom link export as well.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: Expand macros in links

2022-12-27 Thread Michael Dauer
I mean something like:
* Heading
[[http:abc{{{input-file}}}]

When exporting it to html then the link is not replaced.

I'm talking about expansion when exporting.

But I also implemented macro expansion for following links within emacs
quite a while ago. Different story but also very powerful especially for
action links and deep links into other applications.


Am Di., 27. Dez. 2022 um 16:30 Uhr schrieb Ihor Radchenko <
yanta...@posteo.net>:

> Michael Dauer  writes:
>
> > I do not understand why links are excluded from macro expansion. I would
> > see it as very valuable to have macros for links too.
>
> Are they? Could you please provide an example?
>
> --
> Ihor Radchenko // yantar92,
> Org mode contributor,
> Learn more about Org mode at .
> Support Org development at ,
> or support my work at 
>


Re: Expand macros in links

2022-12-27 Thread Ihor Radchenko
Michael Dauer  writes:

> I do not understand why links are excluded from macro expansion. I would
> see it as very valuable to have macros for links too.

Are they? Could you please provide an example?

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Expand macros in links

2022-12-27 Thread Michael Dauer
Hi,

I do not understand why links are excluded from macro expansion. I would
see it as very valuable to have macros for links too.

The change would be as simple as inserting
(eq type 'link)
into org-macro-replace-all.

May I recommend this patch.

Thanks,
Michael