Dear list,

Lars may really start to hate me now. Here is another patch.

It compares the date of $HOME/.lyx/textclass.lst and
$HOME/.lyx/layouts. If layouts is newer, run a partial reconfiguration
of only latex settings.

Verified to work on my system. Namely, if I add/remove layout files
from $HOME/.lyx/layouts, lyx will re-configure automatically, and show
correct entries in classlist.

Like it or not, here it comes. :-)
Bo
Index: src/lyxtextclasslist.C
===================================================================
--- src/lyxtextclasslist.C	(revision 9662)
+++ src/lyxtextclasslist.C	(working copy)
@@ -17,11 +17,22 @@
 #include "lyxlex.h"
 
 #include "support/filetools.h"
+#include "support/package.h"
+#include "support/systemcall.h"
+#include "support/path.h"
 
 #include <boost/bind.hpp>
+#include <boost/filesystem/operations.hpp>
+namespace fs = boost::filesystem;
 
 using lyx::textclass_type;
 
+using lyx::support::AddPath;
+using lyx::support::AddName;
+using lyx::support::QuoteName;
+using lyx::support::Systemcall;
+using lyx::support::Path;
+using lyx::support::package;
 using lyx::support::LibFileSearch;
 using lyx::support::MakeDisplayPath;
 
@@ -107,6 +118,19 @@
 		// compiled in... (Lgb)
 	}
 
+	// if textclass.lst is older than the user layout folder,
+	string layout_dir = AddPath(package().user_support(), "layouts");
+	if (fs::last_write_time(real_file) < fs::last_write_time(layout_dir)) {
+		// run configure.py --check-new-layout in user lyx directory
+		Path p(package().user_support());
+		string const configure_script =
+			AddName(package().system_support(), "configure.py");
+		string const configure_command = "python " + QuoteName(configure_script) + " --check-new-layout";
+		Systemcall one;
+		one.startscript(Systemcall::Wait, configure_command);
+		p.pop();
+	}
+
 	if (!lex.setFile(real_file)) {
 		lyxerr << "LyXTextClassList::Read: "
 			"lyxlex was not able to set file: "
Index: lib/configure.py
===================================================================
--- lib/configure.py	(revision 9662)
+++ lib/configure.py	(working copy)
@@ -642,6 +643,14 @@
   rc_entries = ''
   lyx_keep_temps = False
   version_suffix = ''
+  # check if we run from the right directory
+  srcdir = os.path.dirname(sys.argv[0])
+  if srcdir == '':
+    srcdir = '.'
+  if not os.path.isfile( os.path.join(srcdir, 'chkconfig.ltx') ):
+    print "configure: error: cannot find chkconfig.ltx script"
+    sys.exit(1)
+  setEnviron()
   ## Parse the command line
   for op in sys.argv[1:]:   # default shell/for list is $*, the options
     if op in [ '-help', '--help', '-h' ]:
@@ -651,6 +660,7 @@
   --keep-temps             keep temporary files (for debug. purposes)
   --without-latex-config   do not run LaTeX to determine configuration
   --with-version-suffix=suffix suffix of binary installed files
+  --check-new-layout       add new layout file in the local layouts folder
 '''
       sys.exit(0)
     elif op == '--without-latex-config':
@@ -659,20 +669,21 @@
       lyx_keep_temps = True
     elif op[0:22] == '--with-version-suffix=':  # never mind if op is not long enough
       version_suffix = op[22:]
+    elif op == '--check-new-layout':
+      # currently, this option checks all latex settings.
+      # I would really like to check only new layout, as option name suggests.
+      LATEX = checkLatex()
+      (chk_linuxdoc, bool_linuxdoc, linuxdoc_cmd) = checkLinuxDoc()
+      (chk_docbook, bool_docbook, docbook_cmd) = checkDocBook()
+      checkLatexConfig( LATEX != '', bool_docbook, bool_linuxdoc)
+      createLaTeXConfig()
+      sys.exit(0)
     else:
       print "Unknown option", op
       sys.exit(1)
   #    
-  # check if we run from the right directory
-  srcdir = os.path.dirname(sys.argv[0])
-  if srcdir == '':
-    srcdir = '.'
-  if not os.path.isfile( os.path.join(srcdir, 'chkconfig.ltx') ):
-    print "configure: error: cannot find chkconfig.ltx script"
-    sys.exit(1)
-  setEnviron()
   createDirectories()

Reply via email to