The attached patch solves the problem:

* When running on Windows, configure.py will not detect viewers and let Windows handle it (write 'auto'). When an external application handles auto-detection, a viewer entry can be added.

* Auto-detection inside LyX will use the OS viewer when configure.py has returned 'auto'. Again this is always the case on Windows except some special application handles auto-detection.

* It makes configuration faster because configure.py does not attempt to detect UNIX applications on Windows.

Comments? If this is acceptable, I will write a "pdfview" application to improve PDF viewing on Windows.

Joost
Index: lib/configure.py
===================================================================
--- lib/configure.py    (revision 15338)
+++ lib/configure.py    (working copy)
@@ -176,7 +176,14 @@
 
 def checkViewer(description, progs, rc_entry = [], path = []):
     ''' The same as checkProg, but for viewers and editors '''
-    return checkProg(description, progs, rc_entry, path, not_found = 'auto')
+    if (os.name == 'nt'):
+        # We don't need to detect viewers on Windows, let auto detection 
handle it
+        if len(rc_entry) > 0:  # the last one.
+            addToRC(rc_entry[-1].replace('%%', 'auto'))
+        return ['', 'auto']
+    else:
+        # Detect viewers for UNIX / Cygwin
+        return checkProg(description, progs, rc_entry, path, not_found = 
'auto')
 
 
 def checkLatex():
@@ -242,7 +249,7 @@
         (iv, ie, iv, ie, iv, ie, iv, ie, iv, ie, iv, ie, iv, ie, iv, ie, iv, 
ie, iv, ie) )
     #
     checkViewer('a text editor', ['xemacs', 'gvim', 'kedit', 'kwrite', 'kate', 
\
-        'nedit', 'gedit', 'notepad'],
+        'nedit', 'gedit'],
         rc_entry = [r'''\Format asciichess asc    "Plain text (chess output)"  
"" ""   "%%"
 \Format asciiimage asc    "Plain text (image)"         "" ""   "%%"
 \Format asciixfig  asc    "Plain text (Xfig output)"   "" ""   "%%"
@@ -263,9 +270,16 @@
         rc_entry = [r'''\Format eps        eps     EPS                    "" 
"%%"      ""
 \Format ps         ps      Postscript             t  "%%"      ""'''])
     #
-    checkViewer('a PDF previewer', ['acrobat', 'acroread', 'gv', 'ghostview', \
-                            'xpdf', 'kpdf', 'kghostview'],
-        rc_entry = [r'''\Format pdf        pdf    "PDF (ps2pdf)"          P  
"%%"      ""
+    if ((os.name == 'nt') and checkProg('PDF viewer', ['pdfview']) != ['', 
'']):
+        # Windows only: PDF viewer with auto-detection and a solution for file 
locking
+        addToRC(r'''\Format pdf        pdf    "PDF (ps2pdf)"          P  
"pdfview"     ""
+\Format pdf2       pdf    "PDF (pdflatex)"        F  "pdfview" ""
+\Format pdf3       pdf    "PDF (dvipdfm)"         m  "pdfview" ""''')
+    else:
+        #
+        checkViewer('a PDF previewer', ['acrobat', 'acroread', 'gv', 
'ghostview', \
+            'xpdf', 'kpdf', 'kghostview'],
+            rc_entry = [r'''\Format pdf        pdf    "PDF (ps2pdf)"          
P  "%%"  ""
 \Format pdf2       pdf    "PDF (pdflatex)"        F  "%%"      ""
 \Format pdf3       pdf    "PDF (dvipdfm)"         m  "%%"      ""'''])
     #
Index: src/format.C
===================================================================
--- src/format.C        (revision 15338)
+++ src/format.C        (working copy)
@@ -168,14 +168,17 @@
        if (cmd.empty() || cmd == "none")
                return string();
 
-       // Does the OS manage this format?
-       if (os::canAutoOpenFile(ext, mode))
-               return "auto";
+       // if configure.py found nothing, let the OS manage it
+       if (token(cmd, ' ', 0) == "auto") {
+               if (os::canAutoOpenFile(ext, mode)) {
+                       // the OS has a viewer
+                       return "auto";
+               } else {
+                       // we don't have a viewer
+                       return string();
+               }
+       }
 
-       // if configure.py found nothing, clear the command
-       if (token(cmd, ' ', 0) == "auto")
-               return string();
-
        // use the command found by configure.py
        return cmd;
 }

Reply via email to