>>>>> "Georg" == Georg Baum <[EMAIL PROTECTED]> writes:

Georg> Here are my solutions: config.diff follows the idea suggested
Georg> by Jean-Marc: Test for the nomencl version in chkconfig.ltx and
Georg> put either "nomencl" or "nomencl" and "oldnomencl" to the
Georg> packages.list file. Then the availability of "oldnomencl" is
Georg> tested to determine the version, define the needed commands in
Georg> the preamble and use the correct invocations of makeindex. The
Georg> advantage of this solution is that there are no checks in the
Georg> document. The disadvantage is that you need to reconfigure if
Georg> the nomencl version changes.

Since you have to define the extra nomenclature functions anyway, what
about using your doc.diff version, but with the following preamble:

\usepackage{nomencl}
% the following is useful when we have the old nomencl.sty package
\providecommand{\printnomenclature}{\printglossary}
\providecommand{\makenomenclature}{\makeglossary}
\makenomenclature

Georg> Which solution should go in? Note that I did not handle the
Georg> case when nomencl is not installed, and I don't intend to do
Georg> that.

I prefer the doc version, because the tests in tex seem to be
error prone to me.

What about the following updated version? Only the LaTeXFeatures part
has been changed.

Then the is the problem of glossary versus nomenclature. At least my
version of nomencl.sty writes a helpful "Nomenclature" heading in
front of my glossary. This is stupid.

JMarc

Index: src/LaTeXFeatures.C
===================================================================
--- src/LaTeXFeatures.C	(révision 17918)
+++ src/LaTeXFeatures.C	(copie de travail)
@@ -404,8 +404,13 @@ string const LaTeXFeatures::getPackages(
 		packages << "\\usepackage[all]{xy}\n";
 
 	if (mustProvide("nomencl")) {
-		packages << "\\usepackage{nomencl}[2005/09/22]\n"
-			 << "\\makenomenclature\n";
+		// Make it work with the new and old version of the package,
+		// but don't use the compatibilty option since it is
+		// incompatible to other packages.
+		packages << "\\usepackage{nomencl}\n"
+	                    "\\providecommand{\\printnomenclature}{\\printglossary}\n"
+	                    "\\providecommand{\\makenomenclature}{\\makeglossary}\n"
+		            "\\makenomenclature\n";
 	}
  
 	return packages.str();
Index: src/LaTeX.C
===================================================================
--- src/LaTeX.C	(révision 17918)
+++ src/LaTeX.C	(copie de travail)
@@ -168,6 +168,10 @@ void LaTeX::deleteFilesOnError() const
 	FileName const nls(changeExtension(file.absFilename(), ".nls"));
 	unlink(nls);
 
+	// nomencl file (old version of the package)
+	FileName const gls(changeExtension(file.absFilename(), ".gls"));
+	unlink(gls);
+
 	// Also remove the aux file
 	FileName const aux(changeExtension(file.absFilename(), ".aux"));
 	unlink(aux);
@@ -300,20 +304,12 @@ int LaTeX::run(TeXErrors & terr)
 		rerun |= runMakeIndex(onlyFilename(idxfile.absFilename()),
 				runparams);
 	}
-	if (head.haschanged(FileName(changeExtension(file.absFilename(), ".nlo")))) {
-		LYXERR(Debug::LATEX) 
-			<< "Running MakeIndex for nomencl."
-			<< endl;
-		message(_("Running MakeIndex for nomencl."));
-		// onlyFilename() is needed for cygwin
-		string const nomenclstr = " -s nomencl.ist -o " 
-			+ onlyFilename(changeExtension(
-				file.toFilesystemEncoding(), ".nls"));
-		rerun |= runMakeIndex(onlyFilename(changeExtension(
-				file.absFilename(), ".nlo")),
-				runparams,
-				nomenclstr);
-	}
+	FileName const nlofile(changeExtension(file.absFilename(), ".nlo"));
+	if (head.haschanged(nlofile))
+		rerun |= runMakeIndexNomencl(file, runparams, ".nlo", ".nls");
+	FileName const glofile(changeExtension(file.absFilename(), ".glo"));
+	if (head.haschanged(glofile))
+		rerun |= runMakeIndexNomencl(file, runparams, ".glo", ".gls");
 
 	// run bibtex
 	// if (scanres & UNDEF_CIT || scanres & RERUN || run_bibtex)
@@ -379,7 +375,7 @@ int LaTeX::run(TeXErrors & terr)
 	// more after this.
 
 	// run makeindex if the <file>.idx has changed or was generated.
-	if (head.haschanged(FileName(changeExtension(file.absFilename(), ".idx")))) {
+	if (head.haschanged(idxfile)) {
 		// no checks for now
 		LYXERR(Debug::LATEX) << "Running MakeIndex." << endl;
 		message(_("Running MakeIndex."));
@@ -389,20 +385,10 @@ int LaTeX::run(TeXErrors & terr)
 	}
 
 	// I am not pretty sure if need this twice.
-	if (head.haschanged(FileName(changeExtension(file.absFilename(), ".nlo")))) {
-		LYXERR(Debug::LATEX) 
-			<< "Running MakeIndex for nomencl."
-			<< endl;
-		message(_("Running MakeIndex for nomencl."));
-		// onlyFilename() is needed for cygwin
-		string nomenclstr = " -s nomencl.ist -o " 
-			+ onlyFilename(changeExtension(
-				file.toFilesystemEncoding(), ".nls"));
-		rerun |= runMakeIndex(onlyFilename(changeExtension(
-				file.absFilename(), ".nlo")),
-				runparams,
-				nomenclstr);
-	}
+	if (head.haschanged(nlofile))
+		rerun |= runMakeIndexNomencl(file, runparams, ".nlo", ".nls");
+	if (head.haschanged(glofile))
+		rerun |= runMakeIndexNomencl(file, runparams, ".glo", ".gls");
 
 	// 2
 	// we will only run latex more if the log file asks for it.
@@ -468,6 +454,21 @@ bool LaTeX::runMakeIndex(string const & 
 }
 
 
+bool LaTeX::runMakeIndexNomencl(FileName const & file,
+		OutputParams const & runparams,
+		string const & nlo, string const & nls)
+{
+	LYXERR(Debug::LATEX) << "Running MakeIndex for nomencl." << endl;
+	message(_("Running MakeIndex for nomencl."));
+	// onlyFilename() is needed for cygwin
+	string const nomenclstr = " -s nomencl.ist -o "
+		+ onlyFilename(changeExtension(file.toFilesystemEncoding(), nls));
+	return runMakeIndex(
+			onlyFilename(changeExtension(file.absFilename(), nlo)),
+			runparams, nomenclstr);
+}
+
+
 vector<Aux_Info> const
 LaTeX::scanAuxFiles(FileName const & file)
 {
@@ -862,7 +863,9 @@ bool handleFoundFile(string const & ff, 
 	//     insert it into head
 	if (exists(absname) &&
 	    !fs::is_directory(absname.toFilesystemEncoding())) {
-		static regex unwanted("^.*\\.(aux|log|dvi|bbl|ind|glo)$");
+		// FIXME: This regex contained glo, but glo is used by the old
+		// version of nomencl.sty. Do we need to put it back?
+		static regex unwanted("^.*\\.(aux|log|dvi|bbl|ind)$");
 		if (regex_match(onlyfile, unwanted)) {
 			LYXERR(Debug::DEPEND)
 				<< "We don't want "
@@ -927,6 +930,7 @@ void LaTeX::deplog(DepTable & head)
 	static regex reg4("Writing index file (.+).*");
 	// files also can be enclosed in <...>
 	static regex reg5("<([^>]+)(.).*");
+	static regex regoldnomencl("Writing glossary file (.+).*");
 	static regex regnomencl("Writing nomenclature file (.+).*");
 	// If a toc should be created, MikTex does not write a line like
 	//    \openout# = `sample.toc'.
@@ -1030,7 +1034,8 @@ void LaTeX::deplog(DepTable & head)
 				// probable line break
 				found_file = false;
 		// (6) "Writing nomenclature file file.ext"
-		} else if (regex_match(token, sub, regnomencl))
+		} else if (regex_match(token, sub, regnomencl) ||
+		           regex_match(token, sub, regoldnomencl))
 			// check for dot
 			found_file = checkLineBreak(sub.str(1), head);
 		// (7) "[EMAIL PROTECTED]<nr>" (for MikTeX)
Index: src/LaTeX.h
===================================================================
--- src/LaTeX.h	(révision 17918)
+++ src/LaTeX.h	(copie de travail)
@@ -172,6 +172,10 @@ private:
 	                  std::string const & = std::string());
 
 	///
+	bool runMakeIndexNomencl(support::FileName const &, OutputParams const &,
+	                         std::string const &, std::string const &);
+
+	///
 	std::vector<Aux_Info> const scanAuxFiles(support::FileName const &);
 
 	///

Reply via email to