Le 20/06/2015 01:11, Enrico Forestieri a écrit :
On Fri, Jun 19, 2015 at 04:50:43PM +0100, Guillaume M-M wrote:Le 07/06/2015 12:49, Enrico Forestieri a écrit :On Sat, Jun 06, 2015 at 08:07:12PM +0100, Guillaume M-M wrote:lyx-preview-macros2-failure.lyx shows two cases where a macro is forgotten>from the list. The third inset works and is meant as a control. All 3 workwithout the patch.Here I was forgetting to also scan nested insets.lyx-preview-macros2-lassert.lyx triggers an assertion when preview is activated. Does not assert without the patch.Here I did not account for the fact that also the macros defined in the symbols file are spotted. However, they do not have a valid DataMacro and this was causing the assert. Note that there is another bug here, but it is not a regression as it seems to be like that since ever (I checked with lyx versions since 1.3). The bug is that when using a symbol defined in the symbols file and this symbol requires a certain package, this requirement is not taken into account when generating the tex file for preview and thus latex fails.Notice that my "thourough test" is basically loading my current paper with preview on.I think that your paper is a very valid test case for macros ;) The attached patch solves all of the above problems (and also the segfault you report separately) for me. I am also attaching the patch for #9354 accordingly updated. Please test both and report the issues you find. If your paper pass the tests, I think they are good for stable ;)Hello again,Hi Guillaume,I tested the latest stable that seems to include the patches. As I already told Enrico, sorry for the delay as I did not have much free time until now. Thank you very much, this is really quick now. Thanks also for the timer for generating previews. Also I only had 1 segmentation error, which I could not reproduce unfortunately. It happened after changing from "Instant preview: On" to "No maths" and zooming. But probably it's part of the bigger issues with math macros, and again I could not reproduce.Yes, I also think this is not specifically related to previews.Here are two examples that still fail. lyx-bug-undefined.lyx: the macro used in the argument of another macro is not defined. I had many bugs of this style, so let's hope that this one is representative, otherwise I'll come back with more errors.Yes, I think it is. I was not taking into account that macros could also occur in the arguments of other macros. Should be fixed in master now.lyx-bug-renewcommandx4.lyx: here we have again an error where renewcommandx is used while the macro is not defined beforehand. If it is really too error prone to keep track of what has already been defined then it is easy to work around by using \definecommandx: \def\definecommandx#1{\providecommand#1{}\renewcommandx#1} This seems to work at least for the way newcommandx is used in lyx previews (but maybe you have other reasons for distinguishing the cases newcommandx and renewcommandx that I don't understand).This was due to a stupid typo and should also be fixed in master. As regards your proposal, I don't like defining commands only to immediately redefining them. And the fix was quite straightforward.
Good. We are down to 14 failing previews. (examples at the end)
Lastly I see that you prevent loading the microtype package by redefining \usepackage as you described earlier in the thread. While your redefinition of \usepackage seems to be very careful, I still think that passing the option draft to microtype is more reliable in case the user actually uses macros from microtype (in addition there's no need to test whether the user loads microtype).I am concerned with the fact that in dvi mode the microtype package considerably slows down the processing and prefer to not allow it.
Yes, and the draft option disables the microtype features completely according to the manual. That's also why I mentioned it. But it's your call.
I don't want to be too much of a PITA so here's a patch to lyxpreview2bitmap.py that integrates my above two suggestions and solves the above two problems. (The bug in lyx-bug-undefined.lyx has to be addressed separately.) Parsing a file using regexps is always delicate so I think it's good that with my patch there are fewer of these. I do not think that I missed any subtlety in the existing code, but in any case you don't need to accept it as is.In this particular case the regexp was simply wrong.Also, lyx-preview-macros-2-lassert.lyx no longer lasserts but on opening the preview is not generated because \Coloneqq is not defined. This looks like the bug that you are referring to in your message where packages for symbols are not properly loaded. But, notice that the preview is correctly generated on a second time, when entering and leaving the math inset. So maybe it's easier to fix than it seemed. But indeed it's not a regression.Yes, this has always been the case, seemingly. However, now one can obtain a preview after entering and exiting a math inset, while previously the preview was simply never generated. So, this is a step forward. As regards the reason it occurs, I have still to investigate the matter. Please, try again with master and report back. The required changes to address these glitches are straightforward and maybe Richard will allow backporting them to stable.
I simply applied your patch 98a5072a to stable directly (quicker to recompile).
lyx-bug-undefined3.lyx: macros inside nested macro definitions (!) are not taken into account.
lyx-bug-undefined4.lyx: a combination of two bugs I think. In particular, our friend \renewcommandx again. More detailed comments in the files.
lyx-bug-undefined5.lyx: the arguments are only scanned on the first occurrence of a macro.
lyx-bug-undefined5.lyx
Description: application/lyx
lyx-bug-undefined3.lyx
Description: application/lyx
lyx-bug-undefined4.lyx
Description: application/lyx