The attached patch implements the possibility to customize the options as well as to chose a specific program for index and bibliography generation.
I have assured that this can not be misused to launch something evil (thanks to QProcess). Jürgen
Index: src/LaTeX.cpp =================================================================== --- src/LaTeX.cpp (Revision 29760) +++ src/LaTeX.cpp (Arbeitskopie) @@ -50,7 +50,6 @@ // different way. // - the makeindex style files should be taken care of with // the dependency mechanism. -// - makeindex commandline options should be supported // - somewhere support viewing of bibtex and makeindex log files. // - we should perhaps also scan the bibtex log file @@ -414,6 +413,9 @@ { string tmp = runparams.use_japanese ? lyxrc.jindex_command : lyxrc.index_command; + + if (!runparams.index_command.empty()) + tmp = runparams.index_command; LYXERR(Debug::LATEX, "idx file has been made, running index processor (" @@ -570,6 +572,9 @@ string tmp = runparams.use_japanese ? lyxrc.jbibtex_command : lyxrc.bibtex_command; + + if (!runparams.bibtex_command.empty()) + tmp = runparams.bibtex_command; tmp += " "; // onlyFilename() is needed for cygwin tmp += quoteName(onlyFilename(removeExtension( Index: src/BufferParams.h =================================================================== --- src/BufferParams.h (Revision 29760) +++ src/BufferParams.h (Arbeitskopie) @@ -184,6 +184,10 @@ std::string graphicsDriver; /// The default output format std::string defaultOutputFormat; + /// customized bibliography processor + std::string bibtex_command; + /// customized index processor + std::string index_command; /// the rm font std::string fontsRoman; /// the sf font Index: src/Converter.cpp =================================================================== --- src/Converter.cpp (Revision 29760) +++ src/Converter.cpp (Arbeitskopie) @@ -329,6 +329,10 @@ if (buffer) { runparams.use_japanese = buffer->bufferFormat() == "platex"; runparams.use_indices = buffer->params().use_indices; + runparams.bibtex_command = (buffer->params().bibtex_command == "default") ? + string() : buffer->params().bibtex_command; + runparams.index_command = (buffer->params().index_command == "default") ? + string() : buffer->params().index_command; } // Some converters (e.g. lilypond) can only output files to the Index: src/OutputParams.h =================================================================== --- src/OutputParams.h (Revision 29760) +++ src/OutputParams.h (Arbeitskopie) @@ -127,6 +127,14 @@ */ bool use_japanese; + /** Customized bibtex_command + */ + mutable std::string bibtex_command; + + /** Customized index_command + */ + mutable std::string index_command; + /** Line length to use with plaintext export. */ size_type linelen; Index: src/frontends/qt4/GuiDocument.h =================================================================== --- src/frontends/qt4/GuiDocument.h (Revision 29760) +++ src/frontends/qt4/GuiDocument.h (Arbeitskopie) @@ -99,6 +99,7 @@ void browseLayout(); void browseMaster(); void classChanged(); + void bibtexChanged(int); void updateModuleInfo(); void modulesChanged(); void changeBackgroundColor(); Index: src/frontends/qt4/GuiDocument.cpp =================================================================== --- src/frontends/qt4/GuiDocument.cpp (Revision 29760) +++ src/frontends/qt4/GuiDocument.cpp (Arbeitskopie) @@ -859,11 +859,24 @@ this, SLOT(change_adaptor())); connect(biblioModule->bibtopicCB, SIGNAL(clicked()), this, SLOT(change_adaptor())); + connect(biblioModule->bibtexCO, SIGNAL(activated(int)), + this, SLOT(bibtexChanged(int))); + connect(biblioModule->bibtexOptionsED, SIGNAL(textChanged(QString)), + this, SLOT(change_adaptor())); // biblio biblioModule->citeStyleCO->addItem(qt_("Author-year")); biblioModule->citeStyleCO->addItem(qt_("Numerical")); biblioModule->citeStyleCO->setCurrentIndex(0); + + biblioModule->bibtexCO->clear(); + biblioModule->bibtexCO->addItem(qt_("Default"), QString("default")); + for (vector<string>::const_iterator it = lyxrc.bibtex_alternatives.begin(); + it != lyxrc.bibtex_alternatives.end(); ++it) { + QString const command = toqstr(*it).left(toqstr(*it).indexOf(" ")); + biblioModule->bibtexCO->addItem(command, command); + } + // indices indicesModule = new GuiIndices; connect(indicesModule, SIGNAL(changed()), @@ -1498,6 +1511,13 @@ } +void GuiDocument::bibtexChanged(int n) +{ + biblioModule->bibtexOptionsED->setEnabled(n != 0); + changed(); +} + + namespace { // This is an insanely complicated attempt to make this sort of thing // work with RTL languages. @@ -1721,6 +1741,15 @@ bp_.use_bibtopic = biblioModule->bibtopicCB->isChecked(); + string const bibtex_command = + fromqstr(biblioModule->bibtexCO->itemData( + biblioModule->bibtexCO->currentIndex()).toString()); + if (bibtex_command == "default") + bp_.bibtex_command = bibtex_command; + else + bp_.bibtex_command = bibtex_command + " " + + fromqstr(biblioModule->bibtexOptionsED->text()); + // Indices indicesModule->apply(bp_); @@ -2058,6 +2087,21 @@ biblioModule->bibtopicCB->setChecked( bp_.use_bibtopic); + string command; + string options = + split(bp_.bibtex_command, command, ' '); + + int const bpos = biblioModule->bibtexCO->findData(toqstr(command)); + if (bpos != -1) { + biblioModule->bibtexCO->setCurrentIndex(bpos); + biblioModule->bibtexOptionsED->setText(toqstr(options).trimmed()); + } else { + biblioModule->bibtexCO->setCurrentIndex(0); + biblioModule->bibtexOptionsED->clear(); + } + biblioModule->bibtexOptionsED->setEnabled( + biblioModule->bibtexCO->currentIndex() != 0); + // indices indicesModule->update(bp_); Index: src/frontends/qt4/GuiIndices.h =================================================================== --- src/frontends/qt4/GuiIndices.h (Revision 29760) +++ src/frontends/qt4/GuiIndices.h (Arbeitskopie) @@ -44,6 +44,8 @@ void updateView(); protected Q_SLOTS: + void on_indexCO_activated(int n); + void on_indexOptionsED_textChanged(QString); void on_addIndexPB_pressed(); void on_renamePB_clicked(); void on_removePB_pressed(); Index: src/frontends/qt4/GuiIndices.cpp =================================================================== --- src/frontends/qt4/GuiIndices.cpp (Revision 29760) +++ src/frontends/qt4/GuiIndices.cpp (Arbeitskopie) @@ -22,6 +22,7 @@ #include "frontends/alert.h" #include "BufferParams.h" +#include "LyXRC.h" #include "support/gettext.h" #include "support/lstrings.h" @@ -34,6 +35,10 @@ #include <QColorDialog> +using namespace std; +using namespace lyx::support; + + namespace lyx { namespace frontend { @@ -46,6 +51,14 @@ indicesTW->headerItem()->setText(0, qt_("Name")); indicesTW->headerItem()->setText(1, qt_("Label Color")); indicesTW->setSortingEnabled(true); + + indexCO->clear(); + indexCO->addItem(qt_("Default"), QString("default")); + for (vector<string>::const_iterator it = lyxrc.index_alternatives.begin(); + it != lyxrc.index_alternatives.end(); ++it) { + QString const command = toqstr(*it).left(toqstr(*it).indexOf(" ")); + indexCO->addItem(command, command); + } } void GuiIndices::update(BufferParams const & params) @@ -60,6 +73,22 @@ availableLA->setEnabled(state); removePB->setEnabled(state); colorPB->setEnabled(state); + + string command; + string options = + split(params.index_command, command, ' '); + + int const pos = indexCO->findData(toqstr(command)); + if (pos != -1) { + indexCO->setCurrentIndex(pos); + indexOptionsED->setText(toqstr(options).trimmed()); + } else { + indexCO->setCurrentIndex(0); + indexOptionsED->clear(); + } + indexOptionsED->setEnabled( + indexCO->currentIndex() != 0); + updateView(); } @@ -103,9 +132,31 @@ { params.use_indices = multipleIndicesCB->isChecked(); params.indiceslist() = indiceslist_; + + string const index_command = + fromqstr(indexCO->itemData( + indexCO->currentIndex()).toString()); + if (index_command == "default") + params.index_command = index_command; + else + params.index_command = index_command + " " + + fromqstr(indexOptionsED->text()); } +void GuiIndices::on_indexCO_activated(int n) +{ + indexOptionsED->setEnabled(n != 0); + changed(); +} + + +void GuiIndices::on_indexOptionsED_textChanged(QString) +{ + changed(); +} + + void GuiIndices::on_addIndexPB_pressed() { QString const new_index = newIndexLE->text(); Index: src/frontends/qt4/ui/IndicesUi.ui =================================================================== --- src/frontends/qt4/ui/IndicesUi.ui (Revision 29760) +++ src/frontends/qt4/ui/IndicesUi.ui (Arbeitskopie) @@ -12,21 +12,102 @@ <property name="windowTitle" > <string/> </property> - <layout class="QGridLayout" > - <property name="margin" > - <number>9</number> - </property> - <property name="spacing" > - <number>6</number> - </property> + <layout class="QGridLayout" name="gridLayout" > + <item row="0" column="0" colspan="2" > + <widget class="QGroupBox" name="indexGB" > + <property name="toolTip" > + <string>Here you can define an alternative index processor and specify its options.</string> + </property> + <property name="title" > + <string>Index generation</string> + </property> + <property name="flat" > + <bool>true</bool> + </property> + <layout class="QGridLayout" name="gridLayout_2" > + <item row="0" column="0" > + <layout class="QHBoxLayout" name="horizontalLayout" > + <item> + <widget class="QLabel" name="indexLA" > + <property name="text" > + <string>&Processor:</string> + </property> + <property name="buddy" > + <cstring>indexCO</cstring> + </property> + </widget> + </item> + <item> + <widget class="QComboBox" name="indexCO" > + <property name="toolTip" > + <string>Select a processor</string> + </property> + </widget> + </item> + </layout> + </item> + <item row="1" column="0" > + <layout class="QHBoxLayout" name="horizontalLayout_2" > + <item> + <widget class="QLabel" name="indexOptionsLA" > + <property name="text" > + <string>&Options:</string> + </property> + <property name="buddy" > + <cstring>indexOptionsED</cstring> + </property> + </widget> + </item> + <item> + <widget class="QLineEdit" name="indexOptionsED" > + <property name="toolTip" > + <string>Define program options of the selected processor.</string> + </property> + </widget> + </item> + </layout> + </item> + <item rowspan="2" row="0" column="1" > + <spacer name="horizontalSpacer" > + <property name="orientation" > + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0" > + <size> + <width>183</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> + </item> + <item row="1" column="0" > + <widget class="QCheckBox" name="multipleIndicesCB" > + <property name="toolTip" > + <string>Check if you need multiple indexes (e.g., an Index of Names)</string> + </property> + <property name="text" > + <string>&Use multiple indexes</string> + </property> + </widget> + </item> <item row="2" column="0" colspan="2" > + <widget class="Line" name="line" > + <property name="orientation" > + <enum>Qt::Horizontal</enum> + </property> + </widget> + </item> + <item row="3" column="0" colspan="2" > <layout class="QHBoxLayout" > + <property name="spacing" > + <number>6</number> + </property> <property name="margin" > <number>0</number> </property> - <property name="spacing" > - <number>6</number> - </property> <item> <widget class="QLabel" name="newIndexLA" > <property name="text" > @@ -56,33 +137,7 @@ </item> </layout> </item> - <item row="4" column="1" > - <widget class="QPushButton" name="removePB" > - <property name="toolTip" > - <string>Remove the selected index</string> - </property> - <property name="text" > - <string>&Remove</string> - </property> - </widget> - </item> - <item row="7" column="1" > - <spacer> - <property name="orientation" > - <enum>Qt::Vertical</enum> - </property> - <property name="sizeType" > - <enum>QSizePolicy::Expanding</enum> - </property> - <property name="sizeHint" > - <size> - <width>20</width> - <height>121</height> - </size> - </property> - </spacer> - </item> - <item row="3" column="0" > + <item row="4" column="0" > <widget class="QLabel" name="availableLA" > <property name="text" > <string>A&vailable Indexes:</string> @@ -92,27 +147,36 @@ </property> </widget> </item> - <item rowspan="4" row="4" column="0" > - <widget class="QTreeWidget" name="indicesTW" /> + <item rowspan="4" row="5" column="0" > + <widget class="QTreeWidget" name="indicesTW" > + <column> + <property name="text" > + <string>1</string> + </property> + </column> + </widget> </item> - <item row="0" column="0" > - <widget class="QCheckBox" name="multipleIndicesCB" > + <item row="5" column="1" > + <widget class="QPushButton" name="removePB" > <property name="toolTip" > - <string>Check if you need multiple indexes (e.g., an Index of Names)</string> + <string>Remove the selected index</string> </property> <property name="text" > - <string>&Use multiple indexes</string> + <string>&Remove</string> </property> </widget> </item> - <item row="1" column="0" colspan="2" > - <widget class="Line" name="line" > - <property name="orientation" > - <enum>Qt::Horizontal</enum> + <item row="6" column="1" > + <widget class="QPushButton" name="renamePB" > + <property name="toolTip" > + <string>Rename the selected index</string> </property> + <property name="text" > + <string>R&ename...</string> + </property> </widget> </item> - <item row="6" column="1" > + <item row="7" column="1" > <widget class="QPushButton" name="colorPB" > <property name="toolTip" > <string>Define or change button color</string> @@ -122,15 +186,21 @@ </property> </widget> </item> - <item row="5" column="1" > - <widget class="QPushButton" name="renamePB" > - <property name="toolTip" > - <string>Rename the selected index</string> + <item row="8" column="1" > + <spacer> + <property name="orientation" > + <enum>Qt::Vertical</enum> </property> - <property name="text" > - <string>R&ename...</string> + <property name="sizeType" > + <enum>QSizePolicy::Expanding</enum> </property> - </widget> + <property name="sizeHint" stdset="0" > + <size> + <width>20</width> + <height>121</height> + </size> + </property> + </spacer> </item> </layout> </widget> Index: src/frontends/qt4/ui/BiblioUi.ui =================================================================== --- src/frontends/qt4/ui/BiblioUi.ui (Revision 29760) +++ src/frontends/qt4/ui/BiblioUi.ui (Arbeitskopie) @@ -12,32 +12,23 @@ <property name="windowTitle" > <string/> </property> - <layout class="QGridLayout" > - <property name="margin" > - <number>9</number> - </property> - <property name="spacing" > - <number>6</number> - </property> + <layout class="QGridLayout" name="gridLayout_3" > <item row="0" column="0" > <widget class="QGroupBox" name="CiteStyleBG" > <property name="title" > <string>Citation Style</string> </property> - <layout class="QGridLayout" > - <property name="margin" > - <number>9</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item row="2" column="0" > - <widget class="QRadioButton" name="citeJurabibRB" > + <property name="flat" > + <bool>true</bool> + </property> + <layout class="QGridLayout" name="gridLayout" > + <item row="0" column="0" > + <widget class="QRadioButton" name="citeDefaultRB" > <property name="toolTip" > - <string>Use the jurabib styles for law and humanities</string> + <string>Use BibTeX's default numerical styles</string> </property> <property name="text" > - <string>&Jurabib</string> + <string>&Default (numerical)</string> </property> </widget> </item> @@ -51,24 +42,14 @@ </property> </widget> </item> - <item row="0" column="0" > - <widget class="QRadioButton" name="citeDefaultRB" > - <property name="toolTip" > - <string>Use BibTeX's default numerical styles</string> - </property> - <property name="text" > - <string>&Default (numerical)</string> - </property> - </widget> - </item> <item row="1" column="1" > <layout class="QHBoxLayout" > + <property name="spacing" > + <number>6</number> + </property> <property name="margin" > <number>0</number> </property> - <property name="spacing" > - <number>6</number> - </property> <item> <widget class="QLabel" name="citationStyleL" > <property name="enabled" > @@ -88,9 +69,7 @@ <bool>false</bool> </property> <property name="sizePolicy" > - <sizepolicy> - <hsizetype>0</hsizetype> - <vsizetype>0</vsizetype> + <sizepolicy vsizetype="Fixed" hsizetype="Fixed" > <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> @@ -99,23 +78,33 @@ </item> </layout> </item> + <item row="1" column="2" > + <spacer> + <property name="orientation" > + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0" > + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item row="2" column="0" > + <widget class="QRadioButton" name="citeJurabibRB" > + <property name="toolTip" > + <string>Use the jurabib styles for law and humanities</string> + </property> + <property name="text" > + <string>&Jurabib</string> + </property> + </widget> + </item> </layout> </widget> </item> - <item row="0" column="1" > - <spacer> - <property name="orientation" > - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" > - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item row="1" column="0" colspan="2" > + <item row="1" column="0" > <widget class="QCheckBox" name="bibtopicCB" > <property name="toolTip" > <string>Select this if you want to split your bibliography into sections</string> @@ -125,7 +114,77 @@ </property> </widget> </item> - <item row="2" column="0" colspan="2" > + <item row="2" column="0" > + <widget class="QGroupBox" name="bibtexGB" > + <property name="toolTip" > + <string>Here you can define an alternative program to or specific options of bibtex.</string> + </property> + <property name="title" > + <string>Bibliography generation</string> + </property> + <property name="flat" > + <bool>true</bool> + </property> + <layout class="QGridLayout" name="gridLayout_2" > + <item row="0" column="0" > + <layout class="QHBoxLayout" name="horizontalLayout" > + <item> + <widget class="QLabel" name="bibtexLA" > + <property name="text" > + <string>&Processor:</string> + </property> + <property name="buddy" > + <cstring>bibtexCO</cstring> + </property> + </widget> + </item> + <item> + <widget class="QComboBox" name="bibtexCO" > + <property name="toolTip" > + <string>Select a processor</string> + </property> + </widget> + </item> + </layout> + </item> + <item rowspan="2" row="0" column="1" > + <spacer name="horizontalSpacer" > + <property name="orientation" > + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0" > + <size> + <width>183</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item row="1" column="0" > + <layout class="QHBoxLayout" name="horizontalLayout_2" > + <item> + <widget class="QLabel" name="bibtexOptionsLA" > + <property name="text" > + <string>&Options:</string> + </property> + <property name="buddy" > + <cstring>bibtexOptionsED</cstring> + </property> + </widget> + </item> + <item> + <widget class="QLineEdit" name="bibtexOptionsED" > + <property name="toolTip" > + <string>Define options such as --min-crossrefs (see man bibtex).</string> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + </item> + <item row="3" column="0" > <spacer> <property name="orientation" > <enum>Qt::Vertical</enum> @@ -133,7 +192,7 @@ <property name="sizeType" > <enum>QSizePolicy::Expanding</enum> </property> - <property name="sizeHint" > + <property name="sizeHint" stdset="0" > <size> <width>20</width> <height>20</height> Index: src/Buffer.cpp =================================================================== --- src/Buffer.cpp (Revision 29760) +++ src/Buffer.cpp (Arbeitskopie) @@ -125,7 +125,7 @@ // Do not remove the comment below, so we get merge conflict in // independent branches. Instead add your own. -int const LYX_FORMAT = 357; // sanda: change latex output for various underline commands +int const LYX_FORMAT = 358; // jspitzm: customizable bibtex/makeindex calls typedef map<string, bool> DepClean; typedef map<docstring, pair<InsetLabel const *, Buffer::References> > RefCache; Index: src/BufferParams.cpp =================================================================== --- src/BufferParams.cpp (Revision 29760) +++ src/BufferParams.cpp (Arbeitskopie) @@ -355,6 +355,8 @@ inputenc = "auto"; graphicsDriver = "default"; defaultOutputFormat = "default"; + bibtex_command = "default"; + index_command = "default"; sides = OneSide; columns = 1; listings_params = string(); @@ -531,6 +533,12 @@ readGraphicsDriver(lex); } else if (token == "\\default_output_format") { lex >> defaultOutputFormat; + } else if (token == "\\bibtex_command") { + lex.eatLine(); + bibtex_command = lex.getString(); + } else if (token == "\\index_command") { + lex.eatLine(); + index_command = lex.getString(); } else if (token == "\\font_roman") { lex.eatLine(); fontsRoman = lex.getString(); @@ -813,6 +821,8 @@ } os << "\n\\graphics " << graphicsDriver << '\n'; os << "\\default_output_format " << defaultOutputFormat << '\n'; + os << "\\bibtex_command " << bibtex_command << '\n'; + os << "\\index_command " << index_command << '\n'; if (!float_placement.empty()) { os << "\\float_placement " << float_placement << '\n'; Index: lib/lyx2lyx/lyx_2_0.py =================================================================== --- lib/lyx2lyx/lyx_2_0.py (Revision 29760) +++ lib/lyx2lyx/lyx_2_0.py (Arbeitskopie) @@ -630,6 +630,7 @@ return del document.body[i] + def revert_ulinelatex(document): " Reverts \\uline character style " i = find_token(document.body, '\\bar under', 0) @@ -645,6 +646,20 @@ + '\\renewcommand{\\underbar}[1]{{\\let\\cite...@xcite\\uline{#1}}}\n') +def revert_custom_processors(document): + " Remove bibtex_command and index_command params " + i = find_token(document.header, '\\bibtex_command', 0) + if i == -1: + document.warning("Malformed LyX document: Missing \\bibtex_command.") + return + del document.header[i] + i = find_token(document.header, '\\index_command', 0) + if i == -1: + document.warning("Malformed LyX document: Missing \\index_command.") + return + del document.header[i] + + ## # Conversion hub # @@ -661,10 +676,12 @@ [354, []], [355, []], [356, []], - [357, []] + [357, []], + [358, []] ] -revert = [[356, [revert_ulinelatex]], +revert = [[357, [revert_custom_processors]], + [356, [revert_ulinelatex]], [355, [revert_uulinewave]], [354, [revert_strikeout]], [353, [revert_printindexall]], Index: development/FORMAT =================================================================== --- development/FORMAT (Revision 29760) +++ development/FORMAT (Arbeitskopie) @@ -1,13 +1,17 @@ LyX file-format changes ----------------------- -2009-05-05 Pavel Sanda, Enrico Forestieri - * Format incremented to 357: Change of the latex output for underline - from \underbar to ulem's \uline. +2009-04-26 Jürgen Spitzmüller <sp...@lyx.org> + * Format incremented to 358: support for custom bibtex and + makeindex commands. +2009-05-05 Pavel Sanda <sa...@lyx.org>, Enrico Forestieri <for...@lyx.org> + * Format incremented to 357: Change of the latex output for + underline from \underbar to ulem's \uline. + 2009-05-05 Pavel Sanda <sa...@lyx.org> - * Format incremented to 356: support for double and wave underline character - styles via ulem's \uuline and \uwave + * Format incremented to 356: support for double and wave underline + character styles via ulem's \uuline and \uwave 2009-05-03 Pavel Sanda <sa...@lyx.org> * Format incremented to 355: support for strikeout character @@ -25,7 +29,8 @@ * Format incremented to 352: splitindex support. 2009-04-11 Uwe Stöhr <uwesto...@web.de> - * Format incremented to 351: support to set a page background color. + * Format incremented to 351: support to set a page background + color. 2009-04-06 Jürgen Spitzmüller <sp...@lyx.org> * Format incremented to 350: new param \default_output_format.