[PATCH] Always use \newcommandx instead of \def
Enrico Forestieri
forenr at lyx.org
Tue Oct 17 18:29:12 UTC 2023
On Tue, Oct 17, 2023 at 01:10:23PM -0400, Richard Kimberly Heck wrote:
>
>On 10/16/23 21:22, Isaac Oscar Gariano wrote:
>>Currently \def is used for all math macros that have no option
>>arguments. This has caused me hard to debug errors because it
>>silently clobbers pre-existing LaTeX commands. On the other hand,
>>\newcommandx is used if there are optional arguments, and this gives
>>a helpful error message if the command is already defined. (if you
>>really do want to override the command, you can just put
>>\let\mycommand=\undefined in your LaTeX preamble, although with
>>unicode-math I often have to put this in an \AtBeginDocument).
>>
>>This very simple patch just makes LyX always output \newcommandx
>>instead of \def for math macros.
>>Unfortunately, this means if you want to have any math macros you'll
>>always need the xargs package (but it's a small package release all
>>they way back in 2008 and is included in TeXlive), hopefully this
>>won't annoy users too much.
>
>Since we already depend upon xargs, this won't be a problem.
>
>
>However, I think this might count as a format change, because it
>changes the exported LaTeX. If so, then it would have to wait for
>2.5.0. But I'm not sure about this, and perhaps the people who
>actually know about this will think it's safe. I'd like to hear.
Independently from that, this is a change that needs a lot of testing
and it is risky to perform near a release.
>You might want to have a look at 76dc2c0d3002db, which is where this
>code was introduced. It looks to me as if the previous code was
>actually very similar to what you have, but minus the prefix=\global
>part, and that we could then just have added that. It's a bit puzzling
>to me why Stefan did it the way he did, but he's long since not around
>to answer that question.
I seem to remember that he was actually forced to abandon the
\newcommandx approach due to some technical reason. Maybe there is a bug
report with details about this.
--
Enrico
More information about the lyx-devel
mailing list