On Wed, Oct 15, 2014 at 11:37 AM, Jean-Marc Lasgouttes <lasgout...@lyx.org> wrote: > Le 15/10/2014 11:16, Alfredo Braunstein a écrit : >>> >>> I don't understand: I guess many inset just inherit their ::latex method. >>> What is the risk exactly. >> >> >> Advanced Search & replace all [math:x]->[math:y] in a document containing >> >> [disabled branch: blah blah][math:x] >> >> the result is >> >> [math:y] > > > OK, but what is the link between InsetERT not having a ::latex method ans > not outputting anything? The InsetText::latex is sufficiently flexible to > handle it. Likewise for many insets derived from InsetCommand (label, > bibitem...). > >>> Also, you may want to take in account the following method: >>> >>> /// Is the content of this inset part of the output document? >>> virtual bool producesOutput() const { return true; } >>> You could also check whether there have been some output after calling >>> ::latex and add a special marker otherwise. >> >> >> Where? *::latex gets called recursively... The advanced s&r stuff >> seems pretty complicated to me (and, from a quick look, a bit of a >> hack if you ask me. No offense to the authors I hope, it is actually >> an amazing feature). > > > It is a complet ehack. But this hack was easier to write than the proper > version (especially when one wants to do regex). > >> Adding a force_output flag could be an easy fix >> to the dataloss with no negative consequences that I can think of. >> What is your concern? > > > My concern is that we already have two pices of code where we override the > "no output property": > > * in Inset::addToToc, because we sometimes want the headings inside notes to > be available inthe outline sidebar > > * in Buffer::updateStatistics, because some people want to have the words in > their notes or inactive branches counted > > Before we had yet another thing for yet another use, I was wondering whether > we could have a unique mechanism with correct semantics to do that. > > One poiibility would be to be able to control what Inset::producesOutput > returns (maybe via a Buffer or BufferParams parameter, I don't know). The > explicit code in InsetNote should actually rely on producesOutput instead of > looking at type of note.
I see your point, but I'm not convinced. In your solution we will need to change the Buffer / BufferParams property temporarily before calling latex and restore it afterwards. It seems a bit hackish... Because ultimately, it's not a buffer property what we need, it is really a parameter for the latex export. It's the same for the two examples you cite IIUC, a temporary change only related to that specific operation. A/