Hi, Rik. If it helps, flags are explained in lowlevel-security manual: https://www.pragma-ade.com/general/manuals/lowlevel-security.pdf Jairo :) El dom, 24 de ene. de 2021 a la(s) 16:16, Rik Kabel ( ConTeXt@rik.users.panix.com) escribió:
On 1/24/2021 04:33, Wolfgang Schuster wrote:
Rik Kabel schrieb am 24.01.2021 um 05:13:
Hans and all,
Preparing my standard environments for future strict enforcement of overloading prevention, I have run into one issue.
I had been using the following construction to change the formatting of URLs:
\let\OrigHyphenatedurl\hyphenatedurl \starttexdefinition hyphenatedurl #URL \begingroup \URLfont\OrigHyphenatedurl{#URL} \endgroup \stoptexdefinition
You can use a hook to change the font for \hyphenatedurl.
\starttext
\hyphenatedurl{https://wiki.contextgarden.net/Main_Page}
\appendtoks \it \to \everyhyphenatedurl
\hyphenatedurl{https://wiki.contextgarden.net/Main_Page}
\stoptext
This results in the following warning about overloading \hyphenatedurl:
csname overload > warning, protection level 3, control sequence 'hyphenatedurl', properties 'permanent protected', file 'env_layout.mkvi', line 1
I have tried adding \overloaded to indicate the intentional overloading, but \overloaded cannot be used with \starttexdefinition, so I rewrote it as:
\let\OrigHyphenatedurl\hyphenatedurl \overloaded\define[1]\hyphenatedurl{% \begingroup% \URLfont\OrigHyphenatedurl{#1}% \endgroup}%
but that (and also with \overloaded\def\hyphenatedurl#1...) gives the same (except for the line number) warning:
csname overload > warning, protection level 3, control sequence 'hyphenatedurl', properties 'permanent protected', file 'env_layout.mkvi', line 822
So, what is the proper way to indicate intentional overloading? Or should this redefinition be done in another way?
The best solution is *to not* overload commands because there are either alternative ways to achieve the desired result or other commands which can be used.
\overloadmode=4
\starttext
\permanent\def\mycommand#1{[#1]}
\mycommand{Old definition}
\pushoverloadmode
\aliased\let\originalmycommand\mycommand
\permanent\def\mycommand#1% {{\it\originalmycommand{#1}}}
\popoverloadmode
\mycommand{New definition}
\stoptext
Wolfgang
Thank you, Wolfgang (and Hans),
The hook is perfect for this. I had avoided that construction for a long time thinking that it is too low-level, but looking at it again it seems to be the right thing here.
I can find no information on \aliased and the push/pop for overloademode and such, so will leave documenting that in the wiki to somebody with a few more clues.
-- Rik
___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net
___________________________________________________________________________________