>>>>> "Jean-Marc" == Jean-Marc Lasgouttes <[EMAIL PROTECTED]> writes:

Jean-Marc> This small patch (which is just a proof of concept) tests
Jean-Marc> whether a TeX installation accepts spaces in file names.

This new patch adds the lyxrc support for the variables. There is not
preference UI, and I do not intend to provide one.

I would be interested to know whether this patch works at all. It is
supposed to help when files are in directories with spaces in their
name. 

I guess some tweaks are needed to support more cases, but basically,
it should solve the problem of typesetting documentation in LyX/Win.

This is a 1.3.x patch, which I intend to port later.

Comments welcome.

JMarc

Index: lib/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/lib/ChangeLog,v
retrieving revision 1.363.2.100
diff -u -p -r1.363.2.100 ChangeLog
--- lib/ChangeLog	7 Mar 2005 13:53:19 -0000	1.363.2.100
+++ lib/ChangeLog	10 Mar 2005 14:50:39 -0000
@@ -1,3 +1,8 @@
+2005-03-10  Jean-Marc Lasgouttes  <[EMAIL PROTECTED]>
+
+	* configure.m4: add a check to see whether TeX allows spaces in
+	file names. Probably requires web2c 7.5.3 to be supported.
+
 2005-02-26  Michael Schmitt  <[EMAIL PROTECTED]>
 
 	* ui/default.ui: change "BibTeX Reference..." to "BibTeX Bibliography...";
Index: lib/configure.m4
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/lib/configure.m4,v
retrieving revision 1.60.2.16
diff -u -p -r1.60.2.16 configure.m4
--- lib/configure.m4	17 Feb 2005 13:20:55 -0000	1.60.2.16
+++ lib/configure.m4	10 Mar 2005 14:50:39 -0000
@@ -496,6 +496,26 @@ echo "s/@chk_linuxdoc@/$chk_linuxdoc/g" 
 echo "s/@chk_docbook@/$chk_docbook/g" >> chkconfig.sed
 sed -f chkconfig.sed "${srcdir}"/doc/LaTeXConfig.lyx.in >doc/LaTeXConfig.lyx
 
+### Let's check whether spaces are allowed in TeX file names
+MSG_CHECKING(whether TeX allows spaces in file names)
+if test ${lyx_check_config} = no ; then
+  tex_allows_spaces=false
+else
+  fname="a b"
+  rm -f "$fname".tex
+  echo "\\message{working!^^J}" >"$fname".tex
+changequote([,])dnl
+  if [eval] ${LATEX} "$fname" </dev/null | grep 'working!' ; then
+    MSG_RESULT(yes)
+    tex_allows_spaces=true
+  else
+    MSG_RESULT(no)
+    tex_allows_spaces=false
+  fi
+  rm -r "$fname".*
+changequote(,)dnl  
+fi
+
 echo "creating $outfile"
 cat >$outfile <<EOF
 # This file has been automatically generated by LyX' lib/configure
@@ -565,6 +585,7 @@ cat >$outfile <<EOF
 
 $rc_entries
 \\font_encoding "$chk_fontenc"
+\\tex_allows_spaces $tex_allows_spaces
 EOF
 
 if [ "x$use_cygwin_path_fix" != "x" ]
Index: src/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/ChangeLog,v
retrieving revision 1.1021.2.70
diff -u -p -r1.1021.2.70 ChangeLog
--- src/ChangeLog	24 Feb 2005 11:47:30 -0000	1.1021.2.70
+++ src/ChangeLog	10 Mar 2005 14:50:40 -0000
@@ -1,3 +1,14 @@
+2005-03-10  Jean-Marc Lasgouttes  <[EMAIL PROTECTED]>
+
+	* lyxrc.C (setDefaults, read, output): add support for
+	tex_allows_spaces. 
+
+	* exporter.C (Export): allows files in directory containing spaces
+	if tex_allows_spaces is true.
+
+	* buffer.C (makeLaTeXFile): if the document path contains spaces,
+	output it in double quotes.
+
 2005-02-23  Angus Leeming  <[EMAIL PROTECTED]>
 
 	* commandtags.h:
Index: src/buffer.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/buffer.C,v
retrieving revision 1.399.2.14
diff -u -p -r1.399.2.14 buffer.C
--- src/buffer.C	28 Jan 2005 15:12:55 -0000	1.399.2.14
+++ src/buffer.C	10 Mar 2005 14:50:40 -0000
@@ -1744,6 +1744,8 @@ void Buffer::makeLaTeXFile(ostream & os,
 		if (!original_path.empty()) {
 			string inputpath = os::external_path(original_path);
 			subst(inputpath, "~", "\\string~");
+			if (inputpath.find(' ') != string::npos)
+				inputpath = '"' + inputpath + '"';
 			os << "\\makeatletter\n"
 			    << "[EMAIL PROTECTED]"
 			    << inputpath << "/}}\n"
Index: src/exporter.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/exporter.C,v
retrieving revision 1.25.2.3
diff -u -p -r1.25.2.3 exporter.C
--- src/exporter.C	7 Dec 2004 10:48:22 -0000	1.25.2.3
+++ src/exporter.C	10 Mar 2005 14:50:40 -0000
@@ -83,7 +83,8 @@ bool Exporter::Export(Buffer * buffer, s
 	// LaTeX backend
 	else if (backend_format == format)
 		buffer->makeLaTeXFile(filename, string(), true);
-	else if (contains(buffer->filePath(), ' ')) {
+	else if (!lyxrc.tex_allows_spaces 
+		 && contains(buffer->filePath(), ' ')) {
 		Alert::alert(_("Cannot run LaTeX."),
 			   _("The path to the lyx file cannot contain spaces."));
 		return false;
Index: src/lyxrc.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxrc.C,v
retrieving revision 1.139.2.3
diff -u -p -r1.139.2.3 lyxrc.C
--- src/lyxrc.C	1 Feb 2005 22:41:28 -0000	1.139.2.3
+++ src/lyxrc.C	10 Mar 2005 14:50:40 -0000
@@ -138,6 +138,7 @@ keyword_item lyxrcTags[] = {
 	{ "\\spell_command", LyXRC::RC_SPELL_COMMAND },
 	{ "\\tempdir_path", LyXRC::RC_TEMPDIRPATH },
 	{ "\\template_path", LyXRC::RC_TEMPLATEPATH },
+	{ "\\tex_allows_spaces", LyXRC::RC_TEX_ALLOWS_SPACES },
 	{ "\\ui_file", LyXRC::RC_UIFILE },
 	{ "\\use_alt_language", LyXRC::RC_USE_ALT_LANG },
 	{ "\\use_escape_chars", LyXRC::RC_USE_ESC_CHARS },
@@ -250,6 +251,7 @@ void LyXRC::setDefaults() {
 	default_language = "english";
 	show_banner = true;
 	cygwin_path_fix = false;
+	tex_allows_spaces = false;
 	date_insert_format = "%A, %e %B %Y";
 	cursor_follows_scrollbar = false;
 	dialogs_iconify_with_main = false;
@@ -387,6 +389,12 @@ int LyXRC::read(string const & filename)
  			}
  			break;
  
+		case RC_TEX_ALLOWS_SPACES:
+			if (lexrc.next()) {
+				tex_allows_spaces = lexrc.getBool();
+ 			}
+ 			break;
+ 
 		case RC_KBMAP_PRIMARY:
 			if (lexrc.next()) {
 				string const kmap(lexrc.getString());
@@ -1257,6 +1265,11 @@ void LyXRC::output(ostream & os) const
 		if (cygwin_path_fix != system_lyxrc.cygwin_path_fix) {
 			os << "\\cygwin_path_fix_needed "
 			   << tostr(cygwin_path_fix) << '\n';
+  		}
+	case RC_TEX_ALLOWS_SPACES:
+		if (tex_allows_spaces != system_lyxrc.tex_allows_spaces) {
+			os << "\\tex_allows_spaces "
+			   << tostr(tex_allows_spaces) << '\n';
   		}
 	case RC_KBMAP_PRIMARY:
 		if (primary_kbmap != system_lyxrc.primary_kbmap) {
Index: src/lyxrc.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxrc.h,v
retrieving revision 1.69.2.2
diff -u -p -r1.69.2.2 lyxrc.h
--- src/lyxrc.h	28 Jan 2005 15:12:56 -0000	1.69.2.2
+++ src/lyxrc.h	10 Mar 2005 14:50:40 -0000
@@ -124,6 +124,7 @@ enum LyXRCTags {
 	RC_USE_PSPELL,
 #endif
  	RC_CYGWIN_PATH_FIX,
+	RC_TEX_ALLOWS_SPACES,
 	RC_PATH_PREFIX,
 	RC_LAST
 };
@@ -357,6 +358,8 @@ enum LyXRCTags {
 	float preview_scale_factor;
 	///
 	bool cygwin_path_fix;
+	/// True if the TeX engine can handle file names containing spaces
+	bool tex_allows_spaces;
 	/** Prepend paths to the PATH environment variable.
 	 *  The string is input, stored and output in native format.
 	 */

Reply via email to