On Thu, Oct 29, 2015 at 09:12:04AM +0000, Guenter Milde wrote:
> On 2015-10-29, Scott Kostyshak wrote:

> As my FIXME was wrong, so is your patch.

I see.

> > In regards to "Dont forget to keep this check in sync with the check
> > above!" this seems to be a good situation for a helper function in order
> > to share code.
> 
> Maybe define a new setting/helper_function "inputenc package available"
> in BufferParams.cpp?

I'm starting to understand more the situation and what you want. Here is
what I think I understand:

- the BufferParams inputenc member is not what you want because that is
  just the setting in the document. It is a complicated process (as
  shown by BufferParams::writeEncodingPreamble()) to figure out what is
  actually done.

- you cannot use features.isRequired("inputenc") because even if
  that is false, it seems that the inputenc package could still be
  loaded, as is done in BufferParams::writeEncodingPreamble(). In other
  words, the only place that knows whether the inputenc package is
  loaded is BufferParams::writeEncodingPreamble() and it does not store
  the information anywhere, it just writes to the preamble.

(EDIT for reader: skip to the paragraph starting with "Actually" unless
you want to see the clumsy thought process leading up to that)

So the solution might be to factor out the code that determines whether
to load the inputenc package from BufferParams::writeEncodingPreamble()
in a place that would be acccessible both by
BufferParams::writeEncodingPreamble() and PDFOptions::writeLaTeX().

writeEncodingPreamble() and pdfoptions().writeLaTeX() are both called in
BufferParams::writeLaTeX(), so one possibility is that instead of
writeEncodingPreamble() doing the necessary steps to determine whether
to load the inputenc package, that could be done in
BufferParams::writeLaTeX(), either through a helper function (maybe
named something like determineEncodingPreamble() ?) or just directly
(but I think a helper function would be preferred). For example, we
could create a boolean using_inputenc that is local to
BufferParams::writeLaTeX() and then pass that boolean to
writeEncodingPreamble() and pdfoptions().writeLaTeX().

Another possibility is to store the information in the BufferParams
class. If we do this, I imagine we should not write new information from
bufferParams::writeLaTeX(). At least, I would not expect it to write any
new members judging from its name. So we would have to factor out the
code further.

Actually, after thinking about this a bit longer my new favorite
approach is simply for BufferParams::writeEncodingPreamble to return the
necessary information (e.g. it could return a boolean using_inputenc)
that is then just passed to pdfoptions().writeLaTeX(). That seems the
cleanest and safest approach. I thought that it might not be common for
a write method to return such information (I figured if anything it
would return success/fail), but actually we already do this:
BufferParams::writeLaTeX() returns a boolean use_babel.

Scott

Reply via email to