[PATCH] Always use \newcommandx instead of \def
Scott Kostyshak
skostysh at lyx.org
Tue Oct 17 15:37:50 UTC 2023
On Tue, Oct 17, 2023 at 01:22:26AM +0000, 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.
>
> If you don't like this due to the dependency on the xargs package:
> I'm happy to modify it, to for example:
>
> * Make this patch togglable with a checkbox in the GUI (default will of course by the previous behaviour)
> * Execute a dummy \newcommand to get the error message, then do the \def as before
>
> — Isaac Oscar Gariano
Thank you Isaac! I'm not too familiar with these technical details so I
can't comment on the patch. It might help if you could send a few
minimal .lyx documents that illustrate the problem with the current
mechanism. In addition to making the current problem very clear, those
.lyx files would also be helpful to add to our tests if we move towards
an implementation similar to what you have in mind. If we add the
feature and the test files then we can protect against regressions.
Thanks for your work on this!
Scott
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://lists.lyx.org/pipermail/lyx-devel/attachments/20231017/b47a7887/attachment-0001.asc>
More information about the lyx-devel
mailing list