Am Freitag, 19. Mai 2006 18:19 schrieb Bo Peng: > > I thought about doing that at first. Then I read checkProg in > > configure.py and decided I'd rather not touch it. I am not brave > > enough.
python is friendly to its users, don't fear ;-) > I have not checked the details, but my 'final patch' did just that. > Change '' to 'none', add things like 'auto'. Here is a variant of it. Your patch still did the windows/non-windows distinction that we don't want. Bo, can you please test whether it works? Jean-Marc, can it go in 1.5 and 1.4 if it works? Georg Log: Change the semantics of 'none' and 'auto' viewers/editors: 'none' means now "Don't view/edit this format", and 'auto' means "Use the default viewer/editor". * src/format.C (fixCommand): Change semantics: "none" is equal to "", and "auto" is removed if canAutoOpenFile returns false. * lib/doc/Customization.lyx: Document the autoopen feature * lib/configure.py (checkProg): add optional not_found argument, defaulting to 'none' (checkFormatEntries): call checkProg with not_found = 'auto'
Index: src/format.C =================================================================== --- src/format.C (Revision 13887) +++ src/format.C (Arbeitskopie) @@ -168,15 +168,15 @@ string fixCommand(string const & cmd, st os::auto_open_mode mode) { // configure.py says we do not want a viewer/editor - if (cmd.empty()) - return cmd; + if (cmd.empty() || token(cmd, ' ', 0) == "none") + return string(); // Does the OS manage this format? if (os::canAutoOpenFile(ext, mode)) return "auto"; // if configure.py found nothing, clear the command - if (token(cmd, ' ', 0) == "none") + if (token(cmd, ' ', 0) == "auto") return string(); // use the command found by configure.py Index: lib/doc/Customization.lyx =================================================================== --- lib/doc/Customization.lyx (Revision 13887) +++ lib/doc/Customization.lyx (Arbeitskopie) @@ -1794,6 +1794,25 @@ odify \end_layout \begin_layout Standard +If the operating system has a default viewer associated to a format it is + used instead of the one you can define via the +\family sans +\bar under +T +\bar default +ools\SpecialChar \menuseparator + +\bar under +P +\bar default +references:Conversion +\family default + dialog. + This does currently only work in the Windows® port of LyX, but it is planned + to implement this feature on all other ports that can support it, too. +\end_layout + +\begin_layout Standard Editors are like viewers: Each Format can have an Editor associated to it, and they can be altered via the \family sans Index: lib/configure.py =================================================================== --- lib/configure.py (Revision 13887) +++ lib/configure.py (Arbeitskopie) @@ -111,7 +111,7 @@ def checkCygwinPath(srcdir): ## Searching some useful programs -def checkProg(description, progs, rc_entry = [], path = [] ): +def checkProg(description, progs, rc_entry = [], path = [], not_found = 'none'): ''' This function will search a program in $PATH plus given path If found, return directory and program name (not the options). @@ -127,12 +127,15 @@ def checkProg(description, progs, rc_ent rc_entry: entry to outfile, can be 1. emtpy: no rc entry will be added 2. one pattern: %% will be replaced by the first found program, - or 'none' is no program is found. + or 'none' if no program is found. 3. several patterns for each prog and 'none'. This is used when different programs have different usages. If you do not want 'none' entry to be added to the RC file, you can specify an entry for each prog and use '' for the 'none' entry. + not_found: the value that should be used instead of 'none' if no program + was found + ''' # one rc entry for each progs plus none entry if len(rc_entry) > 1 and len(rc_entry) != len(progs) + 1: @@ -161,8 +164,8 @@ def checkProg(description, progs, rc_ent print ' no' # write rc entries for 'not found' if len(rc_entry) > 0: # the last one. - addToRC(rc_entry[-1].replace('%%', 'none')) - return ['', 'none'] + addToRC(rc_entry[-1].replace('%%', not_found)) + return ['', not_found] def checkLatex(): @@ -193,20 +196,24 @@ def checkLatex(): def checkFormatEntries(): ''' Check all formats (\Format entries) ''' - checkProg('a Tgif viewer and editor', ['tgif'], - rc_entry = [ r'\Format tgif obj Tgif "" "%%" "%%" ""']) + checkProg('a Tif viewer and editor', ['tgif'], + rc_entry = [r'\Format tgif obj Tgif "" "%%" "%%" ""'], + not_found = 'auto') # checkProg('a FIG viewer and editor', ['xfig'], - rc_entry = [ r'\Format fig fig FIG "" "%%" "%%" ""'] ) + rc_entry = [r'\Format fig fig FIG "" "%%" "%%" ""'], + not_found = 'auto') # checkProg('a Grace viewer and editor', ['xmgrace'], - rc_entry = [ r'\Format agr agr Grace "" "%%" "%%" ""'] ) + rc_entry = [r'\Format agr agr Grace "" "%%" "%%" ""'], + not_found = 'auto') # checkProg('a FEN viewer and editor', ['xboard -lpf $$i -mode EditPosition'], - rc_entry = [ r'\Format fen fen FEN "" "%%" "%%" ""' ]) + rc_entry = [r'\Format fen fen FEN "" "%%" "%%" ""'], + not_found = 'auto') # - path, iv = checkProg('a raster image viewer', ['xv', 'kview', 'gimp']) - path, ie = checkProg('a raster image editor', ['gimp']) + path, iv = checkProg('a raster image viewer', ['xv', 'kview', 'gimp'], not_found = 'auto') + path, ie = checkProg('a raster image editor', ['gimp'], not_found = 'auto') addToRC(r'''\Format bmp bmp BMP "" "%s" "%s" "" \Format gif gif GIF "" "%s" "%s" "" \Format jpg jpg JPEG "" "%s" "%s" "" @@ -221,7 +228,7 @@ def checkFormatEntries(): # checkProg('a text editor', ['xemacs', 'gvim', 'kedit', 'kwrite', 'kate', \ 'nedit', 'gedit', 'notepad'], - rc_entry = [ r'''\Format asciichess asc "Plain text (chess output)" "" "" "%%" "" + rc_entry = [r'''\Format asciichess asc "Plain text (chess output)" "" "" "%%" "" \Format asciiimage asc "Plain text (image)" "" "" "%%" "" \Format asciixfig asc "Plain text (Xfig output)" "" "" "%%" "" \Format dateout tmp "date (output)" "" "" "%%" "" @@ -232,25 +239,30 @@ def checkFormatEntries(): \Format linuxdoc sgml LinuxDoc x "" "%%" "document" \Format pdflatex tex "LaTeX (pdflatex)" "" "" "%%" "document" \Format text txt "Plain text" a "" "%%" "document" -\Format textparagraph txt "Plain text (paragraphs)" "" "" "%%" "document"''' ]) +\Format textparagraph txt "Plain text (paragraphs)" "" "" "%%" "document"''' ], + not_found = 'auto') # #checkProg('a Postscript interpreter', ['gs'], # rc_entry = [ r'\ps_command "%%"' ]) checkProg('a Postscript previewer', ['gv', 'ghostview -swap', 'kghostview'], - rc_entry = [ r'''\Format eps eps EPS "" "%%" "" "" -\Format ps ps Postscript t "%%" "" "document"''' ]) + rc_entry = [r'''\Format eps eps EPS "" "%%" "" "" +\Format ps ps Postscript t "%%" "" "document"'''], + not_found = 'auto') # checkProg('a PDF previewer', ['acrobat', 'acroread', 'gv', 'ghostview', \ 'xpdf', 'kpdf', 'kghostview'], - rc_entry = [ r'''\Format pdf pdf "PDF (ps2pdf)" P "%%" "" "document" + rc_entry = [r'''\Format pdf pdf "PDF (ps2pdf)" P "%%" "" "document" \Format pdf2 pdf "PDF (pdflatex)" F "%%" "" "document" -\Format pdf3 pdf "PDF (dvipdfm)" m "%%" "" "document"''' ]) +\Format pdf3 pdf "PDF (dvipdfm)" m "%%" "" "document"'''], + not_found = 'auto') # checkProg('a DVI previewer', ['xdvi', 'kdvi'], - rc_entry = [ r'\Format dvi dvi DVI D "%%" "" "document"' ]) + rc_entry = [r'\Format dvi dvi DVI D "%%" "" "document"'], + not_found = 'auto') # checkProg('a HTML previewer', ['mozilla file://$$p$$i', 'netscape'], - rc_entry = [ r'\Format html html HTML H "%%" "" "document"' ]) + rc_entry = [r'\Format html html HTML H "%%" "" "document"'], + not_found = 'auto') # # entried that do not need checkProg addToRC(r'''\Format date "" "date command" "" "" "" ""