]> git.lyx.org Git - lyx.git/blob - src/LyXRC.cpp
Enhance LyX by fixing #6760. New preference to set minimum length of
[lyx.git] / src / LyXRC.cpp
1 /**
2  * \file LyXRC.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Lars Gullik Bjønnes
7  * \author Jean-Marc Lasgouttes
8  * \author Angus Leeming
9  * \author John Levon
10  * \author André Pönitz
11  * \author Allan Rae
12  * \author Dekel Tsur
13  *
14  * Full author contact details are available in file CREDITS.
15  */
16
17 #include <config.h>
18
19 #include "LyXRC.h"
20
21 #include "ColorSet.h"
22 #include "Converter.h"
23 #include "FontEnums.h"
24 #include "Format.h"
25 #include "Lexer.h"
26 #include "LyX.h"
27 #include "Mover.h"
28 #include "Session.h"
29 #include "version.h"
30
31 #include "graphics/GraphicsTypes.h"
32
33 #include "support/convert.h"
34 #include "support/debug.h"
35 #include "support/environment.h"
36 #include "support/FileName.h"
37 #include "support/filetools.h"
38 #include "support/gettext.h"
39 #include "support/lstrings.h"
40 #include "support/os.h"
41 #include "support/Package.h"
42 #include "support/userinfo.h"
43
44 #include <fstream>
45 #include <iostream>
46 #include <algorithm>
47
48 using namespace std;
49 using namespace lyx::support;
50
51 namespace lyx {
52
53 namespace os = support::os;
54
55 namespace {
56
57 // when adding something to this array keep it sorted!
58 LexerKeyword lyxrcTags[] = {
59         { "\\accept_compound", LyXRC::RC_ACCEPT_COMPOUND },
60         { "\\allow_geometry_session", LyXRC::RC_GEOMETRY_SESSION },
61         { "\\alternate_language", LyXRC::RC_ALT_LANG },
62         { "\\auto_number", LyXRC::RC_AUTO_NUMBER },
63         { "\\auto_region_delete", LyXRC::RC_AUTOREGIONDELETE },
64         { "\\auto_reset_options", LyXRC::RC_AUTORESET_OPTIONS },
65         { "\\autocorrection_math", LyXRC::RC_AUTOCORRECTION_MATH },
66         { "\\autosave", LyXRC::RC_AUTOSAVE },
67         { "\\backupdir_path", LyXRC::RC_BACKUPDIR_PATH },
68         { "\\bibtex_alternatives", LyXRC::RC_BIBTEX_ALTERNATIVES },
69         { "\\bibtex_command", LyXRC::RC_BIBTEX_COMMAND },
70         { "\\bind_file", LyXRC::RC_BINDFILE },
71         { "\\check_lastfiles", LyXRC::RC_CHECKLASTFILES },
72         { "\\chktex_command", LyXRC::RC_CHKTEX_COMMAND },
73         { "\\completion_cursor_text", LyXRC::RC_COMPLETION_CURSOR_TEXT },
74         { "\\completion_inline_delay", LyXRC::RC_COMPLETION_INLINE_DELAY },
75         { "\\completion_inline_dots", LyXRC::RC_COMPLETION_INLINE_DOTS },
76         { "\\completion_inline_math", LyXRC::RC_COMPLETION_INLINE_MATH },
77         { "\\completion_inline_text", LyXRC::RC_COMPLETION_INLINE_TEXT },
78         { "\\completion_popup_after_complete", LyXRC::RC_COMPLETION_POPUP_AFTER_COMPLETE },
79         { "\\completion_popup_delay", LyXRC::RC_COMPLETION_POPUP_DELAY },
80         { "\\completion_popup_math", LyXRC::RC_COMPLETION_POPUP_MATH },
81         { "\\completion_popup_text", LyXRC::RC_COMPLETION_POPUP_TEXT },
82         { "\\converter", LyXRC::RC_CONVERTER },
83         { "\\converter_cache_maxage", LyXRC::RC_CONVERTER_CACHE_MAXAGE },
84         { "\\copier", LyXRC::RC_COPIER },
85         { "\\cursor_follows_scrollbar", LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR },
86         { "\\date_insert_format", LyXRC::RC_DATE_INSERT_FORMAT },
87         { "\\def_file", LyXRC::RC_DEFFILE },
88         { "\\default_decimal_point", LyXRC::RC_DEFAULT_DECIMAL_POINT },
89         { "\\default_language", LyXRC::RC_DEFAULT_LANGUAGE },
90         { "\\default_papersize", LyXRC::RC_DEFAULT_PAPERSIZE },
91         { "\\default_view_format", LyXRC::RC_DEFAULT_VIEW_FORMAT },
92         { "\\dialogs_iconify_with_main", LyXRC::RC_DIALOGS_ICONIFY_WITH_MAIN },
93         { "\\display_graphics", LyXRC::RC_DISPLAY_GRAPHICS },
94         { "\\document_path", LyXRC::RC_DOCUMENTPATH },
95         { "\\editor_alternatives", LyXRC::RC_EDITOR_ALTERNATIVES },
96         { "\\escape_chars", LyXRC::RC_ESC_CHARS },
97         { "\\example_path", LyXRC::RC_EXAMPLEPATH },
98         { "\\export_overwrite", LyXRC::RC_EXPORT_OVERWRITE },
99         { "\\font_encoding", LyXRC::RC_FONT_ENCODING },
100         { "\\format", LyXRC::RC_FORMAT },
101         { "\\forward_search_dvi", LyXRC::RC_FORWARD_SEARCH_DVI },
102         { "\\forward_search_pdf", LyXRC::RC_FORWARD_SEARCH_PDF },
103         { "\\fullscreen_limit", LyXRC::RC_FULL_SCREEN_LIMIT },
104         { "\\fullscreen_menubar", LyXRC::RC_FULL_SCREEN_MENUBAR },
105         { "\\fullscreen_scrollbar", LyXRC::RC_FULL_SCREEN_SCROLLBAR },
106         { "\\fullscreen_tabbar", LyXRC::RC_FULL_SCREEN_TABBAR },
107         { "\\fullscreen_toolbars", LyXRC::RC_FULL_SCREEN_TOOLBARS },
108         { "\\fullscreen_width", LyXRC::RC_FULL_SCREEN_WIDTH },
109         { "\\group_layouts", LyXRC::RC_GROUP_LAYOUTS },
110         { "\\gui_language", LyXRC::RC_GUI_LANGUAGE },
111         { "\\hunspelldir_path", LyXRC::RC_HUNSPELLDIR_PATH },
112         { "\\index_alternatives", LyXRC::RC_INDEX_ALTERNATIVES },
113         { "\\index_command", LyXRC::RC_INDEX_COMMAND },
114         { "\\input", LyXRC::RC_INPUT },
115         { "\\jbibtex_command", LyXRC::RC_JBIBTEX_COMMAND },
116         { "\\jindex_command", LyXRC::RC_JINDEX_COMMAND },
117         { "\\kbmap", LyXRC::RC_KBMAP },
118         { "\\kbmap_primary", LyXRC::RC_KBMAP_PRIMARY },
119         { "\\kbmap_secondary", LyXRC::RC_KBMAP_SECONDARY },
120         { "\\language_auto_begin", LyXRC::RC_LANGUAGE_AUTO_BEGIN },
121         { "\\language_auto_end", LyXRC::RC_LANGUAGE_AUTO_END },
122         { "\\language_command_begin", LyXRC::RC_LANGUAGE_COMMAND_BEGIN },
123         { "\\language_command_end", LyXRC::RC_LANGUAGE_COMMAND_END },
124         { "\\language_command_local", LyXRC::RC_LANGUAGE_COMMAND_LOCAL },
125         { "\\language_global_options", LyXRC::RC_LANGUAGE_GLOBAL_OPTIONS },
126         { "\\language_package", LyXRC::RC_LANGUAGE_PACKAGE },
127         { "\\language_use_babel", LyXRC::RC_LANGUAGE_USE_BABEL },
128         { "\\load_session", LyXRC::RC_LOADSESSION },
129         { "\\mac_like_word_movement", LyXRC::RC_MAC_LIKE_WORD_MOVEMENT },
130         { "\\macro_edit_style", LyXRC::RC_MACRO_EDIT_STYLE },
131         { "\\make_backup", LyXRC::RC_MAKE_BACKUP },
132         { "\\mark_foreign_language", LyXRC::RC_MARK_FOREIGN_LANGUAGE },
133         { "\\mouse_wheel_speed", LyXRC::RC_MOUSE_WHEEL_SPEED },
134         { "\\nomencl_command", LyXRC::RC_NOMENCL_COMMAND },
135         { "\\num_lastfiles", LyXRC::RC_NUMLASTFILES },
136         { "\\open_buffers_in_tabs", LyXRC::RC_OPEN_BUFFERS_IN_TABS },
137         { "\\paragraph_markers", LyXRC::RC_PARAGRAPH_MARKERS },
138         { "\\path_prefix", LyXRC::RC_PATH_PREFIX },
139         { "\\personal_dictionary", LyXRC::RC_PERS_DICT },
140         { "\\plaintext_linelen", LyXRC::RC_PLAINTEXT_LINELEN },
141         { "\\plaintext_roff_command", LyXRC::RC_PLAINTEXT_ROFF_COMMAND },
142         { "\\preview", LyXRC::RC_PREVIEW },
143         { "\\preview_hashed_labels", LyXRC::RC_PREVIEW_HASHED_LABELS },
144         { "\\preview_scale_factor", LyXRC::RC_PREVIEW_SCALE_FACTOR },
145         { "\\print_adapt_output", LyXRC::RC_PRINT_ADAPTOUTPUT },
146         { "\\print_collcopies_flag", LyXRC::RC_PRINTCOLLCOPIESFLAG },
147         { "\\print_command", LyXRC::RC_PRINT_COMMAND },
148         { "\\print_copies_flag", LyXRC::RC_PRINTCOPIESFLAG },
149         { "\\print_evenpage_flag", LyXRC::RC_PRINTEVENPAGEFLAG },
150         { "\\print_extra_options", LyXRC::RC_PRINTEXSTRAOPTIONS },
151         { "\\print_file_extension", LyXRC::RC_PRINTFILEEXTENSION },
152         { "\\print_landscape_flag", LyXRC::RC_PRINTLANDSCAPEFLAG },
153         { "\\print_oddpage_flag", LyXRC::RC_PRINTODDPAGEFLAG },
154         { "\\print_pagerange_flag", LyXRC::RC_PRINTPAGERANGEFLAG },
155         { "\\print_paper_dimension_flag", LyXRC::RC_PRINTPAPERDIMENSIONFLAG },
156         { "\\print_paper_flag", LyXRC::RC_PRINTPAPERFLAG },
157         { "\\print_reverse_flag", LyXRC::RC_PRINTREVERSEFLAG },
158         { "\\print_spool_command", LyXRC::RC_PRINTSPOOL_COMMAND },
159         { "\\print_spool_printerprefix", LyXRC::RC_PRINTSPOOL_PRINTERPREFIX },
160         { "\\print_to_file", LyXRC::RC_PRINTTOFILE },
161         { "\\print_to_printer", LyXRC::RC_PRINTTOPRINTER },
162         { "\\printer", LyXRC::RC_PRINTER },
163         { "\\rtl", LyXRC::RC_RTL_SUPPORT },
164         { "\\save_compressed", LyXRC::RC_SAVE_COMPRESSED },
165         { "\\screen_dpi", LyXRC::RC_SCREEN_DPI },
166         { "\\screen_font_roman", LyXRC::RC_SCREEN_FONT_ROMAN },
167         { "\\screen_font_roman_foundry", LyXRC::RC_SCREEN_FONT_ROMAN_FOUNDRY },
168         { "\\screen_font_sans", LyXRC::RC_SCREEN_FONT_SANS },
169         { "\\screen_font_sans_foundry", LyXRC::RC_SCREEN_FONT_SANS_FOUNDRY },
170         { "\\screen_font_scalable", LyXRC::RC_SCREEN_FONT_SCALABLE },
171         { "\\screen_font_sizes", LyXRC::RC_SCREEN_FONT_SIZES },
172         { "\\screen_font_typewriter", LyXRC::RC_SCREEN_FONT_TYPEWRITER },
173         { "\\screen_font_typewriter_foundry", LyXRC::RC_SCREEN_FONT_TYPEWRITER_FOUNDRY },
174         { "\\screen_zoom", LyXRC::RC_SCREEN_ZOOM },
175         { "\\scroll_below_document", LyXRC::RC_SCROLL_BELOW_DOCUMENT },
176         { "\\serverpipe", LyXRC::RC_SERVERPIPE },
177         { "\\set_color", LyXRC::RC_SET_COLOR },
178         { "\\show_banner", LyXRC::RC_SHOW_BANNER },
179         { "\\single_close_tab_button", LyXRC::RC_SINGLE_CLOSE_TAB_BUTTON },
180         { "\\sort_layouts", LyXRC::RC_SORT_LAYOUTS },
181         { "\\spell_command", LyXRC::RC_SPELL_COMMAND },
182         { "\\spellcheck_continuously", LyXRC::RC_SPELLCHECK_CONTINUOUSLY },
183         { "\\spellcheck_minlength", LyXRC::RC_SPELL_MINLENGTH },
184         { "\\spellcheck_notes", LyXRC::RC_SPELLCHECK_NOTES },
185         { "\\spellchecker", LyXRC::RC_SPELLCHECKER },
186         { "\\splitindex_command", LyXRC::RC_SPLITINDEX_COMMAND },
187         { "\\tempdir_path", LyXRC::RC_TEMPDIRPATH },
188         { "\\template_path", LyXRC::RC_TEMPLATEPATH },
189         { "\\tex_allows_spaces", LyXRC::RC_TEX_ALLOWS_SPACES },
190         { "\\tex_expects_windows_paths", LyXRC::RC_TEX_EXPECTS_WINDOWS_PATHS },
191         { "\\thesaurusdir_path", LyXRC::RC_THESAURUSDIRPATH },
192         { "\\ui_file", LyXRC::RC_UIFILE },
193         { "\\use_alt_language", LyXRC::RC_USE_ALT_LANG },
194         { "\\use_converter_cache", LyXRC::RC_USE_CONVERTER_CACHE },
195         { "\\use_escape_chars", LyXRC::RC_USE_ESC_CHARS },
196         { "\\use_input_encoding", LyXRC::RC_USE_INP_ENC },
197         { "\\use_lastfilepos", LyXRC::RC_USELASTFILEPOS },
198         { "\\use_personal_dictionary", LyXRC::RC_USE_PERS_DICT },
199         { "\\use_pixmap_cache", LyXRC::RC_USE_PIXMAP_CACHE },
200         // compatibility with versions older than 1.4.0 only
201         { "\\use_pspell", LyXRC::RC_USE_SPELL_LIB },
202         // compatibility with versions older than 1.4.0 only
203         { "\\use_tempdir", LyXRC::RC_USETEMPDIR },
204         { "\\use_tooltip", LyXRC::RC_USE_TOOLTIP },
205         { "\\user_email", LyXRC::RC_USER_EMAIL },
206         { "\\user_name", LyXRC::RC_USER_NAME },
207         { "\\view_dvi_paper_option", LyXRC::RC_VIEWDVI_PAPEROPTION },
208         // compatibility with versions older than 1.4.0 only
209         { "\\viewer", LyXRC::RC_VIEWER},
210         { "\\viewer_alternatives", LyXRC::RC_VIEWER_ALTERNATIVES },
211         { "\\visual_cursor" ,LyXRC::RC_VISUAL_CURSOR}
212 };
213
214 const int lyxrcCount = sizeof(lyxrcTags) / sizeof(lyxrcTags[0]);
215
216 } // namespace anon
217
218
219 LyXRC::LyXRC()
220 {
221         setDefaults();
222 }
223
224
225 void LyXRC::setDefaults()
226 {
227         bind_file = "cua";
228         def_file = "default";
229         ui_file = "default";
230         // Get printer from the environment. If fail, use default "",
231         // assuming that everything is set up correctly.
232         printer = getEnv("PRINTER");
233         print_adapt_output = false;
234         print_command = "dvips";
235         print_evenpage_flag = "-B";
236         print_oddpage_flag = "-A";
237         print_pagerange_flag = "-pp";
238         print_copies_flag = "-c";
239         print_collcopies_flag = "-C";
240         print_reverse_flag = "-r";
241         print_landscape_flag = "-t landscape";
242         print_to_printer = "-P";
243         print_to_file = "-o ";
244         print_file_extension = ".ps";
245         print_paper_flag = "-t";
246         print_paper_dimension_flag = "-T";
247         document_path.erase();
248         view_dvi_paper_option.erase();
249         default_papersize = PAPER_DEFAULT;
250         default_view_format = "pdf2";
251         chktex_command = "chktex -n1 -n3 -n6 -n9 -n22 -n25 -n30 -n38";
252         bibtex_command = "bibtex";
253         fontenc = "default";
254         index_command = "makeindex -c -q";
255         nomencl_command = "makeindex -s nomencl.ist";
256         dpi = 75;
257         // Because a screen is typically wider than a piece of paper:
258         zoom = 150;
259         allow_geometry_session = true;
260         // Default LaTeX font size:
261         font_sizes[FONT_SIZE_TINY] = "5.0";
262         font_sizes[FONT_SIZE_SCRIPT] = "7.0";
263         font_sizes[FONT_SIZE_FOOTNOTE] = "8.0";
264         font_sizes[FONT_SIZE_SMALL] = "9.0";
265         font_sizes[FONT_SIZE_NORMAL] = "10.0";
266         font_sizes[FONT_SIZE_LARGE] = "12.0";
267         font_sizes[FONT_SIZE_LARGER] = "14.4";
268         font_sizes[FONT_SIZE_LARGEST] = "17.26";
269         font_sizes[FONT_SIZE_HUGE] = "20.74";
270         font_sizes[FONT_SIZE_HUGER] = "24.88";
271         use_scalable_fonts = true;
272         roman_font_name = "";
273         sans_font_name = "";
274         typewriter_font_name = "";
275         autosave = 300;
276         auto_region_delete = true;
277         auto_reset_options = false;
278         plaintext_linelen = 65;
279         mouse_wheel_speed = 1.0;
280         num_lastfiles = maxlastfiles;
281         check_lastfiles = true;
282         use_lastfilepos = true;
283         load_session = false;
284         make_backup = true;
285         save_compressed = false;
286         backupdir_path.erase();
287         display_graphics = true;
288         // Spellchecker settings:
289 // FIXME: this check should test the target platform (darwin)
290 #if defined(USE_MACOSX_PACKAGING)
291         spellchecker = "native";
292 #elif defined(USE_ASPELL)
293         spellchecker = "aspell";
294 #elif defined(USE_HUNSPELL)
295         spellchecker = "hunspell";
296 #else
297         spellchecker = "aspell";
298 #endif
299         spellchecker_accept_compound = false;
300         spellcheck_continuously = false;
301         spellcheck_minlength = 6;
302         spellcheck_notes = true;
303         use_kbmap = false;
304         rtl_support = true;
305         visual_cursor = false;
306         auto_number = true;
307         mark_foreign_language = true;
308         language_auto_begin = true;
309         language_auto_end = true;
310         language_global_options = true;
311         language_use_babel = true;
312         language_package = "\\usepackage{babel}";
313         language_command_begin = "\\selectlanguage{$$lang}";
314         language_command_local = "\\foreignlanguage{$$lang}{";
315         sort_layouts = false;
316         group_layouts = true;
317         default_language = "english";
318         gui_language = "auto";
319         show_banner = true;
320         windows_style_tex_paths = false;
321         tex_allows_spaces = false;
322         date_insert_format = "%x";
323         cursor_follows_scrollbar = false;
324         scroll_below_document = false;
325         paragraph_markers = false;
326         mac_like_word_movement = false;
327         macro_edit_style = MACRO_EDIT_INLINE_BOX;
328         dialogs_iconify_with_main = false;
329         preview = PREVIEW_OFF;
330         preview_hashed_labels  = false;
331         preview_scale_factor = 1.0;
332         use_converter_cache = true;
333         use_tooltip = true;
334         use_pixmap_cache = false;
335         converter_cache_maxage = 6 * 30 * 24 * 3600; // 6 months
336         user_name = to_utf8(support::user_name());
337         user_email = to_utf8(support::user_email());
338         open_buffers_in_tabs = true;
339         single_close_tab_button = false;
340         forward_search_dvi = string();
341         forward_search_pdf = string();
342         export_overwrite = NO_FILES;
343
344         // Fullscreen settings
345         full_screen_limit = false;
346         full_screen_toolbars = true;
347         full_screen_tabbar = true;
348         full_screen_menubar = true;
349         full_screen_scrollbar = true;
350         full_screen_width = 700;
351
352         completion_cursor_text = true;
353         completion_popup_math = true;
354         completion_popup_text = false;
355         completion_popup_delay = 2.0;
356         completion_popup_after_complete = true;
357         autocorrection_math = false;
358         completion_inline_math = true;
359         completion_inline_text = false;
360         completion_inline_dots = -1;
361         completion_inline_delay = 0.2;
362         default_decimal_point = ".";
363 }
364
365
366 namespace {
367
368 void oldFontFormat(string & family, string & foundry)
369 {
370         if (family.empty() || family[0] != '-')
371                 return;
372         foundry = token(family, '-', 1);
373         family = token(family, '-', 2);
374         if (foundry == "*")
375                 foundry.erase();
376 }
377
378 } // namespace anon
379
380
381 int LyXRC::read(FileName const & filename)
382 {
383         Lexer lexrc(lyxrcTags);
384         if (lyxerr.debugging(Debug::PARSER))
385                 lexrc.printTable(lyxerr);
386
387         lexrc.setFile(filename);
388         if (!lexrc.isOK())
389                 return -2;
390
391         LYXERR(Debug::LYXRC, "Reading '" << filename << "'...");
392
393         return read(lexrc);
394 }
395
396
397 int LyXRC::read(istream & is)
398 {
399         Lexer lexrc(lyxrcTags);
400         if (lyxerr.debugging(Debug::PARSER))
401                 lexrc.printTable(lyxerr);
402
403         lexrc.setStream(is);
404         if (!lexrc.isOK())
405                 return -2;
406
407         LYXERR(Debug::LYXRC, "Reading istream...");
408
409         return read(lexrc);
410 }
411
412
413 int LyXRC::read(Lexer & lexrc)
414 {
415         if (!lexrc.isOK())
416                 return -2;
417
418         while (lexrc.isOK()) {
419                 // By using two switches we take advantage of the compiler
420                 // telling us if we have missed a LyXRCTags element in
421                 // the second switch.
422                 // Note that this also shows a problem with Lexer since it
423                 // helps us avoid taking advantage of the strictness of the
424                 // compiler.
425
426                 int le = lexrc.lex();
427                 switch (le) {
428                 case Lexer::LEX_UNDEF:
429                         lexrc.printError("Unknown tag `$$Token'");
430                         continue;
431                 case Lexer::LEX_FEOF:
432                         continue;
433                 default:
434                         break;
435                 }
436                 switch (static_cast<LyXRCTags>(le)) {
437                 case RC_INPUT: // Include file
438                         if (lexrc.next()) {
439                                 FileName const tmp =
440                                         libFileSearch(string(),
441                                                       lexrc.getString());
442                                 if (read(tmp)) {
443                                         lexrc.printError("Error reading "
444                                                          "included file: " + tmp.absFileName());
445                                 }
446                         }
447                         break;
448                 case RC_BINDFILE:
449                         if (lexrc.next())
450                                 bind_file = os::internal_path(lexrc.getString());
451                         break;
452
453                 case RC_DEFFILE:
454                         if (lexrc.next())
455                                 def_file = os::internal_path(lexrc.getString());
456                         break;
457
458                 case RC_UIFILE:
459                         if (lexrc.next())
460                                 ui_file = os::internal_path(lexrc.getString());
461                         break;
462
463                 case RC_AUTORESET_OPTIONS:
464                         lexrc >> auto_reset_options;
465                         break;
466
467                 case RC_DISPLAY_GRAPHICS:
468                         if (lexrc.next())
469                                 display_graphics = lexrc.getString() == "true";
470                         break;
471
472                 case RC_TEX_EXPECTS_WINDOWS_PATHS:
473                         lexrc >> windows_style_tex_paths;
474                         break;
475
476                 case RC_TEX_ALLOWS_SPACES:
477                         lexrc >> tex_allows_spaces;
478                         break;
479
480                 case RC_KBMAP:
481                         lexrc >> use_kbmap;
482                         break;
483
484                 case RC_KBMAP_PRIMARY:
485                         if (lexrc.next()) {
486                                 string const kmap(os::internal_path(lexrc.getString()));
487                                 if (!libFileSearch("kbd", kmap, "kmap").empty()
488                                           || kmap.empty()) {
489                                         primary_kbmap = kmap;
490                                 } else {
491                                         lexrc.printError("LyX: Keymap `$$Token' not found");
492                                 }
493                         }
494                         break;
495
496                 case RC_KBMAP_SECONDARY:
497                         if (lexrc.next()) {
498                                 string const kmap(os::internal_path(lexrc.getString()));
499                                 if (!libFileSearch("kbd", kmap, "kmap").empty()
500                                           || kmap.empty()) {
501                                         secondary_kbmap = kmap;
502                                 } else {
503                                         lexrc.printError("LyX: Keymap `$$Token' not found");
504                                 }
505                         }
506                         break;
507
508                 case RC_FONT_ENCODING:
509                         lexrc >> fontenc;
510                         break;
511
512                 case RC_PRINTER:
513                         lexrc >> printer;
514                         break;
515
516                 case RC_PRINT_COMMAND:
517                         if (lexrc.next(true)) {
518                                 print_command = lexrc.getString();
519                         }
520                         break;
521
522                 case RC_PRINTEVENPAGEFLAG:
523                         lexrc >> print_evenpage_flag;
524                         break;
525
526                 case RC_PRINTODDPAGEFLAG:
527                         lexrc >> print_oddpage_flag;
528                         break;
529
530                 case RC_PRINTPAGERANGEFLAG:
531                         lexrc >> print_pagerange_flag;
532                         break;
533
534                 case RC_PRINTCOPIESFLAG:
535                         lexrc >> print_copies_flag;
536                         break;
537
538                 case RC_PRINTCOLLCOPIESFLAG:
539                         lexrc >> print_collcopies_flag;
540                         break;
541
542                 case RC_PRINTREVERSEFLAG:
543                         lexrc >> print_reverse_flag;
544                         break;
545
546                 case RC_PRINTLANDSCAPEFLAG:
547                         lexrc >> print_landscape_flag;
548                         break;
549
550                 case RC_PRINTTOPRINTER:
551                         lexrc >> print_to_printer;
552                         break;
553
554                 case RC_PRINT_ADAPTOUTPUT:
555                         lexrc >> print_adapt_output;
556                         break;
557
558                 case RC_PRINTTOFILE:
559                         if (lexrc.next()) {
560                                 print_to_file = os::internal_path(lexrc.getString());
561                         }
562                         break;
563
564                 case RC_PRINTFILEEXTENSION:
565                         lexrc >> print_file_extension;
566                         break;
567
568                 case RC_PRINTEXSTRAOPTIONS:
569                         lexrc >> print_extra_options;
570                         break;
571
572                 case RC_PRINTSPOOL_COMMAND:
573                         if (lexrc.next(true)) {
574                                 print_spool_command = lexrc.getString();
575                         }
576                         break;
577
578                 case RC_PRINTSPOOL_PRINTERPREFIX:
579                         lexrc >> print_spool_printerprefix;
580                         break;
581
582                 case RC_PRINTPAPERDIMENSIONFLAG:
583                         lexrc >> print_paper_dimension_flag;
584                         break;
585
586                 case RC_PRINTPAPERFLAG:
587                         lexrc >> print_paper_flag;
588                         break;
589
590                 case RC_DEFAULT_PAPERSIZE:
591                         if (lexrc.next()) {
592                                 string const size = ascii_lowercase(lexrc.getString());
593                                 if (size == "usletter")
594                                         default_papersize = PAPER_USLETTER;
595                                 else if (size == "legal")
596                                         default_papersize = PAPER_USLEGAL;
597                                 else if (size == "executive")
598                                         default_papersize = PAPER_USEXECUTIVE;
599                                 else if (size == "a3")
600                                         default_papersize = PAPER_A3;
601                                 else if (size == "a4")
602                                         default_papersize = PAPER_A4;
603                                 else if (size == "a5")
604                                         default_papersize = PAPER_A5;
605                                 else if (size == "b5")
606                                         default_papersize = PAPER_B5;
607                                 else if (size == "default")
608                                         default_papersize = PAPER_DEFAULT;
609                         }
610                         break;
611
612                 case RC_VIEWDVI_PAPEROPTION:
613                         if (lexrc.next())
614                                 view_dvi_paper_option = lexrc.getString();
615                         else
616                                 view_dvi_paper_option.erase();
617                         break;
618
619                 case RC_CHKTEX_COMMAND:
620                         if (lexrc.next(true)) {
621                                 chktex_command = lexrc.getString();
622                         }
623                         break;
624
625                 case RC_BIBTEX_ALTERNATIVES:
626                         if (lexrc.next(true)) {
627                                 bibtex_alternatives.insert(lexrc.getString());
628                         }
629                         break;
630
631                 case RC_BIBTEX_COMMAND:
632                         if (lexrc.next(true)) {
633                                 bibtex_command = lexrc.getString();
634                         }
635                         break;
636
637                 case RC_JBIBTEX_COMMAND:
638                         if (lexrc.next(true)) {
639                                 jbibtex_command = lexrc.getString();
640                         }
641                         break;
642
643                 case RC_INDEX_ALTERNATIVES:
644                         if (lexrc.next(true)) {
645                                 index_alternatives.insert(lexrc.getString());
646                         }
647                         break;
648
649                 case RC_INDEX_COMMAND:
650                         if (lexrc.next(true)) {
651                                 index_command = lexrc.getString();
652                         }
653                         break;
654
655                 case RC_JINDEX_COMMAND:
656                         if (lexrc.next(true)) {
657                                 jindex_command = lexrc.getString();
658                         }
659                         break;
660
661                 case RC_SPLITINDEX_COMMAND:
662                         if (lexrc.next(true)) {
663                                 splitindex_command = lexrc.getString();
664                         }
665                         break;
666
667                 case RC_NOMENCL_COMMAND:
668                         if (lexrc.next(true)) {
669                                 nomencl_command = lexrc.getString();
670                         }
671                         break;
672
673                 case RC_SCREEN_DPI:
674                         lexrc >> dpi;
675                         break;
676
677                 case RC_SCREEN_ZOOM:
678                         lexrc >> zoom;
679                         break;
680
681                 case RC_GEOMETRY_SESSION:
682                         lexrc >> allow_geometry_session;
683                         break;
684
685                 case RC_SCREEN_FONT_SIZES:
686                         lexrc >> font_sizes[FONT_SIZE_TINY];
687                         lexrc >> font_sizes[FONT_SIZE_SCRIPT];
688                         lexrc >> font_sizes[FONT_SIZE_FOOTNOTE];
689                         lexrc >> font_sizes[FONT_SIZE_SMALL];
690                         lexrc >> font_sizes[FONT_SIZE_NORMAL];
691                         lexrc >> font_sizes[FONT_SIZE_LARGE];
692                         lexrc >> font_sizes[FONT_SIZE_LARGER];
693                         lexrc >> font_sizes[FONT_SIZE_LARGEST];
694                         lexrc >> font_sizes[FONT_SIZE_HUGE];
695                         lexrc >> font_sizes[FONT_SIZE_HUGER];
696                         break;
697
698                 case RC_SCREEN_FONT_SCALABLE:
699                         lexrc >> use_scalable_fonts;
700                         break;
701
702                 case RC_AUTOSAVE:
703                         lexrc >> autosave;
704                         break;
705
706                 case RC_DOCUMENTPATH:
707                         if (lexrc.next()) {
708                                 document_path = os::internal_path(lexrc.getString());
709                                 document_path = expandPath(document_path);
710                         }
711                         break;
712
713                 case RC_EXAMPLEPATH:
714                         if (lexrc.next()) {
715                                 example_path = os::internal_path(lexrc.getString());
716                                 example_path = expandPath(example_path);
717                         }
718                         break;
719
720                 case RC_TEMPLATEPATH:
721                         if (lexrc.next()) {
722                                 template_path = os::internal_path(lexrc.getString());
723                                 template_path = expandPath(template_path);
724                         }
725                         break;
726
727                 case RC_TEMPDIRPATH:
728                         if (lexrc.next()) {
729                                 tempdir_path = os::internal_path(lexrc.getString());
730                                 tempdir_path = expandPath(tempdir_path);
731                         }
732                         break;
733
734                 case RC_THESAURUSDIRPATH:
735                         if (lexrc.next()) {
736                                 thesaurusdir_path = os::internal_path(lexrc.getString());
737                                 thesaurusdir_path = expandPath(thesaurusdir_path);
738                         }
739                         break;
740
741                 case RC_HUNSPELLDIR_PATH:
742                         if (lexrc.next()) {
743                                 hunspelldir_path = os::internal_path(lexrc.getString());
744                                 hunspelldir_path = expandPath(hunspelldir_path);
745                         }
746                         break;
747
748                 case RC_USELASTFILEPOS:
749                         lexrc >> use_lastfilepos;
750                         break;
751
752                 case RC_LOADSESSION:
753                         lexrc >> load_session;
754                         break;
755
756                 case RC_MOUSE_WHEEL_SPEED:
757                         lexrc >> mouse_wheel_speed;
758                         break;
759
760                 case RC_COMPLETION_INLINE_DELAY:
761                         lexrc >> completion_inline_delay;
762                         break;
763
764                 case RC_COMPLETION_INLINE_MATH:
765                         lexrc >> completion_inline_math;
766                         break;
767
768                 case RC_COMPLETION_INLINE_TEXT:
769                         lexrc >> completion_inline_text;
770                         break;
771
772                 case RC_COMPLETION_INLINE_DOTS:
773                         lexrc >> completion_inline_dots;
774                         break;
775
776                 case RC_AUTOCORRECTION_MATH:
777                         lexrc >> autocorrection_math;
778                         break;
779
780                 case RC_COMPLETION_POPUP_DELAY:
781                         lexrc >> completion_popup_delay;
782                         break;
783
784                 case RC_COMPLETION_POPUP_MATH:
785                         lexrc >> completion_popup_math;
786                         break;
787
788                 case RC_COMPLETION_POPUP_TEXT:
789                         lexrc >> completion_popup_text;
790                         break;
791
792                 case RC_COMPLETION_CURSOR_TEXT:
793                         lexrc >> completion_cursor_text;
794                         break;
795
796                 case RC_COMPLETION_POPUP_AFTER_COMPLETE:
797                         lexrc >> completion_popup_after_complete;
798                         break;
799
800                 case RC_NUMLASTFILES:
801                         lexrc >> num_lastfiles;
802                         break;
803
804                 case RC_CHECKLASTFILES:
805                         lexrc >> check_lastfiles;
806                         break;
807
808                 case RC_SCREEN_FONT_ROMAN:
809                         if (lexrc.next()) {
810                                 roman_font_name = lexrc.getString();
811                                 oldFontFormat(roman_font_name,
812                                               roman_font_foundry);
813                         }
814                         break;
815
816                 case RC_SCREEN_FONT_SANS:
817                         if (lexrc.next()) {
818                                 sans_font_name = lexrc.getString();
819                                 oldFontFormat(sans_font_name, sans_font_foundry);
820                         }
821                         break;
822
823                 case RC_SCREEN_FONT_TYPEWRITER:
824                         if (lexrc.next()) {
825                                 typewriter_font_name = lexrc.getString();
826                                 oldFontFormat(typewriter_font_name,
827                                               typewriter_font_foundry);
828                         }
829                         break;
830
831                 case RC_SCREEN_FONT_ROMAN_FOUNDRY:
832                         lexrc >> roman_font_foundry;
833                         break;
834
835                 case RC_SCREEN_FONT_SANS_FOUNDRY:
836                         lexrc >> sans_font_foundry;
837                         break;
838
839                 case RC_SCREEN_FONT_TYPEWRITER_FOUNDRY:
840                         lexrc >> typewriter_font_foundry;
841                         break;
842
843                 case RC_SET_COLOR: {
844                         if (!lexrc.next()) {
845                                 lexrc.printError("Missing color tag.");
846                                 break;
847                         }
848                         string lyx_name = lexrc.getString();
849
850                         if (!lexrc.next()) {
851                                 lexrc.printError("Missing color name for color: `$$Token'");
852                                 break;
853                         }
854                         string x11_name = lexrc.getString();
855
856                         ColorCode const col =
857                                 lcolor.getFromLyXName(lyx_name);
858                         if (col == Color_none ||
859                             col == Color_inherit ||
860                             col == Color_ignore)
861                                 break;
862
863                         if (!lcolor.setColor(col, x11_name))
864                                 LYXERR0("Bad lyxrc set_color for " << lyx_name);
865                         break;
866                 }
867
868                 case RC_AUTOREGIONDELETE:
869                         // Auto region delete defaults to true
870                         lexrc >> auto_region_delete;
871                         break;
872
873                 case RC_SERVERPIPE:
874                         if (lexrc.next()) {
875                                 lyxpipes = os::internal_path(lexrc.getString());
876                                 lyxpipes = expandPath(lyxpipes);
877                         }
878                         break;
879
880                 case RC_CURSOR_FOLLOWS_SCROLLBAR:
881                         lexrc >> cursor_follows_scrollbar;
882                         break;
883
884                 case RC_SCROLL_BELOW_DOCUMENT:
885                         lexrc >> scroll_below_document;
886                         break;
887
888                 case RC_PARAGRAPH_MARKERS:
889                         lexrc >> paragraph_markers;
890                         break;
891
892                 case RC_MAC_LIKE_WORD_MOVEMENT:
893                         lexrc >> mac_like_word_movement;
894                         break;
895
896                 case RC_MACRO_EDIT_STYLE:
897                         if (lexrc.next()) {
898                                 switch (lexrc.getInteger()) {
899                                 case 0: macro_edit_style = MACRO_EDIT_INLINE_BOX; break;
900                                 case 1: macro_edit_style = MACRO_EDIT_INLINE; break;
901                                 case 2: macro_edit_style = MACRO_EDIT_LIST; break;
902                                 }
903                         }
904                         break;
905
906                 case RC_DIALOGS_ICONIFY_WITH_MAIN:
907                         lexrc >> dialogs_iconify_with_main;
908                         break;
909
910                 case RC_PLAINTEXT_LINELEN:
911                         lexrc >> plaintext_linelen;
912                         break;
913                         // Spellchecker settings:
914                 case RC_ACCEPT_COMPOUND:
915                         lexrc >> spellchecker_accept_compound;
916                         break;
917                 case RC_USE_TOOLTIP:
918                         lexrc >> use_tooltip;
919                         break;
920                 case RC_USE_PIXMAP_CACHE:
921                         lexrc >> use_pixmap_cache;
922                         break;
923                 case RC_SPELLCHECKER:
924                         lexrc >> spellchecker;
925                         break;
926                 case RC_SPELL_MINLENGTH: {
927                         int len;
928                         lexrc >> len;
929                         // make sure we have a sensible value
930                         // these should be kept in sync with the min and max 
931                         // values for the spinbox in PrefSpellcheckerUi.ui
932                         if (len < 5)
933                                 len = 5;
934                         else if (len > 15)
935                                 len = 15;
936                         spellcheck_minlength = len;
937                         break;
938                 }
939                 case RC_ALT_LANG:
940                         lexrc >> spellchecker_alt_lang;
941                         break;
942                 case RC_ESC_CHARS:
943                         lexrc >> spellchecker_esc_chars;
944                         break;
945                 case RC_SPELLCHECK_CONTINUOUSLY:
946                         lexrc >> spellcheck_continuously;
947                         break;
948                 case RC_SPELLCHECK_NOTES:
949                         lexrc >> spellcheck_notes;
950                         break;
951                 case RC_MAKE_BACKUP:
952                         lexrc >> make_backup;
953                         break;
954                 case RC_SAVE_COMPRESSED:
955                         lexrc >> save_compressed;
956                         break;
957                 case RC_BACKUPDIR_PATH:
958                         if (lexrc.next()) {
959                                 backupdir_path = os::internal_path(lexrc.getString());
960                                 backupdir_path = expandPath(backupdir_path);
961                         }
962                         break;
963                 case RC_DEFAULT_DECIMAL_POINT:
964                         lexrc >> default_decimal_point;
965                         break;
966                 case RC_DATE_INSERT_FORMAT:
967                         lexrc >> date_insert_format;
968                         break;
969                 case RC_LANGUAGE_PACKAGE:
970                         lexrc >> language_package;
971                         break;
972                 case RC_LANGUAGE_AUTO_BEGIN:
973                         lexrc >> language_auto_begin;
974                         break;
975                 case RC_LANGUAGE_AUTO_END:
976                         lexrc >> language_auto_end;
977                         break;
978                 case RC_LANGUAGE_GLOBAL_OPTIONS:
979                         lexrc >> language_global_options;
980                         break;
981                 case RC_LANGUAGE_USE_BABEL:
982                         lexrc >> language_use_babel;
983                         break;
984                 case RC_LANGUAGE_COMMAND_BEGIN:
985                         lexrc >> language_command_begin;
986                         break;
987                 case RC_LANGUAGE_COMMAND_END:
988                         lexrc >> language_command_end;
989                         break;
990                 case RC_LANGUAGE_COMMAND_LOCAL:
991                         lexrc >> language_command_local;
992                         break;
993                 case RC_RTL_SUPPORT:
994                         lexrc >> rtl_support;
995                         break;
996                 case RC_VISUAL_CURSOR:
997                         lexrc >> visual_cursor;
998                         break;
999                 case RC_AUTO_NUMBER:
1000                         lexrc >> auto_number;
1001                         break;
1002                 case RC_MARK_FOREIGN_LANGUAGE:
1003                         lexrc >> mark_foreign_language;
1004                         break;
1005
1006                 case RC_COPIER: {
1007                         string fmt, command;
1008                         if (lexrc.next())
1009                                 fmt = lexrc.getString();
1010                         if (lexrc.next(true))
1011                                 command = lexrc.getString();
1012                         setMover(fmt, command);
1013                         break;
1014                 }
1015
1016                 case RC_CONVERTER: {
1017                         string from, to, command, flags;
1018                         if (lexrc.next())
1019                                 from = lexrc.getString();
1020                         if (lexrc.next())
1021                                 to = lexrc.getString();
1022                         if (lexrc.next(true))
1023                                 command = lexrc.getString();
1024                         if (lexrc.next())
1025                                 flags = lexrc.getString();
1026                         if (command.empty())
1027                                 theConverters().erase(from, to);
1028                         else
1029                                 theConverters().add(from, to, command, flags);
1030                         break;
1031                 }
1032                 // compatibility with versions older than 1.4.0 only
1033                 case RC_VIEWER: {
1034                         string format, command;
1035                         lexrc >> format >> command;
1036                         formats.setViewer(format, command);
1037                         break;
1038                 }
1039                 case RC_FORMAT: {
1040                         string format, extension, prettyname, shortcut;
1041                         lexrc >> format >> extension >> prettyname >> shortcut;
1042                         string viewer, editor;
1043                         if (lexrc.next(true))
1044                                 viewer = lexrc.getString();
1045                         if (lexrc.next(true))
1046                                 editor = lexrc.getString();
1047                         string flags;
1048                         // Hack to ensure compatibility with versions older
1049                         // than 1.5.0
1050                         int le = lexrc.lex();
1051                         if (le != Lexer::LEX_FEOF && le != Lexer::LEX_UNDEF) {
1052                                 flags = lexrc.getString();
1053                                 if (le != Lexer::LEX_DATA) {
1054                                         // We have got a known token.
1055                                         // Therefore this is an old style
1056                                         // format definition without
1057                                         // flags.
1058                                         lexrc.pushToken(flags);
1059                                         flags.erase();
1060                                 }
1061                         }
1062                         int flgs = Format::none;
1063                         while (!flags.empty()) {
1064                                 string flag;
1065                                 flags = split(flags, flag, ',');
1066                                 if (flag == "document")
1067                                         flgs |= Format::document;
1068                                 else if (flag == "vector")
1069                                         flgs |= Format::vector;
1070                                 else
1071                                         LYXERR0("Ignoring unknown flag `"
1072                                                << flag << "' for format `"
1073                                                << format << "'.");
1074                         }
1075                         if (prettyname.empty()) {
1076                                 if (theConverters().formatIsUsed(format))
1077                                         LYXERR0("Can't delete format " << format);
1078                                 else
1079                                         formats.erase(format);
1080                         } else {
1081                                 formats.add(format, extension, prettyname,
1082                                             shortcut, viewer, editor, flgs);
1083                         }
1084                         break;
1085                 }
1086                 case RC_VIEWER_ALTERNATIVES:  {
1087                         string format, command;
1088                         if (lexrc.next())
1089                                 format = lexrc.getString();
1090                         if (lexrc.eatLine())
1091                                 command = lexrc.getString();
1092                         viewer_alternatives[format].insert(command);
1093                         break;
1094                 }
1095                 case RC_EDITOR_ALTERNATIVES:  {
1096                         string format, command;
1097                         lexrc >> format >> command;
1098                         editor_alternatives[format].insert(command);
1099                         break;
1100                 }
1101
1102                 case RC_DEFAULT_VIEW_FORMAT:
1103                         lexrc >> default_view_format;
1104                         break;
1105                         
1106                 case RC_DEFAULT_LANGUAGE:
1107                         lexrc >> default_language;
1108                         break;
1109
1110                 case RC_GUI_LANGUAGE:
1111                         lexrc >> gui_language;
1112                         break;
1113
1114                 case RC_SHOW_BANNER:
1115                         lexrc >> show_banner;
1116                         break;
1117
1118                 case RC_PREVIEW:
1119                         if (lexrc.next()) {
1120                                 string const tmp = lexrc.getString();
1121                                 if (tmp == "true" || tmp == "on")
1122                                         preview = PREVIEW_ON;
1123                                 else if (tmp == "no_math")
1124                                         preview = PREVIEW_NO_MATH;
1125                                 else {
1126                                         preview = PREVIEW_OFF;
1127                                         if (tmp != "false" && tmp != "off")
1128                                                 LYXERR0("Unrecognized preview status \""
1129                                                        << tmp << '\n');
1130                                 }
1131                         }
1132                         break;
1133
1134                 case RC_PREVIEW_HASHED_LABELS:
1135                         lexrc >> preview_hashed_labels;
1136                         break;
1137
1138                 case RC_PREVIEW_SCALE_FACTOR:
1139                         lexrc >> preview_scale_factor;
1140                         break;
1141
1142                 case RC_USER_NAME:
1143                         lexrc >> user_name;
1144                         break;
1145                 case RC_USER_EMAIL:
1146                         lexrc >> user_email;
1147                         break;
1148
1149                 case RC_PATH_PREFIX:
1150                         lexrc >> path_prefix;
1151                         break;
1152
1153                 case RC_USE_CONVERTER_CACHE:
1154                         lexrc >> use_converter_cache;
1155                         break;
1156                 case RC_CONVERTER_CACHE_MAXAGE:
1157                         lexrc >> converter_cache_maxage;
1158                         break;
1159
1160                 case RC_SORT_LAYOUTS:
1161                         lexrc >> sort_layouts;
1162                         break;
1163                 case RC_GROUP_LAYOUTS:
1164                         lexrc >> group_layouts;
1165                         break;
1166                 case RC_FULL_SCREEN_LIMIT:
1167                         lexrc >> full_screen_limit;
1168                         break;
1169                 case RC_FULL_SCREEN_TOOLBARS:
1170                         lexrc >> full_screen_toolbars;
1171                         break;
1172                 case RC_FULL_SCREEN_SCROLLBAR:
1173                         lexrc >> full_screen_scrollbar;
1174                         break;
1175                 case RC_FULL_SCREEN_TABBAR:
1176                         lexrc >> full_screen_tabbar;
1177                         break;
1178                 case RC_FULL_SCREEN_MENUBAR:
1179                         lexrc >> full_screen_menubar;
1180                         break;
1181                 case RC_FULL_SCREEN_WIDTH:
1182                         lexrc >> full_screen_width;
1183                         break;
1184                 case RC_OPEN_BUFFERS_IN_TABS:
1185                         lexrc >> open_buffers_in_tabs;
1186                         break;
1187                 case RC_SINGLE_CLOSE_TAB_BUTTON:
1188                         lexrc >> single_close_tab_button;
1189                         break;
1190                 case RC_FORWARD_SEARCH_DVI:
1191                         if (lexrc.next(true)) 
1192                                 forward_search_dvi = lexrc.getString();
1193                         break;
1194                 case RC_FORWARD_SEARCH_PDF:
1195                         if (lexrc.next(true)) 
1196                                 forward_search_pdf = lexrc.getString();
1197                         break;
1198                 case RC_EXPORT_OVERWRITE:
1199                         if (lexrc.next()) {
1200                                 string const tmp = lexrc.getString();
1201                                 if (tmp == "all" || tmp == "true")
1202                                         export_overwrite = ALL_FILES;
1203                                 else if (tmp == "main")
1204                                         export_overwrite = MAIN_FILE;
1205                                 else {
1206                                         export_overwrite = NO_FILES;
1207                                         if (tmp != "ask" && tmp != "false")
1208                                                 LYXERR0("Unrecognized export_overwrite status \""
1209                                                        << tmp << '"');
1210                                 }
1211                         }
1212                         break;
1213
1214                 // Obsoteted in 1.4.0
1215                 case RC_USETEMPDIR:
1216                 // Obsoleted in 2.0
1217                 case RC_SPELL_COMMAND:
1218                 case RC_PERS_DICT:
1219                 case RC_PLAINTEXT_ROFF_COMMAND: 
1220                 case RC_USE_ALT_LANG:
1221                 case RC_USE_ESC_CHARS:
1222                 case RC_USE_INP_ENC:
1223                 case RC_USE_PERS_DICT:
1224                 case RC_USE_SPELL_LIB:
1225                         LYXERR(Debug::LYXRC, "Skipping obsolete tag `" 
1226                                << lexrc.getString() << "'.");
1227                         lexrc.next(true);
1228                         break;
1229
1230                 case RC_LAST:
1231                         break; // this is just a dummy
1232                 }
1233         }
1234
1235         /// Update converters data-structures
1236         theConverters().update(formats);
1237         theConverters().buildGraph();
1238
1239         return 0;
1240 }
1241
1242
1243 void LyXRC::write(FileName const & filename, bool ignore_system_lyxrc) const
1244 {
1245         ofstream ofs(filename.toFilesystemEncoding().c_str());
1246         if (ofs)
1247                 write(ofs, ignore_system_lyxrc);
1248 }
1249
1250
1251 void LyXRC::print() const
1252 {
1253         if (lyxerr.debugging())
1254                 write(lyxerr, false);
1255         else
1256                 write(cout, false);
1257 }
1258
1259
1260 class SameMover {
1261 public:
1262         typedef pair<string, SpecialisedMover> Data;
1263
1264         SameMover(Data const & comparison)
1265                 : comparison_(comparison) {}
1266
1267         bool operator()(Data const & data) const
1268         {
1269                 return data.first == comparison_.first &&
1270                         data.second.command() == comparison_.second.command();
1271         }
1272
1273 private:
1274         Data comparison_;
1275 };
1276
1277
1278 namespace {
1279
1280         // Escape \ and " so that LyXLex can read the string later
1281         string escapeCommand(string const & str) {
1282                 return subst(subst(str , "\\", "\\\\"), 
1283                              "\"", "\\\"");
1284         }
1285
1286 }
1287
1288
1289 void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) const
1290 {
1291         LyXRCTags tag = RC_LAST;
1292         
1293         if (!name.empty()) {
1294                 for (int i = 0; i != lyxrcCount; ++i)
1295                         if ("\\" + name == lyxrcTags[i].tag)
1296                                 tag = static_cast<LyXRCTags>(lyxrcTags[i].code);
1297         }
1298
1299         if (tag == RC_LAST)
1300                 os << "# LyX " << lyx_version
1301                    << " generated this file. If you want to make your own\n"
1302                    << "# modifications you should do them from inside LyX and save.\n"
1303                    << "\n";
1304
1305         // Why the switch you might ask. It is a trick to ensure that all
1306         // the elements in the LyXRCTags enum are handled. As you can see
1307         // there are no breaks at all. So it is just a huge fall-through.
1308         // The nice thing is that we will get a warning from the compiler
1309         // if we forget an element.
1310         switch (tag) {
1311         case RC_LAST:
1312         case RC_INPUT:
1313                 // input/include files are not done here
1314         case RC_BINDFILE:
1315                 if (ignore_system_lyxrc ||
1316                     bind_file != system_lyxrc.bind_file) {
1317                         string const path = os::external_path(bind_file);
1318                         os << "\\bind_file \"" << path << "\"\n";
1319                 }
1320                 if (tag != RC_LAST)
1321                         break;
1322
1323         case RC_DEFFILE:
1324                 if (ignore_system_lyxrc ||
1325                     def_file != system_lyxrc.def_file) {
1326                         string const path = os::external_path(def_file);
1327                         os << "\\def_file \"" << path << "\"\n";
1328                 }
1329                 if (tag != RC_LAST)
1330                         break;
1331
1332                 //
1333                 // Misc Section
1334                 //
1335                 os << "\n#\n"
1336                    << "# MISC SECTION ######################################\n"
1337                    << "#\n\n";
1338                 // bind files are not done here.
1339
1340         case RC_PATH_PREFIX:
1341                 if (ignore_system_lyxrc ||
1342                     path_prefix != system_lyxrc.path_prefix) {
1343                         os << "\\path_prefix \"" << path_prefix << "\"\n";
1344                 }
1345                 if (tag != RC_LAST)
1346                         break;
1347         case RC_UIFILE:
1348                 if (ignore_system_lyxrc ||
1349                     ui_file != system_lyxrc.ui_file) {
1350                         string const path = os::external_path(ui_file);
1351                         os << "\\ui_file \"" << path << "\"\n";
1352                 }
1353                 if (tag != RC_LAST)
1354                         break;
1355         case RC_AUTOREGIONDELETE:
1356                 if (ignore_system_lyxrc ||
1357                     auto_region_delete != system_lyxrc.auto_region_delete) {
1358                         os << "# Set to false to inhibit automatic replacement of\n"
1359                            << "# the current selection.\n"
1360                            << "\\auto_region_delete " << convert<string>(auto_region_delete)
1361                            << '\n';
1362                 }
1363                 if (tag != RC_LAST)
1364                         break;
1365         case RC_AUTORESET_OPTIONS:
1366                 if (ignore_system_lyxrc ||
1367                     auto_reset_options != system_lyxrc.auto_reset_options) {
1368                         os << "# Set to false to inhibit automatic reset of\n"
1369                            << "# the class options to defaults on class change.\n"
1370                            << "\\auto_reset_options "
1371                            << convert<string>(auto_reset_options)
1372                            << '\n';
1373                 }
1374                 if (tag != RC_LAST)
1375                         break;
1376         case RC_AUTOSAVE:
1377                 if (ignore_system_lyxrc ||
1378                     autosave != system_lyxrc.autosave) {
1379                         os << "# The time interval between auto-saves in seconds.\n"
1380                            << "\\autosave " << autosave << '\n';
1381                 }
1382                 if (tag != RC_LAST)
1383                         break;
1384         case RC_DISPLAY_GRAPHICS:
1385                 if (ignore_system_lyxrc ||
1386                     display_graphics != system_lyxrc.display_graphics) {
1387                         os << "# Display graphics within LyX\n"
1388                            << "# true|false\n"
1389                            << "\\display_graphics "
1390                            << (display_graphics ? "true" : "false")
1391                            << '\n';
1392                 }
1393                 if (tag != RC_LAST)
1394                         break;
1395         case RC_SORT_LAYOUTS:
1396                 if (ignore_system_lyxrc ||
1397                     sort_layouts != system_lyxrc.sort_layouts) {
1398                         os << "# Sort layouts alphabetically.\n"
1399                            << "\\sort_layouts " << convert<string>(sort_layouts) << '\n';
1400                 }
1401                 if (tag != RC_LAST)
1402                         break;
1403         case RC_GROUP_LAYOUTS:
1404                 if (ignore_system_lyxrc ||
1405                     group_layouts != system_lyxrc.group_layouts) {
1406                         os << "# Group layouts by their category.\n"
1407                            << "\\group_layouts " << convert<string>(group_layouts) << '\n';
1408                 }
1409                 if (tag != RC_LAST)
1410                         break;
1411         case RC_VIEWDVI_PAPEROPTION:
1412                 if (ignore_system_lyxrc ||
1413                     view_dvi_paper_option
1414                     != system_lyxrc.view_dvi_paper_option) {
1415                         os << "# Options used to specify paper size to the\n"
1416                            << "# view_dvi_command (e.g. -paper)\n"
1417                            << "\\view_dvi_paper_option \""
1418                            << view_dvi_paper_option << "\"\n";
1419                 }
1420                 if (tag != RC_LAST)
1421                         break;
1422         case RC_DEFAULT_PAPERSIZE:
1423                 if (ignore_system_lyxrc ||
1424                     default_papersize != system_lyxrc.default_papersize) {
1425                         os << "# The default papersize to use.\n"
1426                            << "\\default_papersize \"";
1427                         switch (default_papersize) {
1428                         case PAPER_DEFAULT:
1429                                 os << "default"; break;
1430                         case PAPER_USLETTER:
1431                                 os << "usletter"; break;
1432                         case PAPER_USLEGAL:
1433                                 os << "legal"; break;
1434                         case PAPER_USEXECUTIVE:
1435                                 os << "executive"; break;
1436                         case PAPER_A3:
1437                                 os << "a3"; break;
1438                         case PAPER_A4:
1439                                 os << "a4"; break;
1440                         case PAPER_A5:
1441                                 os << "a5"; break;
1442                         case PAPER_B5:
1443                                 os << "b5"; break;
1444                         case PAPER_CUSTOM:
1445                         case PAPER_A0:
1446                         case PAPER_A1:
1447                         case PAPER_A2:
1448                         case PAPER_A6:
1449                         case PAPER_B0:
1450                         case PAPER_B1:
1451                         case PAPER_B2:
1452                         case PAPER_B3:
1453                         case PAPER_B4:
1454                         case PAPER_B6:
1455                         case PAPER_C0:
1456                         case PAPER_C1:
1457                         case PAPER_C2:
1458                         case PAPER_C3:
1459                         case PAPER_C4:
1460                         case PAPER_C5:
1461                         case PAPER_C6:
1462                         case PAPER_JISB0:
1463                         case PAPER_JISB1:
1464                         case PAPER_JISB2:
1465                         case PAPER_JISB3:
1466                         case PAPER_JISB4:
1467                         case PAPER_JISB5:
1468                         case PAPER_JISB6: break;
1469                         }
1470                         os << "\"\n";
1471                 }
1472                 if (tag != RC_LAST)
1473                         break;
1474         case RC_CHKTEX_COMMAND:
1475                 if (ignore_system_lyxrc ||
1476                     chktex_command != system_lyxrc.chktex_command) {
1477                         os << "\\chktex_command \"" << escapeCommand(chktex_command) << "\"\n";
1478                 }
1479                 if (tag != RC_LAST)
1480                         break;
1481         case RC_BIBTEX_ALTERNATIVES: {
1482                 CommandSet::const_iterator it = bibtex_alternatives.begin();
1483                 CommandSet::const_iterator end = bibtex_alternatives.end();
1484                 for ( ; it != end; ++it) {
1485                         if (ignore_system_lyxrc
1486                             || !system_lyxrc.bibtex_alternatives.count(*it))
1487                                 os << "\\bibtex_alternatives \""
1488                                    << *it << "\"\n";
1489                 }
1490                 if (tag != RC_LAST)
1491                         break;
1492         }
1493         case RC_BIBTEX_COMMAND:
1494                 if (ignore_system_lyxrc ||
1495                     bibtex_command != system_lyxrc.bibtex_command) {
1496                         os << "\\bibtex_command \"" << escapeCommand(bibtex_command) << "\"\n";
1497                 }
1498                 if (tag != RC_LAST)
1499                         break;
1500         case RC_JBIBTEX_COMMAND:
1501                 if (ignore_system_lyxrc ||
1502                     jbibtex_command != system_lyxrc.jbibtex_command) {
1503                         os << "\\jbibtex_command \"" << escapeCommand(jbibtex_command) << "\"\n";
1504                 }
1505                 if (tag != RC_LAST)
1506                         break;
1507         case RC_INDEX_ALTERNATIVES: {
1508                 CommandSet::const_iterator it = index_alternatives.begin();
1509                 CommandSet::const_iterator end = index_alternatives.end();
1510                 for ( ; it != end; ++it) {
1511                         if (ignore_system_lyxrc
1512                             || !system_lyxrc.index_alternatives.count(*it))
1513                                 os << "\\index_alternatives \""
1514                                    << *it << "\"\n";
1515                 }
1516                 if (tag != RC_LAST)
1517                         break;
1518         }
1519         case RC_INDEX_COMMAND:
1520                 if (ignore_system_lyxrc ||
1521                     index_command != system_lyxrc.index_command) {
1522                         os << "\\index_command \"" << escapeCommand(index_command) << "\"\n";
1523                 }
1524                 if (tag != RC_LAST)
1525                         break;
1526         case RC_JINDEX_COMMAND:
1527                 if (ignore_system_lyxrc ||
1528                     jindex_command != system_lyxrc.jindex_command) {
1529                         os << "\\jindex_command \"" << escapeCommand(jindex_command) << "\"\n";
1530                 }
1531                 if (tag != RC_LAST)
1532                         break;
1533         case RC_SPLITINDEX_COMMAND:
1534                 if (ignore_system_lyxrc ||
1535                     splitindex_command != system_lyxrc.splitindex_command) {
1536                         os << "\\splitindex_command \"" << escapeCommand(splitindex_command) << "\"\n";
1537                 }
1538                 if (tag != RC_LAST)
1539                         break;
1540         case RC_NOMENCL_COMMAND:
1541                 if (ignore_system_lyxrc ||
1542                     nomencl_command != system_lyxrc.nomencl_command) {
1543                         os << "\\nomencl_command \"" << escapeCommand(nomencl_command) << "\"\n";
1544                 }
1545                 if (tag != RC_LAST)
1546                         break;
1547         case RC_TEX_EXPECTS_WINDOWS_PATHS:
1548                 if (ignore_system_lyxrc ||
1549                     windows_style_tex_paths != system_lyxrc.windows_style_tex_paths) {
1550                         os << "\\tex_expects_windows_paths "
1551                            << convert<string>(windows_style_tex_paths) << '\n';
1552                 }
1553                 if (tag != RC_LAST)
1554                         break;
1555         case RC_TEX_ALLOWS_SPACES:
1556                 if (tex_allows_spaces != system_lyxrc.tex_allows_spaces) {
1557                         os << "\\tex_allows_spaces "
1558                            << convert<string>(tex_allows_spaces) << '\n';
1559                 }
1560                 if (tag != RC_LAST)
1561                         break;
1562         case RC_KBMAP:
1563                 if (ignore_system_lyxrc ||
1564                     use_kbmap != system_lyxrc.use_kbmap) {
1565                         os << "\\kbmap " << convert<string>(use_kbmap) << '\n';
1566                 }
1567                 if (tag != RC_LAST)
1568                         break;
1569         case RC_KBMAP_PRIMARY:
1570                 if (ignore_system_lyxrc ||
1571                     primary_kbmap != system_lyxrc.primary_kbmap) {
1572                         string const path = os::external_path(primary_kbmap);
1573                         os << "\\kbmap_primary \"" << path << "\"\n";
1574                 }
1575                 if (tag != RC_LAST)
1576                         break;
1577         case RC_KBMAP_SECONDARY:
1578                 if (ignore_system_lyxrc ||
1579                     secondary_kbmap != system_lyxrc.secondary_kbmap) {
1580                         string const path = os::external_path(secondary_kbmap);
1581                         os << "\\kbmap_secondary \"" << path << "\"\n";
1582                 }
1583                 if (tag != RC_LAST)
1584                         break;
1585         case RC_SERVERPIPE:
1586                 if (ignore_system_lyxrc ||
1587                     lyxpipes != system_lyxrc.lyxpipes) {
1588                         string const path = os::external_path(lyxpipes);
1589                         os << "\\serverpipe \"" << path << "\"\n";
1590                 }
1591                 if (tag != RC_LAST)
1592                         break;
1593         case RC_DATE_INSERT_FORMAT:
1594                 if (ignore_system_lyxrc ||
1595                     date_insert_format != system_lyxrc.date_insert_format) {
1596                         os << "\\date_insert_format \"" << date_insert_format
1597                            << "\"\n";
1598                 }
1599                 if (tag != RC_LAST)
1600                         break;
1601
1602         case RC_USER_NAME:
1603                 os << "\\user_name \"" << user_name << "\"\n";
1604                 if (tag != RC_LAST)
1605                         break;
1606
1607         case RC_USER_EMAIL:
1608                 os << "\\user_email \"" << user_email << "\"\n";
1609                 if (tag != RC_LAST)
1610                         break;
1611
1612         case RC_SHOW_BANNER:
1613                 if (ignore_system_lyxrc ||
1614                     show_banner != system_lyxrc.show_banner) {
1615                         os << "\\show_banner " << convert<string>(show_banner) << '\n';
1616                 }
1617                 if (tag != RC_LAST)
1618                         break;
1619
1620         case RC_PREVIEW:
1621                 if (ignore_system_lyxrc ||
1622                     preview != system_lyxrc.preview) {
1623                         string status;
1624                         switch (preview) {
1625                         case PREVIEW_ON:
1626                                 status = "on";
1627                                 break;
1628                         case PREVIEW_NO_MATH:
1629                                 status = "no_math";
1630                                 break;
1631                         case PREVIEW_OFF:
1632                                 status = "off";
1633                                 break;
1634                         }
1635                         os << "\\preview " << status << '\n';
1636                 }
1637                 if (tag != RC_LAST)
1638                         break;
1639
1640         case RC_PREVIEW_HASHED_LABELS:
1641                 if (ignore_system_lyxrc ||
1642                     preview_hashed_labels !=
1643                     system_lyxrc.preview_hashed_labels) {
1644                         os << "\\preview_hashed_labels "
1645                            << convert<string>(preview_hashed_labels) << '\n';
1646                 }
1647                 if (tag != RC_LAST)
1648                         break;
1649
1650         case RC_PREVIEW_SCALE_FACTOR:
1651                 if (ignore_system_lyxrc ||
1652                     preview_scale_factor != system_lyxrc.preview_scale_factor) {
1653                         os << "\\preview_scale_factor "
1654                            << preview_scale_factor << '\n';
1655                 }
1656                 if (tag != RC_LAST)
1657                         break;
1658
1659         case RC_USE_CONVERTER_CACHE:
1660                 if (ignore_system_lyxrc ||
1661                     use_converter_cache != system_lyxrc.use_converter_cache) {
1662                         os << "\\use_converter_cache "
1663                            << convert<string>(use_converter_cache) << '\n';
1664                 }
1665                 if (tag != RC_LAST)
1666                         break;
1667
1668         case RC_CONVERTER_CACHE_MAXAGE:
1669                 if (ignore_system_lyxrc ||
1670                     converter_cache_maxage != system_lyxrc.converter_cache_maxage) {
1671                         os << "\\converter_cache_maxage "
1672                            << converter_cache_maxage << '\n';
1673                 }
1674                 if (tag != RC_LAST)
1675                         break;
1676
1677                 os << "\n#\n"
1678                    << "# SCREEN & FONTS SECTION ############################\n"
1679                    << "#\n\n";
1680
1681         case RC_SCREEN_DPI:
1682                 if (ignore_system_lyxrc ||
1683                     dpi != system_lyxrc.dpi) {
1684                         os << "\\screen_dpi " << dpi << '\n';
1685                 }
1686                 if (tag != RC_LAST)
1687                         break;
1688         case RC_SCREEN_ZOOM:
1689                 if (ignore_system_lyxrc ||
1690                     zoom != system_lyxrc.zoom) {
1691                         os << "\\screen_zoom " << zoom << '\n';
1692                 }
1693                 if (tag != RC_LAST)
1694                         break;
1695         case RC_GEOMETRY_SESSION:
1696                 if (ignore_system_lyxrc ||
1697                     allow_geometry_session != system_lyxrc.allow_geometry_session) {
1698                         os << "\\allow_geometry_session " << convert<string>(allow_geometry_session)
1699                            << '\n';
1700                 }
1701                 if (tag != RC_LAST)
1702                         break;
1703         case RC_CURSOR_FOLLOWS_SCROLLBAR:
1704                 if (ignore_system_lyxrc ||
1705                     cursor_follows_scrollbar
1706                     != system_lyxrc.cursor_follows_scrollbar) {
1707                         os << "\\cursor_follows_scrollbar "
1708                            << convert<string>(cursor_follows_scrollbar) << '\n';
1709                 }
1710                 if (tag != RC_LAST)
1711                         break;
1712         case RC_SCROLL_BELOW_DOCUMENT:
1713                 if (ignore_system_lyxrc ||
1714                     scroll_below_document
1715                     != system_lyxrc.scroll_below_document) {
1716                         os << "\\scroll_below_document "
1717                            << convert<string>(scroll_below_document) << '\n';
1718                 }
1719                 if (tag != RC_LAST)
1720                         break;
1721         case RC_PARAGRAPH_MARKERS:
1722                 if (ignore_system_lyxrc ||
1723                         paragraph_markers
1724                     != system_lyxrc.paragraph_markers) {
1725                         os << "\\paragraph_markers "
1726                            << convert<string>(paragraph_markers) << '\n';
1727                 }
1728                 if (tag != RC_LAST)
1729                         break;
1730         case RC_MAC_LIKE_WORD_MOVEMENT:
1731                 if (ignore_system_lyxrc ||
1732                     mac_like_word_movement
1733                     != system_lyxrc.mac_like_word_movement) {
1734                         os << "\\mac_like_word_movement "
1735                            << convert<string>(mac_like_word_movement) << '\n';
1736                 }
1737                 if (tag != RC_LAST)
1738                         break;
1739         case RC_MACRO_EDIT_STYLE:
1740                 if (ignore_system_lyxrc ||
1741                     macro_edit_style
1742                     != system_lyxrc.macro_edit_style) {
1743                         os << "\\macro_edit_style ";
1744                         switch (macro_edit_style) {
1745                         case MACRO_EDIT_INLINE_BOX: os << "0\n"; break;
1746                         case MACRO_EDIT_INLINE: os << "1\n"; break;
1747                         case MACRO_EDIT_LIST: os << "2\n"; break;
1748                         }
1749                 }
1750                 if (tag != RC_LAST)
1751                         break;
1752         case RC_DIALOGS_ICONIFY_WITH_MAIN:
1753                 if (ignore_system_lyxrc ||
1754                     dialogs_iconify_with_main
1755                    != system_lyxrc.dialogs_iconify_with_main) {
1756                         os << "\\dialogs_iconify_with_main "
1757                           <<  convert<string>(dialogs_iconify_with_main) << '\n';
1758                 }
1759                 if (tag != RC_LAST)
1760                         break;
1761         case RC_SCREEN_FONT_ROMAN:
1762                 if (ignore_system_lyxrc ||
1763                     roman_font_name != system_lyxrc.roman_font_name) {
1764                         os << "\\screen_font_roman \"" << roman_font_name
1765                            << "\"\n";
1766                 }
1767                 if (tag != RC_LAST)
1768                         break;
1769         case RC_SCREEN_FONT_ROMAN_FOUNDRY:
1770                 if (ignore_system_lyxrc ||
1771                     roman_font_foundry != system_lyxrc.roman_font_foundry) {
1772                         os << "\\screen_font_roman_foundry \"" << roman_font_foundry
1773                            << "\"\n";
1774                 }
1775                 if (tag != RC_LAST)
1776                         break;
1777         case RC_SCREEN_FONT_SANS:
1778                 if (ignore_system_lyxrc ||
1779                     sans_font_name != system_lyxrc.sans_font_name) {
1780                         os << "\\screen_font_sans \"" << sans_font_name
1781                            << "\"\n";
1782                 }
1783                 if (tag != RC_LAST)
1784                         break;
1785         case RC_SCREEN_FONT_SANS_FOUNDRY:
1786                 if (ignore_system_lyxrc ||
1787                     sans_font_foundry != system_lyxrc.sans_font_foundry) {
1788                         os << "\\screen_font_sans_foundry \"" << sans_font_foundry
1789                            << "\"\n";
1790                 }
1791                 if (tag != RC_LAST)
1792                         break;
1793         case RC_SCREEN_FONT_TYPEWRITER:
1794                 if (ignore_system_lyxrc ||
1795                     typewriter_font_name != system_lyxrc.typewriter_font_name) {
1796                         os << "\\screen_font_typewriter \""
1797                            << typewriter_font_name << "\"\n";
1798                 }
1799                 if (tag != RC_LAST)
1800                         break;
1801         case RC_SCREEN_FONT_TYPEWRITER_FOUNDRY:
1802                 if (ignore_system_lyxrc ||
1803                     typewriter_font_foundry != system_lyxrc.typewriter_font_foundry) {
1804                         os << "\\screen_font_typewriter_foundry \""
1805                            << typewriter_font_foundry << "\"\n";
1806                 }
1807                 if (tag != RC_LAST)
1808                         break;
1809
1810         case RC_SCREEN_FONT_SCALABLE:
1811                 if (ignore_system_lyxrc ||
1812                     use_scalable_fonts != system_lyxrc.use_scalable_fonts) {
1813                         os << "\\screen_font_scalable "
1814                            << convert<string>(use_scalable_fonts)
1815                            << '\n';
1816                 }
1817                 if (tag != RC_LAST)
1818                         break;
1819         case RC_SCREEN_FONT_SIZES:
1820                 if (ignore_system_lyxrc ||
1821                     font_sizes[FONT_SIZE_TINY]
1822                     != system_lyxrc.font_sizes[FONT_SIZE_TINY] ||
1823                     font_sizes[FONT_SIZE_SCRIPT]
1824                     != system_lyxrc.font_sizes[FONT_SIZE_SCRIPT] ||
1825                     font_sizes[FONT_SIZE_FOOTNOTE]
1826                     != system_lyxrc.font_sizes[FONT_SIZE_FOOTNOTE] ||
1827                     font_sizes[FONT_SIZE_SMALL]
1828                     != system_lyxrc.font_sizes[FONT_SIZE_SMALL] ||
1829                     font_sizes[FONT_SIZE_NORMAL]
1830                     != system_lyxrc.font_sizes[FONT_SIZE_NORMAL] ||
1831                     font_sizes[FONT_SIZE_LARGE]
1832                     != system_lyxrc.font_sizes[FONT_SIZE_LARGE] ||
1833                     font_sizes[FONT_SIZE_LARGER]
1834                     != system_lyxrc.font_sizes[FONT_SIZE_LARGER] ||
1835                     font_sizes[FONT_SIZE_LARGEST]
1836                     != system_lyxrc.font_sizes[FONT_SIZE_LARGEST] ||
1837                     font_sizes[FONT_SIZE_HUGE]
1838                     != system_lyxrc.font_sizes[FONT_SIZE_HUGE] ||
1839                     font_sizes[FONT_SIZE_HUGER]
1840                     != system_lyxrc.font_sizes[FONT_SIZE_HUGER]) {
1841                         os.setf(ios::fixed);
1842                         os.precision(2);
1843                         os << "\\screen_font_sizes"
1844                            << ' ' << font_sizes[FONT_SIZE_TINY]
1845                            << ' ' << font_sizes[FONT_SIZE_SCRIPT]
1846                            << ' ' << font_sizes[FONT_SIZE_FOOTNOTE]
1847                            << ' ' << font_sizes[FONT_SIZE_SMALL]
1848                            << ' ' << font_sizes[FONT_SIZE_NORMAL]
1849                            << ' ' << font_sizes[FONT_SIZE_LARGE]
1850                            << ' ' << font_sizes[FONT_SIZE_LARGER]
1851                            << ' ' << font_sizes[FONT_SIZE_LARGEST]
1852                            << ' ' << font_sizes[FONT_SIZE_HUGE]
1853                            << ' ' << font_sizes[FONT_SIZE_HUGER]
1854                            << '\n';
1855                 }
1856                 if (tag != RC_LAST)
1857                         break;
1858         case RC_FULL_SCREEN_LIMIT:
1859                 if (ignore_system_lyxrc ||
1860                     full_screen_limit != system_lyxrc.full_screen_limit) {
1861                         os << "\\fullscreen_limit "
1862                            << convert<string>(full_screen_limit)
1863                            << '\n';
1864                 }
1865                 if (tag != RC_LAST)
1866                         break;
1867         case RC_FULL_SCREEN_TOOLBARS:
1868                 if (ignore_system_lyxrc ||
1869                     full_screen_toolbars != system_lyxrc.full_screen_toolbars) {
1870                         os << "\\fullscreen_toolbars "
1871                            << convert<string>(full_screen_toolbars)
1872                            << '\n';
1873                 }
1874                 if (tag != RC_LAST)
1875                         break;
1876         case RC_FULL_SCREEN_SCROLLBAR:
1877                 if (ignore_system_lyxrc ||
1878                     full_screen_scrollbar != system_lyxrc.full_screen_scrollbar) {
1879                         os << "\\fullscreen_scrollbar "
1880                            << convert<string>(full_screen_scrollbar)
1881                            << '\n';
1882                 }
1883                 if (tag != RC_LAST)
1884                         break;
1885         case RC_FULL_SCREEN_TABBAR:
1886                 if (ignore_system_lyxrc ||
1887                     full_screen_tabbar != system_lyxrc.full_screen_tabbar) {
1888                         os << "\\fullscreen_tabbar "
1889                            << convert<string>(full_screen_tabbar)
1890                            << '\n';
1891                 }
1892                 if (tag != RC_LAST)
1893                         break;
1894         case RC_FULL_SCREEN_MENUBAR:
1895                 if (ignore_system_lyxrc ||
1896                     full_screen_menubar != system_lyxrc.full_screen_menubar) {
1897                         os << "\\fullscreen_menubar "
1898                            << convert<string>(full_screen_menubar)
1899                            << '\n';
1900                 }
1901                 if (tag != RC_LAST)
1902                         break;
1903         case RC_FULL_SCREEN_WIDTH:
1904                 if (ignore_system_lyxrc ||
1905                     full_screen_width != system_lyxrc.full_screen_width) {
1906                         os << "\\fullscreen_width "
1907                            << convert<string>(full_screen_width)
1908                            << '\n';
1909                 }
1910                 if (tag != RC_LAST)
1911                         break;
1912         case RC_OPEN_BUFFERS_IN_TABS:
1913                 if (ignore_system_lyxrc ||
1914                     open_buffers_in_tabs != system_lyxrc.open_buffers_in_tabs) {
1915                         os << "\\open_buffers_in_tabs "
1916                            << convert<string>(open_buffers_in_tabs)
1917                            << '\n';
1918                 }
1919                 if (tag != RC_LAST)
1920                         break;
1921         case RC_SINGLE_CLOSE_TAB_BUTTON:
1922                 if (ignore_system_lyxrc ||
1923                     single_close_tab_button != system_lyxrc.single_close_tab_button) {
1924                         os << "\\single_close_tab_button "
1925                            << convert<string>(single_close_tab_button)
1926                            << '\n';
1927                 }
1928                 if (tag != RC_LAST)
1929                         break;
1930         case RC_FORWARD_SEARCH_DVI:
1931                 if (ignore_system_lyxrc ||
1932                     forward_search_dvi != system_lyxrc.forward_search_dvi) {
1933                         os << "\\forward_search_dvi \"" << escapeCommand(forward_search_dvi) << "\"\n";
1934                 }
1935                 if (tag != RC_LAST)
1936                         break;
1937         case RC_FORWARD_SEARCH_PDF:
1938                 if (ignore_system_lyxrc ||
1939                     forward_search_pdf != system_lyxrc.forward_search_pdf) {
1940                         os << "\\forward_search_pdf \"" << escapeCommand(forward_search_pdf) << "\"\n";
1941                 }
1942                 if (tag != RC_LAST)
1943                         break;
1944
1945         os << "\n#\n"
1946                         << "# COLOR SECTION ###################################\n"
1947                         << "#\n\n";
1948
1949         case RC_SET_COLOR:
1950                 for (int i = 0; i < Color_ignore; ++i) {
1951                         ColorCode lc = static_cast<ColorCode>(i);
1952                         string const col = lcolor.getX11Name(lc);
1953                         if (ignore_system_lyxrc
1954                             || col != system_lcolor.getX11Name(lc)) {
1955                                 os << "\\set_color \""
1956                                    << lcolor.getLyXName(lc) << "\" \""
1957                                    << col << "\"\n";
1958                         }
1959                 }
1960                 if (tag != RC_LAST)
1961                         break;
1962
1963                 os << "\n#\n"
1964                    << "# PRINTER SECTION ###################################\n"
1965                    << "#\n\n";
1966
1967         case RC_PRINTER:
1968                 if (ignore_system_lyxrc ||
1969                     printer != system_lyxrc.printer) {
1970                         os << "\\printer \"" << printer << "\"\n";
1971                 }
1972                 if (tag != RC_LAST)
1973                         break;
1974         case RC_PRINT_ADAPTOUTPUT:
1975                 if (ignore_system_lyxrc ||
1976                     print_adapt_output != system_lyxrc.print_adapt_output) {
1977                         os << "\\print_adapt_output "
1978                            << convert<string>(print_adapt_output)
1979                            << '\n';
1980                 }
1981                 if (tag != RC_LAST)
1982                         break;
1983         case RC_PRINT_COMMAND:
1984                 if (ignore_system_lyxrc ||
1985                     print_command != system_lyxrc.print_command) {
1986                         os << "\\print_command \"" << escapeCommand(print_command) << "\"\n";
1987                 }
1988                 if (tag != RC_LAST)
1989                         break;
1990         case RC_PRINTEXSTRAOPTIONS:
1991                 if (ignore_system_lyxrc ||
1992                     print_extra_options != system_lyxrc.print_extra_options) {
1993                         os << "\\print_extra_options \"" << print_extra_options
1994                            << "\"\n";
1995                 }
1996                 if (tag != RC_LAST)
1997                         break;
1998         case RC_PRINTSPOOL_COMMAND:
1999                 if (ignore_system_lyxrc ||
2000                     print_spool_command != system_lyxrc.print_spool_command) {
2001                         os << "\\print_spool_command \"" << escapeCommand(print_spool_command)
2002                            << "\"\n";
2003                 }
2004                 if (tag != RC_LAST)
2005                         break;
2006         case RC_PRINTSPOOL_PRINTERPREFIX:
2007                 if (ignore_system_lyxrc ||
2008                     print_spool_printerprefix
2009                     != system_lyxrc.print_spool_printerprefix) {
2010                         os << "\\print_spool_printerprefix \""
2011                            << print_spool_printerprefix << "\"\n";
2012                 }
2013                 if (tag != RC_LAST)
2014                         break;
2015         case RC_PRINTEVENPAGEFLAG:
2016                 if (ignore_system_lyxrc ||
2017                     print_evenpage_flag != system_lyxrc.print_evenpage_flag) {
2018                         os << "\\print_evenpage_flag \"" << print_evenpage_flag
2019                            << "\"\n";
2020                 }
2021                 if (tag != RC_LAST)
2022                         break;
2023         case RC_PRINTODDPAGEFLAG:
2024                 if (ignore_system_lyxrc ||
2025                     print_oddpage_flag != system_lyxrc.print_oddpage_flag) {
2026                         os << "\\print_oddpage_flag \"" << print_oddpage_flag
2027                            << "\"\n";
2028                 }
2029                 if (tag != RC_LAST)
2030                         break;
2031         case RC_PRINTREVERSEFLAG:
2032                 if (ignore_system_lyxrc ||
2033                     print_reverse_flag != system_lyxrc.print_reverse_flag) {
2034                         os << "\\print_reverse_flag \"" << print_reverse_flag
2035                            << "\"\n";
2036                 }
2037                 if (tag != RC_LAST)
2038                         break;
2039         case RC_PRINTLANDSCAPEFLAG:
2040                 if (ignore_system_lyxrc ||
2041                     print_landscape_flag != system_lyxrc.print_landscape_flag) {
2042                         os << "\\print_landscape_flag \"" << print_landscape_flag
2043                            << "\"\n";
2044                 }
2045                 if (tag != RC_LAST)
2046                         break;
2047         case RC_PRINTPAGERANGEFLAG:
2048                 if (ignore_system_lyxrc ||
2049                     print_pagerange_flag != system_lyxrc.print_pagerange_flag) {
2050                         os << "\\print_pagerange_flag \"" << print_pagerange_flag
2051                            << "\"\n";
2052                 }
2053                 if (tag != RC_LAST)
2054                         break;
2055         case RC_PRINTCOPIESFLAG:
2056                 if (ignore_system_lyxrc ||
2057                     print_copies_flag != system_lyxrc.print_copies_flag) {
2058                         os << "\\print_copies_flag \"" << print_copies_flag
2059                            << "\"\n";
2060                 }
2061                 if (tag != RC_LAST)
2062                         break;
2063         case RC_PRINTCOLLCOPIESFLAG:
2064                 if (ignore_system_lyxrc ||
2065                     print_collcopies_flag
2066                     != system_lyxrc.print_collcopies_flag) {
2067                         os << "\\print_collcopies_flag \""
2068                            << print_collcopies_flag
2069                            << "\"\n";
2070                 }
2071                 if (tag != RC_LAST)
2072                         break;
2073         case RC_PRINTPAPERFLAG:
2074                 if (ignore_system_lyxrc ||
2075                     print_paper_flag != system_lyxrc.print_paper_flag) {
2076                         os << "\\print_paper_flag \"" << print_paper_flag
2077                            << "\"\n";
2078                 }
2079                 if (tag != RC_LAST)
2080                         break;
2081         case RC_PRINTPAPERDIMENSIONFLAG:
2082                 if (ignore_system_lyxrc ||
2083                     print_paper_dimension_flag
2084                     != system_lyxrc.print_paper_dimension_flag) {
2085                         os << "\\print_paper_dimension_flag \""
2086                            << print_paper_dimension_flag << "\"\n";
2087                 }
2088                 if (tag != RC_LAST)
2089                         break;
2090         case RC_PRINTTOPRINTER:
2091                 if (ignore_system_lyxrc ||
2092                     print_to_printer != system_lyxrc.print_to_printer) {
2093                         os << "\\print_to_printer \"" << print_to_printer
2094                            << "\"\n";
2095                 }
2096                 if (tag != RC_LAST)
2097                         break;
2098         case RC_PRINTTOFILE:
2099                 if (ignore_system_lyxrc ||
2100                     print_to_file != system_lyxrc.print_to_file) {
2101                         string const path = os::external_path(print_to_file);
2102                         os << "\\print_to_file \"" << path << "\"\n";
2103                 }
2104                 if (tag != RC_LAST)
2105                         break;
2106         case RC_PRINTFILEEXTENSION:
2107                 if (ignore_system_lyxrc ||
2108                     print_file_extension != system_lyxrc.print_file_extension) {
2109                         os << "\\print_file_extension \""
2110                            << print_file_extension
2111                            << "\"\n";
2112                 }
2113                 if (tag != RC_LAST)
2114                         break;
2115
2116                 os << "\n#\n"
2117                    << "# TEX SECTION #######################################\n"
2118                    << "#\n\n";
2119
2120         case RC_FONT_ENCODING:
2121                 if (ignore_system_lyxrc ||
2122                     fontenc != system_lyxrc.fontenc) {
2123                         os << "\\font_encoding \"" << fontenc << "\"\n";
2124                 }
2125                 if (tag != RC_LAST)
2126                         break;
2127
2128                 os << "\n#\n"
2129                    << "# FILE SECTION ######################################\n"
2130                    << "#\n\n";
2131
2132         case RC_DOCUMENTPATH:
2133                 if (ignore_system_lyxrc ||
2134                     document_path != system_lyxrc.document_path) {
2135                         string const path = os::external_path(document_path);
2136                         os << "\\document_path \"" << path << "\"\n";
2137                 }
2138                 if (tag != RC_LAST)
2139                         break;
2140         case RC_USELASTFILEPOS:
2141                 if (ignore_system_lyxrc ||
2142                     use_lastfilepos != system_lyxrc.use_lastfilepos) {
2143                         os << "\\use_lastfilepos " << convert<string>(use_lastfilepos)
2144                            << '\n';
2145                 }
2146                 if (tag != RC_LAST)
2147                         break;
2148         case RC_LOADSESSION:
2149                 if (ignore_system_lyxrc ||
2150                     load_session != system_lyxrc.load_session) {
2151                         os << "\\load_session " << convert<string>(load_session)
2152                            << "\n";
2153                 }
2154                 if (tag != RC_LAST)
2155                         break;
2156         case RC_MOUSE_WHEEL_SPEED:
2157                 if (ignore_system_lyxrc ||
2158                     mouse_wheel_speed != system_lyxrc.mouse_wheel_speed) {
2159                         os << "\\mouse_wheel_speed " << mouse_wheel_speed << '\n';
2160                 }
2161                 if (tag != RC_LAST)
2162                         break;
2163         case RC_COMPLETION_INLINE_DELAY:
2164                 if (ignore_system_lyxrc ||
2165                     completion_inline_delay != system_lyxrc.completion_inline_delay) {
2166                         os << "\\completion_inline_delay " << completion_inline_delay << '\n';
2167                 }
2168                 if (tag != RC_LAST)
2169                         break;
2170         case RC_COMPLETION_INLINE_MATH:
2171                 if (ignore_system_lyxrc ||
2172                     completion_inline_math != system_lyxrc.completion_inline_math) {
2173                         os << "\\completion_inline_math "
2174                                 << convert<string>(completion_inline_math) << '\n';
2175                 }
2176                 if (tag != RC_LAST)
2177                         break;
2178         case RC_COMPLETION_INLINE_TEXT:
2179                 if (ignore_system_lyxrc ||
2180                     completion_inline_text != system_lyxrc.completion_inline_text) {
2181                         os << "\\completion_inline_text "
2182                                 << convert<string>(completion_inline_text) << '\n';
2183                 }
2184                 if (tag != RC_LAST)
2185                         break;
2186         case RC_COMPLETION_INLINE_DOTS:
2187                 if (ignore_system_lyxrc ||
2188                     completion_inline_dots != system_lyxrc.completion_inline_dots) {
2189                         os << "\\completion_inline_dots "
2190                                 << convert<string>(completion_inline_dots) << '\n';
2191                 }
2192                 if (tag != RC_LAST)
2193                         break;
2194         case RC_AUTOCORRECTION_MATH:
2195                 if (ignore_system_lyxrc ||
2196                     autocorrection_math != system_lyxrc.autocorrection_math) {
2197                         os << "\\autocorrection_math "
2198                                 << convert<string>(autocorrection_math) << '\n';
2199                 }
2200                 if (tag != RC_LAST)
2201                         break;
2202         case RC_COMPLETION_POPUP_DELAY:
2203                 if (ignore_system_lyxrc ||
2204                     completion_popup_delay != system_lyxrc.completion_popup_delay) {
2205                         os << "\\completion_popup_delay " << completion_popup_delay << '\n';
2206                 }
2207                 if (tag != RC_LAST)
2208                         break;
2209         case RC_COMPLETION_POPUP_MATH:
2210                 if (ignore_system_lyxrc ||
2211                     completion_popup_math != system_lyxrc.completion_popup_math) {
2212                         os << "\\completion_popup_math "
2213                                 << convert<string>(completion_popup_math) << '\n';
2214                 }
2215                 if (tag != RC_LAST)
2216                         break;
2217         case RC_COMPLETION_POPUP_TEXT:
2218                 if (ignore_system_lyxrc ||
2219                     completion_popup_text != system_lyxrc.completion_popup_text) {
2220                         os << "\\completion_popup_text "
2221                                 << convert<string>(completion_popup_text) << '\n';
2222                 }
2223                 if (tag != RC_LAST)
2224                         break;
2225         case RC_COMPLETION_CURSOR_TEXT:
2226                 if (ignore_system_lyxrc ||
2227                     completion_cursor_text != system_lyxrc.completion_cursor_text) {
2228                         os << "\\completion_cursor_text "
2229                            << convert<string>(completion_cursor_text) << '\n';
2230                 }
2231                 if (tag != RC_LAST)
2232                         break;
2233         case RC_COMPLETION_POPUP_AFTER_COMPLETE:
2234                 if (ignore_system_lyxrc ||
2235                     completion_popup_after_complete
2236                     != system_lyxrc.completion_popup_after_complete) {
2237                         os << "\\completion_popup_after_complete "
2238                                 << convert<string>(completion_popup_after_complete) << '\n';
2239                 }
2240                 if (tag != RC_LAST)
2241                         break;
2242         case RC_NUMLASTFILES:
2243                 if (ignore_system_lyxrc ||
2244                     num_lastfiles != system_lyxrc.num_lastfiles) {
2245                         os << "\\num_lastfiles " << num_lastfiles << '\n';
2246                 }
2247                 if (tag != RC_LAST)
2248                         break;
2249         case RC_CHECKLASTFILES:
2250                 if (ignore_system_lyxrc ||
2251                     check_lastfiles != system_lyxrc.check_lastfiles) {
2252                         os << "\\check_lastfiles " << convert<string>(check_lastfiles)
2253                            << '\n';
2254                 }
2255                 if (tag != RC_LAST)
2256                         break;
2257         case RC_EXAMPLEPATH:
2258                 if (ignore_system_lyxrc ||
2259                     example_path != system_lyxrc.example_path) {
2260                         string const path = os::external_path(example_path);
2261                         os << "\\example_path \"" << path << "\"\n";
2262                 }
2263                 if (tag != RC_LAST)
2264                         break;
2265         case RC_TEMPLATEPATH:
2266                 if (ignore_system_lyxrc ||
2267                     template_path != system_lyxrc.template_path) {
2268                         string const path = os::external_path(template_path);
2269                         os << "\\template_path \"" << path << "\"\n";
2270                 }
2271                 if (tag != RC_LAST)
2272                         break;
2273         case RC_TEMPDIRPATH:
2274                 if (ignore_system_lyxrc ||
2275                     tempdir_path != system_lyxrc.tempdir_path) {
2276                         string const path = os::external_path(tempdir_path);
2277                         os << "\\tempdir_path \"" << path << "\"\n";
2278                 }
2279                 if (tag != RC_LAST)
2280                         break;
2281         case RC_THESAURUSDIRPATH:
2282                 if (ignore_system_lyxrc ||
2283                     thesaurusdir_path != system_lyxrc.thesaurusdir_path) {
2284                         string const path = os::external_path(thesaurusdir_path);
2285                         os << "\\thesaurusdir_path \"" << path << "\"\n";
2286                 }
2287                 if (tag != RC_LAST)
2288                         break;
2289         case RC_HUNSPELLDIR_PATH:
2290                 if (ignore_system_lyxrc ||
2291                     hunspelldir_path != system_lyxrc.hunspelldir_path) {
2292                         string const path = os::external_path(hunspelldir_path);
2293                         os << "\\hunspelldir_path \"" << path << "\"\n";
2294                 }
2295                 if (tag != RC_LAST)
2296                         break;
2297         case RC_USETEMPDIR:
2298                 if (tag != RC_LAST)
2299                         break;
2300                 // Ignore it
2301         case RC_PLAINTEXT_ROFF_COMMAND: // Obsoleted in 2.0
2302                 if (tag != RC_LAST)
2303                         break;
2304         case RC_PLAINTEXT_LINELEN:
2305                 if (ignore_system_lyxrc ||
2306                     plaintext_linelen != system_lyxrc.plaintext_linelen) {
2307                         os << "\\plaintext_linelen " << plaintext_linelen << '\n';
2308                 }
2309                 if (tag != RC_LAST)
2310                         break;
2311         case RC_MAKE_BACKUP:
2312                 if (ignore_system_lyxrc ||
2313                     make_backup != system_lyxrc.make_backup) {
2314                         os << "\\make_backup " << convert<string>(make_backup) << '\n';
2315                 }
2316                 if (tag != RC_LAST)
2317                         break;
2318         case RC_SAVE_COMPRESSED:
2319                 if (ignore_system_lyxrc ||
2320                     save_compressed != system_lyxrc.save_compressed) {
2321                         os << "\\save_compressed " << convert<string>(save_compressed) << '\n';
2322                 }
2323                 if (tag != RC_LAST)
2324                         break;
2325         case RC_BACKUPDIR_PATH:
2326                 if (ignore_system_lyxrc ||
2327                     backupdir_path != system_lyxrc.backupdir_path) {
2328                         string const path = os::external_path(backupdir_path);
2329                         os << "\\backupdir_path \"" << path << "\"\n";
2330                 }
2331                 if (tag != RC_LAST)
2332                         break;
2333
2334                 os << "\n#\n"
2335                    << "# PLAIN TEXT EXPORT SECTION ##############################\n"
2336                    << "#\n\n";
2337
2338                 os << "\n#\n"
2339                    << "# SPELLCHECKER SECTION ##############################\n"
2340                    << "#\n\n";
2341
2342         case RC_SPELL_COMMAND:
2343         case RC_USE_SPELL_LIB:
2344                 // Obsoleted in 2.0
2345                 if (tag != RC_LAST)
2346                         break;
2347         case RC_ACCEPT_COMPOUND:
2348                 if (ignore_system_lyxrc ||
2349                     spellchecker_accept_compound != system_lyxrc.spellchecker_accept_compound) {
2350                         os << "\\accept_compound " << convert<string>(spellchecker_accept_compound)
2351                            << '\n';
2352                 }
2353                 if (tag != RC_LAST)
2354                         break;
2355         case RC_USE_ALT_LANG:
2356                 // Obsoleted in 2.0
2357                 if (tag != RC_LAST)
2358                         break;
2359         case RC_ALT_LANG:
2360                 if (ignore_system_lyxrc ||
2361                     spellchecker_alt_lang != system_lyxrc.spellchecker_alt_lang) {
2362                         os << "\\alternate_language \"" << spellchecker_alt_lang
2363                            << "\"\n";
2364                 }
2365                 if (tag != RC_LAST)
2366                         break;
2367         case RC_USE_ESC_CHARS:
2368                 if (tag != RC_LAST)
2369                         break;
2370         case RC_ESC_CHARS:
2371                 if (ignore_system_lyxrc ||
2372                     spellchecker_esc_chars != system_lyxrc.spellchecker_esc_chars) {
2373                         os << "\\escape_chars \"" << spellchecker_esc_chars << "\"\n";
2374                 }
2375                 if (tag != RC_LAST)
2376                         break;
2377         case RC_USE_PERS_DICT:
2378                 // obsoleted in 2.0
2379                 if (tag != RC_LAST)
2380                         break;
2381         case RC_USE_TOOLTIP:
2382                 if (ignore_system_lyxrc ||
2383                     use_tooltip != system_lyxrc.use_tooltip) {
2384                         os << "\\use_tooltip "
2385                            << convert<string>(use_tooltip)
2386                            << '\n';
2387                 }
2388                 if (tag != RC_LAST)
2389                         break;
2390         case RC_USE_PIXMAP_CACHE:
2391                 if (ignore_system_lyxrc ||
2392                     use_pixmap_cache != system_lyxrc.use_pixmap_cache) {
2393                         os << "\\use_pixmap_cache "
2394                            << convert<string>(use_pixmap_cache)
2395                            << '\n';
2396                 }
2397                 if (tag != RC_LAST)
2398                         break;
2399         case RC_PERS_DICT:
2400                 // obsoleted in 2.0
2401                 if (tag != RC_LAST)
2402                         break;
2403         case RC_USE_INP_ENC:
2404                 // obsoleted in 2.0
2405                 if (tag != RC_LAST)
2406                         break;
2407
2408                 os << "\n#\n"
2409                    << "# LANGUAGE SUPPORT SECTION ##########################\n"
2410                    << "#\n\n";
2411                 if (tag != RC_LAST)
2412                         break;
2413
2414         case RC_DEFAULT_DECIMAL_POINT:
2415                 if (ignore_system_lyxrc ||
2416                     default_decimal_point != system_lyxrc.default_decimal_point) {
2417                         os << "\\default_decimal_point " << default_decimal_point << '\n';
2418                 }
2419                 if (tag != RC_LAST)
2420                         break;
2421
2422         case RC_SPELLCHECKER:
2423                 if (ignore_system_lyxrc ||
2424                     spellchecker != system_lyxrc.spellchecker) {
2425                         os << "\\spellchecker " << spellchecker << '\n';
2426                 }
2427                 if (tag != RC_LAST)
2428                         break;
2429
2430         case RC_SPELLCHECK_CONTINUOUSLY:
2431                 if (ignore_system_lyxrc ||
2432                     spellcheck_continuously != system_lyxrc.spellcheck_continuously) {
2433                         os << "\\spellcheck_continuously " << convert<string>(spellcheck_continuously)
2434                            << '\n';
2435                 }
2436                 if (tag != RC_LAST)
2437                         break;
2438
2439         case RC_SPELL_MINLENGTH:
2440                 if (ignore_system_lyxrc ||
2441                     spellcheck_minlength != system_lyxrc.spellcheck_minlength) {
2442                         os << "\\spellcheck_minlength " << convert<string>(spellcheck_minlength)
2443                            << '\n';
2444                 }
2445                 if (tag != RC_LAST)
2446                         break;
2447
2448         case RC_SPELLCHECK_NOTES:
2449                 if (ignore_system_lyxrc ||
2450                     spellcheck_notes != system_lyxrc.spellcheck_notes) {
2451                         os << "\\spellcheck_notes " << convert<string>(spellcheck_notes)
2452                            << '\n';
2453                 }
2454                 if (tag != RC_LAST)
2455                         break;
2456
2457         case RC_RTL_SUPPORT:
2458                 if (ignore_system_lyxrc ||
2459                     rtl_support != system_lyxrc.rtl_support) {
2460                         os << "\\rtl " << convert<string>(rtl_support) << '\n';
2461                 }
2462                 if (tag != RC_LAST)
2463                         break;
2464         case RC_VISUAL_CURSOR:
2465                 if (ignore_system_lyxrc ||
2466                         visual_cursor != system_lyxrc.visual_cursor) {
2467                         os << "\\visual_cursor " << convert<string>(visual_cursor) << '\n';
2468                 }
2469                 if (tag != RC_LAST)
2470                         break;
2471         case RC_LANGUAGE_PACKAGE:
2472                 if (ignore_system_lyxrc ||
2473                     language_package != system_lyxrc.language_package) {
2474                         os << "\\language_package \"" << language_package
2475                            << "\"\n";
2476                 }
2477                 if (tag != RC_LAST)
2478                         break;
2479         case RC_LANGUAGE_GLOBAL_OPTIONS:
2480                 if (ignore_system_lyxrc ||
2481                     language_global_options
2482                     != system_lyxrc.language_global_options) {
2483                         os << "\\language_global_options \""
2484                            << convert<string>(language_global_options)
2485                            << "\"\n";
2486                 }
2487                 if (tag != RC_LAST)
2488                         break;
2489         case RC_LANGUAGE_USE_BABEL:
2490                 if (ignore_system_lyxrc ||
2491                     language_use_babel != system_lyxrc.language_use_babel) {
2492                         os << "\\language_use_babel \""
2493                            << convert<string>(language_use_babel)
2494                            << "\"\n";
2495                 }
2496                 if (tag != RC_LAST)
2497                         break;
2498         case RC_LANGUAGE_COMMAND_BEGIN:
2499                 if (ignore_system_lyxrc ||
2500                     language_command_begin
2501                     != system_lyxrc.language_command_begin) {
2502                         os << "\\language_command_begin \""
2503                            << language_command_begin
2504                            << "\"\n";
2505                 }
2506                 if (tag != RC_LAST)
2507                         break;
2508         case RC_LANGUAGE_COMMAND_END:
2509                 if (ignore_system_lyxrc ||
2510                     language_command_end
2511                     != system_lyxrc.language_command_end) {
2512                         os << "\\language_command_end \"" << language_command_end
2513                            << "\"\n";
2514                 }
2515                 if (tag != RC_LAST)
2516                         break;
2517         case RC_LANGUAGE_COMMAND_LOCAL:
2518                 if (ignore_system_lyxrc ||
2519                     language_command_local
2520                     != system_lyxrc.language_command_local) {
2521                         os << "\\language_command_local \""
2522                            << language_command_local
2523                            << "\"\n";
2524                 }
2525                 if (tag != RC_LAST)
2526                         break;
2527         case RC_LANGUAGE_AUTO_BEGIN:
2528                 if (ignore_system_lyxrc ||
2529                     language_auto_begin != system_lyxrc.language_auto_begin) {
2530                         os << "\\language_auto_begin "
2531                            << convert<string>(language_auto_begin) << '\n';
2532                 }
2533                 if (tag != RC_LAST)
2534                         break;
2535         case RC_LANGUAGE_AUTO_END:
2536                 if (ignore_system_lyxrc ||
2537                     language_auto_end != system_lyxrc.language_auto_end) {
2538                         os << "\\language_auto_end "
2539                            << convert<string>(language_auto_end) << '\n';
2540                 }
2541                 if (tag != RC_LAST)
2542                         break;
2543         case RC_MARK_FOREIGN_LANGUAGE:
2544                 if (ignore_system_lyxrc ||
2545                     mark_foreign_language
2546                     != system_lyxrc.mark_foreign_language) {
2547                         os << "\\mark_foreign_language " <<
2548                                 convert<string>(mark_foreign_language) << '\n';
2549                 }
2550                 if (tag != RC_LAST)
2551                         break;
2552
2553                 os << "\n#\n"
2554                    << "# 2nd MISC SUPPORT SECTION ##########################\n"
2555                    << "#\n\n";
2556
2557         case RC_AUTO_NUMBER:
2558                 if (ignore_system_lyxrc ||
2559                     auto_number != system_lyxrc.auto_number) {
2560                         os << "\\auto_number " << convert<string>(auto_number) << '\n';
2561                 }
2562                 if (tag != RC_LAST)
2563                         break;
2564         case RC_DEFAULT_LANGUAGE:
2565                 if (ignore_system_lyxrc ||
2566                     default_language != system_lyxrc.default_language) {
2567                         os << "\\default_language " << default_language << '\n';
2568                 }
2569                 if (tag != RC_LAST)
2570                         break;
2571         case RC_GUI_LANGUAGE:
2572                 if (ignore_system_lyxrc ||
2573                     gui_language != system_lyxrc.gui_language) {
2574                         os << "\\gui_language " << gui_language << '\n';
2575                 }
2576                 if (tag != RC_LAST)
2577                         break;
2578         case RC_EXPORT_OVERWRITE:
2579                 if (ignore_system_lyxrc ||
2580                     export_overwrite != system_lyxrc.export_overwrite) {
2581                         string status;
2582                         switch (export_overwrite) {
2583                         case NO_FILES:
2584                                 status = "ask";
2585                                 break;
2586                         case MAIN_FILE:
2587                                 status = "main";
2588                                 break;
2589                         case ALL_FILES:
2590                                 status = "all";
2591                                 break;
2592                         }
2593                         os << "\\export_overwrite " << status << '\n';
2594                 }
2595                 if (tag != RC_LAST)
2596                         break;
2597
2598                 os << "\n#\n"
2599                    << "# FORMATS SECTION ##########################\n"
2600                    << "#\n\n";
2601
2602         case RC_FORMAT:
2603                 // New/modified formats
2604                 for (Formats::const_iterator cit = formats.begin();
2605                      cit != formats.end(); ++cit) {
2606                         Format const * format =
2607                                 system_formats.getFormat(cit->name());
2608                         if (!format ||
2609                             format->extension() != cit->extension() ||
2610                             format->prettyname() != cit->prettyname() ||
2611                             format->shortcut() != cit->shortcut() ||
2612                             format->viewer() != cit->viewer() ||
2613                             format->editor() != cit->editor() ||
2614                             format->documentFormat() != cit->documentFormat() ||
2615                             format->vectorFormat() != cit->vectorFormat()) {
2616                                 os << "\\format \"" << cit->name() << "\" \""
2617                                    << cit->extension() << "\" \""
2618                                    << cit->prettyname() << "\" \""
2619                                    << cit->shortcut() << "\" \""
2620                                    << escapeCommand(cit->viewer()) << "\" \""
2621                                    << escapeCommand(cit->editor()) << "\" \"";
2622                                 vector<string> flags;
2623                                 if (cit->documentFormat())
2624                                         flags.push_back("document");
2625                                 if (cit->vectorFormat())
2626                                         flags.push_back("vector");
2627                                 os << getStringFromVector(flags);
2628                                 os << "\"\n";
2629                         }
2630                 }
2631
2632                 // Look for deleted formats
2633                 for (Formats::const_iterator cit = system_formats.begin();
2634                      cit != system_formats.end(); ++cit)
2635                         if (!formats.getFormat(cit->name()))
2636                                 os << "\\format \"" << cit->name()
2637                                    << "\" \"\" \"\" \"\" \"\" \"\" \"\"\n";
2638                 if (tag != RC_LAST)
2639                         break;
2640         case RC_VIEWER_ALTERNATIVES: {
2641                 Alternatives::const_iterator it = viewer_alternatives.begin();
2642                 Alternatives::const_iterator const en = viewer_alternatives.end();
2643                 Alternatives::const_iterator const sysend = 
2644                                 system_lyxrc.viewer_alternatives.end();
2645                 for (; it != en; ++it) {
2646                         string const & fmt = it->first;
2647                         CommandSet const & cmd = it->second;
2648                         CommandSet::const_iterator sit = cmd.begin();
2649                         CommandSet::const_iterator const sen = cmd.end();
2650                         Alternatives::const_iterator const sysfmt = ignore_system_lyxrc ? 
2651                                         system_lyxrc.viewer_alternatives.begin() : // we won't use it in this case
2652                                         system_lyxrc.viewer_alternatives.find(fmt);
2653                         for (; sit != sen; ++sit) {
2654                                 string const & cmd = *sit;
2655                                 if (ignore_system_lyxrc 
2656                                     || sysfmt == sysend               // format not found
2657                                          || sysfmt->second.count(cmd) == 0 // this command not found
2658                                    )
2659                                         os << "\\viewer_alternatives " << fmt << " " << cmd << "\n";
2660                         }
2661                 }
2662                 if (tag != RC_LAST)
2663                         break;
2664         }
2665         case RC_EDITOR_ALTERNATIVES: {
2666                 Alternatives::const_iterator it = editor_alternatives.begin();
2667                 Alternatives::const_iterator const en = editor_alternatives.end();
2668                 Alternatives::const_iterator const sysend = 
2669                                 system_lyxrc.editor_alternatives.end();
2670                 for (; it != en; ++it) {
2671                         string const & fmt = it->first;
2672                         CommandSet const & cmd = it->second;
2673                         CommandSet::const_iterator sit = cmd.begin();
2674                         CommandSet::const_iterator const sen = cmd.end();
2675                         Alternatives::const_iterator const sysfmt = ignore_system_lyxrc ? 
2676                                         system_lyxrc.editor_alternatives.begin() : // we won't use it in this case
2677                                         system_lyxrc.editor_alternatives.find(fmt);
2678                         for (; sit != sen; ++sit) {
2679                                 string const & cmd = *sit;
2680                                 if (ignore_system_lyxrc 
2681                                     || sysfmt == sysend               // format not found
2682                                     || sysfmt->second.count(cmd) == 0 // this command not found
2683                                    )
2684                                         os << "\\editor_alternatives " << fmt << " " << cmd << "\n";
2685                         }
2686                 }
2687                 if (tag != RC_LAST)
2688                         break;
2689         }
2690         case RC_DEFAULT_VIEW_FORMAT:
2691                 if (ignore_system_lyxrc ||
2692                     default_view_format != system_lyxrc.default_view_format) {
2693                         os << "\\default_view_format " << default_view_format << '\n';
2694                 }
2695                 if (tag != RC_LAST)
2696                         break;
2697         case RC_VIEWER:
2698                 // Ignore it
2699                 if (tag != RC_LAST)
2700                         break;
2701
2702                 os << "\n#\n"
2703                    << "# CONVERTERS SECTION ##########################\n"
2704                    << "#\n\n";
2705
2706         case RC_CONVERTER:
2707                 // Look for new converters
2708                 for (Converters::const_iterator cit = theConverters().begin();
2709                      cit != theConverters().end(); ++cit) {
2710                         Converter const * converter =
2711                                 theSystemConverters().getConverter(cit->from,
2712                                                                cit->to);
2713                         if (!converter ||
2714                             converter->command != cit->command ||
2715                             converter->flags != cit->flags)
2716                                 os << "\\converter \"" << cit->from << "\" \""
2717                                    << cit->to << "\" \""
2718                                    << escapeCommand(cit->command) << "\" \""
2719                                    << cit->flags << "\"\n";
2720                 }
2721
2722                 // New/modifed converters
2723                 for (Converters::const_iterator cit = theSystemConverters().begin();
2724                      cit != theSystemConverters().end(); ++cit)
2725                         if (!theConverters().getConverter(cit->from, cit->to))
2726                                 os << "\\converter \"" << cit->from
2727                                    << "\" \"" << cit->to << "\" \"\" \"\"\n";
2728                 if (tag != RC_LAST)
2729                         break;
2730         
2731         case RC_COPIER:
2732                 if (tag == RC_LAST)
2733                         os << "\n#\n"
2734                            << "# COPIERS SECTION ##########################\n"
2735                            << "#\n\n";
2736
2737                 // Look for new movers
2738                 Movers::const_iterator const sysbegin = theSystemMovers().begin();
2739                 Movers::const_iterator const sysend = theSystemMovers().end();
2740                 Movers::const_iterator it = theMovers().begin();
2741                 Movers::const_iterator end = theMovers().end();
2742
2743                 for (; it != end; ++it) {
2744                         Movers::const_iterator const sysit =
2745                                 find_if(sysbegin, sysend, SameMover(*it));
2746                         if (sysit == sysend) {
2747                                 string const & fmt = it->first;
2748                                 string const & command =
2749                                         it->second.command();
2750
2751                                 os << "\\copier " << fmt
2752                                    << " \"" << escapeCommand(command) << "\"\n";
2753                         }
2754                 }
2755                 if (tag != RC_LAST)
2756                         break;
2757
2758                 // We don't actually delete SpecialisedMover(s) from the
2759                 // map, just clear their 'command', so there's no need
2760                 // to test for anything else.
2761         }
2762
2763         os.flush();
2764 }
2765
2766
2767 void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new)
2768 {
2769         // Why the switch you might ask. It is a trick to ensure that all
2770         // the elements in the LyXRCTags enum is handled. As you can see
2771         // there are no breaks at all. So it is just a huge fall-through.
2772         // The nice thing is that we will get a warning from the compiler
2773         // if we forget an element.
2774         LyXRC::LyXRCTags tag = LyXRC::RC_LAST;
2775         switch (tag) {
2776         case LyXRC::RC_ACCEPT_COMPOUND:
2777         case LyXRC::RC_ALT_LANG:
2778         case LyXRC::RC_PLAINTEXT_LINELEN:
2779         case LyXRC::RC_PLAINTEXT_ROFF_COMMAND:
2780         case LyXRC::RC_AUTOCORRECTION_MATH:
2781         case LyXRC::RC_AUTOREGIONDELETE:
2782         case LyXRC::RC_AUTORESET_OPTIONS:
2783         case LyXRC::RC_AUTOSAVE:
2784         case LyXRC::RC_AUTO_NUMBER:
2785         case LyXRC::RC_BACKUPDIR_PATH:
2786         case LyXRC::RC_BIBTEX_ALTERNATIVES:
2787         case LyXRC::RC_BIBTEX_COMMAND:
2788         case LyXRC::RC_BINDFILE:
2789         case LyXRC::RC_CHECKLASTFILES:
2790         case LyXRC::RC_COMPLETION_CURSOR_TEXT:
2791         case LyXRC::RC_COMPLETION_INLINE_DELAY:
2792         case LyXRC::RC_COMPLETION_INLINE_DOTS:
2793         case LyXRC::RC_COMPLETION_INLINE_MATH:
2794         case LyXRC::RC_COMPLETION_INLINE_TEXT:
2795         case LyXRC::RC_COMPLETION_POPUP_AFTER_COMPLETE:
2796         case LyXRC::RC_COMPLETION_POPUP_DELAY:
2797         case LyXRC::RC_COMPLETION_POPUP_MATH:
2798         case LyXRC::RC_COMPLETION_POPUP_TEXT:
2799         case LyXRC::RC_USELASTFILEPOS:
2800         case LyXRC::RC_LOADSESSION:
2801         case LyXRC::RC_CHKTEX_COMMAND:
2802         case LyXRC::RC_CONVERTER:
2803         case LyXRC::RC_CONVERTER_CACHE_MAXAGE:
2804         case LyXRC::RC_COPIER:
2805         case LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR:
2806         case LyXRC::RC_SCROLL_BELOW_DOCUMENT:
2807         case LyXRC::RC_DATE_INSERT_FORMAT:
2808         case LyXRC::RC_DEFAULT_LANGUAGE:
2809         case LyXRC::RC_GUI_LANGUAGE:
2810         case LyXRC::RC_DEFAULT_PAPERSIZE:
2811         case LyXRC::RC_DEFAULT_VIEW_FORMAT:
2812         case LyXRC::RC_DEFFILE:
2813         case LyXRC::RC_DIALOGS_ICONIFY_WITH_MAIN:
2814         case LyXRC::RC_DISPLAY_GRAPHICS:
2815         case LyXRC::RC_DOCUMENTPATH:
2816                 if (lyxrc_orig.document_path != lyxrc_new.document_path) {
2817                         FileName path(lyxrc_new.document_path);
2818                         if (path.exists() && path.isDirectory())
2819                                 package().document_dir() = FileName(lyxrc.document_path);
2820                 }
2821         case LyXRC::RC_EDITOR_ALTERNATIVES:
2822         case LyXRC::RC_ESC_CHARS:
2823         case LyXRC::RC_EXAMPLEPATH:
2824         case LyXRC::RC_FONT_ENCODING:
2825         case LyXRC::RC_FORMAT:
2826         case LyXRC::RC_GROUP_LAYOUTS:
2827         case LyXRC::RC_HUNSPELLDIR_PATH:
2828         case LyXRC::RC_INDEX_ALTERNATIVES:
2829         case LyXRC::RC_INDEX_COMMAND:
2830         case LyXRC::RC_JBIBTEX_COMMAND:
2831         case LyXRC::RC_JINDEX_COMMAND:
2832         case LyXRC::RC_NOMENCL_COMMAND:
2833         case LyXRC::RC_INPUT:
2834         case LyXRC::RC_KBMAP:
2835         case LyXRC::RC_KBMAP_PRIMARY:
2836         case LyXRC::RC_KBMAP_SECONDARY:
2837         case LyXRC::RC_LANGUAGE_AUTO_BEGIN:
2838         case LyXRC::RC_LANGUAGE_AUTO_END:
2839         case LyXRC::RC_LANGUAGE_COMMAND_BEGIN:
2840         case LyXRC::RC_LANGUAGE_COMMAND_END:
2841         case LyXRC::RC_LANGUAGE_COMMAND_LOCAL:
2842         case LyXRC::RC_LANGUAGE_GLOBAL_OPTIONS:
2843         case LyXRC::RC_LANGUAGE_PACKAGE:
2844         case LyXRC::RC_LANGUAGE_USE_BABEL:
2845         case LyXRC::RC_MAC_LIKE_WORD_MOVEMENT:
2846         case LyXRC::RC_MACRO_EDIT_STYLE:
2847         case LyXRC::RC_MAKE_BACKUP:
2848         case LyXRC::RC_MARK_FOREIGN_LANGUAGE:
2849         case LyXRC::RC_MOUSE_WHEEL_SPEED:
2850         case LyXRC::RC_NUMLASTFILES:
2851         case LyXRC::RC_PARAGRAPH_MARKERS:
2852         case LyXRC::RC_PATH_PREFIX:
2853                 if (lyxrc_orig.path_prefix != lyxrc_new.path_prefix) {
2854                         prependEnvPath("PATH", lyxrc.path_prefix);
2855                 }
2856         case LyXRC::RC_PERS_DICT:
2857         case LyXRC::RC_PREVIEW:
2858         case LyXRC::RC_PREVIEW_HASHED_LABELS:
2859         case LyXRC::RC_PREVIEW_SCALE_FACTOR:
2860         case LyXRC::RC_PRINTCOLLCOPIESFLAG:
2861         case LyXRC::RC_PRINTCOPIESFLAG:
2862         case LyXRC::RC_PRINTER:
2863         case LyXRC::RC_PRINTEVENPAGEFLAG:
2864         case LyXRC::RC_PRINTEXSTRAOPTIONS:
2865         case LyXRC::RC_PRINTFILEEXTENSION:
2866         case LyXRC::RC_PRINTLANDSCAPEFLAG:
2867         case LyXRC::RC_PRINTODDPAGEFLAG:
2868         case LyXRC::RC_PRINTPAGERANGEFLAG:
2869         case LyXRC::RC_PRINTPAPERDIMENSIONFLAG:
2870         case LyXRC::RC_PRINTPAPERFLAG:
2871         case LyXRC::RC_PRINTREVERSEFLAG:
2872         case LyXRC::RC_PRINTSPOOL_COMMAND:
2873         case LyXRC::RC_PRINTSPOOL_PRINTERPREFIX:
2874         case LyXRC::RC_PRINTTOFILE:
2875         case LyXRC::RC_PRINTTOPRINTER:
2876         case LyXRC::RC_PRINT_ADAPTOUTPUT:
2877         case LyXRC::RC_PRINT_COMMAND:
2878         case LyXRC::RC_RTL_SUPPORT:
2879         case LyXRC::RC_SAVE_COMPRESSED:
2880         case LyXRC::RC_SCREEN_DPI:
2881         case LyXRC::RC_SCREEN_FONT_ROMAN:
2882         case LyXRC::RC_SCREEN_FONT_ROMAN_FOUNDRY:
2883         case LyXRC::RC_SCREEN_FONT_SANS:
2884         case LyXRC::RC_SCREEN_FONT_SANS_FOUNDRY:
2885         case LyXRC::RC_SCREEN_FONT_SCALABLE:
2886         case LyXRC::RC_SCREEN_FONT_SIZES:
2887         case LyXRC::RC_SCREEN_FONT_TYPEWRITER:
2888         case LyXRC::RC_SCREEN_FONT_TYPEWRITER_FOUNDRY:
2889         case LyXRC::RC_GEOMETRY_SESSION:
2890         case LyXRC::RC_SCREEN_ZOOM:
2891         case LyXRC::RC_SERVERPIPE:
2892         case LyXRC::RC_SET_COLOR:
2893         case LyXRC::RC_SHOW_BANNER:
2894         case LyXRC::RC_OPEN_BUFFERS_IN_TABS:
2895         case LyXRC::RC_SPELL_COMMAND:
2896         case LyXRC::RC_SPELLCHECKER:
2897         case LyXRC::RC_SPELLCHECK_CONTINUOUSLY:
2898         case LyXRC::RC_SPELLCHECK_NOTES:
2899         case LyXRC::RC_SPELL_MINLENGTH:
2900         case LyXRC::RC_SPLITINDEX_COMMAND:
2901         case LyXRC::RC_TEMPDIRPATH:
2902         case LyXRC::RC_TEMPLATEPATH:
2903         case LyXRC::RC_TEX_ALLOWS_SPACES:
2904         case LyXRC::RC_TEX_EXPECTS_WINDOWS_PATHS:
2905                 if (lyxrc_orig.windows_style_tex_paths != lyxrc_new.windows_style_tex_paths) {
2906                         os::windows_style_tex_paths(lyxrc_new.windows_style_tex_paths);
2907                 }
2908         case LyXRC::RC_THESAURUSDIRPATH:
2909         case LyXRC::RC_UIFILE:
2910         case LyXRC::RC_USER_EMAIL:
2911         case LyXRC::RC_USER_NAME:
2912         case LyXRC::RC_USETEMPDIR:
2913         case LyXRC::RC_USE_ALT_LANG:
2914         case LyXRC::RC_USE_CONVERTER_CACHE:
2915         case LyXRC::RC_USE_ESC_CHARS:
2916         case LyXRC::RC_USE_INP_ENC:
2917         case LyXRC::RC_USE_PERS_DICT:
2918         case LyXRC::RC_USE_TOOLTIP:
2919         case LyXRC::RC_USE_PIXMAP_CACHE:
2920         case LyXRC::RC_USE_SPELL_LIB:
2921         case LyXRC::RC_VIEWDVI_PAPEROPTION:
2922         case LyXRC::RC_SINGLE_CLOSE_TAB_BUTTON:
2923         case LyXRC::RC_SORT_LAYOUTS:
2924         case LyXRC::RC_FULL_SCREEN_LIMIT:
2925         case LyXRC::RC_FULL_SCREEN_SCROLLBAR:
2926         case LyXRC::RC_FULL_SCREEN_MENUBAR:
2927         case LyXRC::RC_FULL_SCREEN_TABBAR:
2928         case LyXRC::RC_FULL_SCREEN_TOOLBARS:
2929         case LyXRC::RC_FULL_SCREEN_WIDTH:
2930         case LyXRC::RC_VISUAL_CURSOR:
2931         case LyXRC::RC_VIEWER:
2932         case LyXRC::RC_VIEWER_ALTERNATIVES:
2933         case LyXRC::RC_FORWARD_SEARCH_DVI:
2934         case LyXRC::RC_FORWARD_SEARCH_PDF:
2935         case LyXRC::RC_EXPORT_OVERWRITE:
2936         case LyXRC::RC_DEFAULT_DECIMAL_POINT:
2937         case LyXRC::RC_LAST:
2938                 break;
2939         }
2940 }
2941
2942
2943 #if 0
2944 string const LyXRC::getDescription(LyXRCTags tag)
2945 {
2946         docstring str;
2947
2948         switch (tag) {
2949         case RC_ACCEPT_COMPOUND:
2950                 str = _("Consider run-together words, such as \"diskdrive\" for \"disk drive\", as legal words?");
2951                 break;
2952
2953         case RC_ALT_LANG:
2954         case RC_USE_ALT_LANG:
2955                 str = _("Specify an alternate language. The default is to use the language of the document.");
2956                 break;
2957
2958         case RC_PLAINTEXT_ROFF_COMMAND:
2959                 str = _("Use to define an external program to render tables in plain text output. E.g. \"groff -t -Tlatin1 $$FName\" where $$FName is the input file. If \"\" is specified, an internal routine is used.");
2960                 break;
2961
2962         case RC_PLAINTEXT_LINELEN:
2963                 str = _("The maximum line length of exported plain text/LaTeX/SGML files. If set to 0, paragraphs are output in a single line; if the line length is > 0, paragraphs are separated by a blank line.");
2964                 break;
2965
2966         case RC_AUTOREGIONDELETE:
2967                 str = _("De-select if you don't want the current selection to be replaced automatically by what you type.");
2968                 break;
2969
2970         case RC_AUTORESET_OPTIONS:
2971                 str = _("De-select if you don't want the class options to be reset to defaults after class change.");
2972                 break;
2973
2974         case RC_AUTOSAVE:
2975                 str = _("The time interval between auto-saves (in seconds). 0 means no auto-save.");
2976                 break;
2977
2978         case RC_AUTO_NUMBER:
2979                 break;
2980
2981         case RC_BACKUPDIR_PATH:
2982                 str = _("The path for storing backup files. If it is an empty string, LyX will store the backup file in the same directory as the original file.");
2983                 break;
2984
2985         case RC_BIBTEX_COMMAND:
2986                 str = _("Define the options of bibtex (cf. man bibtex) or select an alternative compiler (e.g. mlbibtex or bibulus).");
2987                 break;
2988
2989         case RC_JBIBTEX_COMMAND:
2990                 str = _("Define the options of the bibtex program for PLaTeX (Japanese LaTeX).");
2991                 break;
2992
2993         case RC_BINDFILE:
2994                 str = _("Keybindings file. Can either specify an absolute path, or LyX will look in its global and local bind/ directories.");
2995                 break;
2996
2997         case RC_CHECKLASTFILES:
2998                 str = _("Select to check whether the lastfiles still exist.");
2999                 break;
3000
3001         case RC_CHKTEX_COMMAND:
3002                 str = _("Define how to run chktex. E.g. \"chktex -n11 -n1 -n3 -n6 -n9 -22 -n25 -n30 -n38\" Refer to the ChkTeX documentation.");
3003                 break;
3004
3005         case RC_CONVERTER:
3006                 break;
3007
3008         case RC_COPIER:
3009                 break;
3010
3011         case RC_CURSOR_FOLLOWS_SCROLLBAR:
3012                 str = _("LyX normally doesn't update the cursor position if you move the scrollbar. Set to true if you'd prefer to always have the cursor on screen.");
3013                 break;
3014
3015         case RC_SCROLL_BELOW_DOCUMENT:
3016                 str = _("LyX normally doesn't allow the user to scroll further than the bottom of the document. Set to true if you prefer to scroll the bottom of the document to the top of the screen");
3017                 break;
3018
3019         case RC_MAC_LIKE_WORD_MOVEMENT:
3020                 str = _("Use the Mac OS X conventions for the word-level cursor movement");
3021                 break;
3022
3023         case RC_SHOW_MACRO_LABEL:
3024                 str = _("Show a small box around a Math Macro with the macro name when the cursor is inside.");
3025                 break;
3026
3027         case RC_DATE_INSERT_FORMAT:
3028                 //xgettext:no-c-format
3029                 str = _("This accepts the normal strftime formats; see man strftime for full details. E.g.\"%A, %e. %B %Y\".");
3030                 break;
3031
3032         case RC_DEFFILE:
3033                 str = _("Command definition file. Can either specify an absolute path, or LyX will look in its global and local commands/ directories.");
3034                 break;
3035
3036         case RC_DEFAULT_VIEW_FORMAT:
3037                 str = _("The default format used with LFUN_BUFFER_[VIEW|UPDATE].");
3038                 break;
3039
3040         case RC_DEFAULT_LANGUAGE:
3041                 str = _("New documents will be assigned this language.");
3042                 break;
3043
3044         case RC_DEFAULT_PAPERSIZE:
3045                 str = _("Specify the default paper size.");
3046                 break;
3047
3048         case RC_DIALOGS_ICONIFY_WITH_MAIN:
3049                 str = _("Iconify the dialogs when the main window is iconified. (Affects only dialogs shown after the change has been made.)");
3050                 break;
3051
3052         case RC_DISPLAY_GRAPHICS:
3053                 str = _("Select how LyX will display any graphics.");
3054                 break;
3055
3056         case RC_DOCUMENTPATH:
3057                 str = _("The default path for your documents. An empty value selects the directory LyX was started from.");
3058                 break;
3059
3060         case RC_ESC_CHARS:
3061         case RC_USE_ESC_CHARS:
3062                 str = _("Specify additional chars that can be part of a word.");
3063                 break;
3064
3065         case RC_EXAMPLEPATH:
3066                 str = _("The path that LyX will set when offering to choose an example. An empty value selects the directory LyX was started from.");
3067                 break;
3068
3069         case RC_FONT_ENCODING:
3070                 str = _("The font encoding used for the LaTeX2e fontenc package. T1 is highly recommended for non-English languages.");
3071                 break;
3072
3073         case RC_FORMAT:
3074                 break;
3075
3076         case RC_INDEX_COMMAND:
3077                 str = _("Define the options of makeindex (cf. man makeindex) or select an alternative compiler. E.g., using xindy/make-rules, the command string would be \"makeindex.sh -m $$lang\".");
3078                 break;
3079
3080         case RC_JINDEX_COMMAND:
3081                 str = _("Define the options of the index program for PLaTeX (Japanese LaTeX).");
3082                 break;
3083
3084         case RC_NOMENCL_COMMAND:
3085                 str = _("Define the options of makeindex (cf. man makeindex) to be used for nomenclatures. This might differ from the index processing options.");
3086                 break;
3087
3088         case RC_INPUT:
3089                 break;
3090
3091         case RC_KBMAP:
3092         case RC_KBMAP_PRIMARY:
3093         case RC_KBMAP_SECONDARY:
3094                 str = _("Use this to set the correct mapping file for your keyboard. You'll need this if you for instance want to type German documents on an American keyboard.");
3095                 break;
3096
3097         case RC_LANGUAGE_AUTO_BEGIN:
3098                 str = _("Select if a language switching command is needed at the beginning of the document.");
3099                 break;
3100
3101         case RC_LANGUAGE_AUTO_END:
3102                 str = _("Select if a language switching command is needed at the end of the document.");
3103                 break;
3104
3105         case RC_LANGUAGE_COMMAND_BEGIN:
3106                 str = _("The LaTeX command for changing from the language of the document to another language. E.g. \\selectlanguage{$$lang} where $$lang is substituted by the name of the second language.");
3107                 break;
3108
3109         case RC_LANGUAGE_COMMAND_END:
3110                 str = _("The LaTeX command for changing back to the language of the document.");
3111                 break;
3112
3113         case RC_LANGUAGE_COMMAND_LOCAL:
3114                 str = _("The LaTeX command for local changing of the language.");
3115                 break;
3116
3117         case RC_LANGUAGE_GLOBAL_OPTIONS:
3118                 str = _("De-select if you don't want the language(s) used as an argument to \\documentclass.");
3119                 break;
3120
3121         case RC_LANGUAGE_PACKAGE:
3122                 str = _("The LaTeX command for loading the language package. E.g. \"\\usepackage{babel}\", \"\\usepackage{omega}\".");
3123                 break;
3124
3125         case RC_LANGUAGE_USE_BABEL:
3126                 str = _("De-select if you don't want babel to be used when the language of the document is the default language.");
3127                 break;
3128
3129         case RC_USELASTFILEPOS:
3130                 str = _("De-select if you do not want LyX to scroll to saved position.");
3131                 break;
3132
3133         case RC_LOADSESSION:
3134                 str = _("De-select to prevent loading files opened from the last LyX session.");
3135                 break;
3136
3137         case RC_MAKE_BACKUP:
3138                 str = _("De-select if you don't want LyX to create backup files.");
3139                 break;
3140
3141         case RC_MARK_FOREIGN_LANGUAGE:
3142                 str = _("Select to control the highlighting of words with a language foreign to that of the document.");
3143                 break;
3144
3145         case RC_MOUSE_WHEEL_SPEED:
3146                 str = bformat(_("The scrolling speed of the mouse wheel."),
3147                       maxlastfiles);
3148                 break;
3149
3150         case RC_COMPLETION_POPUP_DELAY:
3151                 str = _("The completion popup delay.");
3152                 break;
3153
3154         case RC_COMPLETION_POPUP_MATH:
3155                 str = _("Select to display the completion popup in math mode.");
3156                 break;
3157
3158         case RC_COMPLETION_POPUP_TEXT:
3159                 str = _("Select to display the completion popup in text mode.");
3160                 break;
3161
3162         case RC_COMPLETION_POPUP_AFTER_COMPLETE:
3163                 str = _("Show the completion popup without delay after non-unique completion attempt.");
3164                 break;
3165
3166         case RC_COMPLETION_POPUP_TEXT:
3167                 str = _("Show a small triangle on the cursor to indicate that a completion is available.");
3168                 break;
3169
3170         case RC_COMPLETION_POPUP_DELAY:
3171                 str = _("The inline completion delay.");
3172                 break;
3173
3174         case RC_COMPLETION_INLINE_MATH:
3175                 str = _("Select to display the inline completion in math mode.");
3176                 break;
3177
3178         case RC_COMPLETION_INLINE_TEXT:
3179                 str = _("Select to display the inline completion in text mode.");
3180                 break;
3181
3182         case RC_COMPLETION_INLINE_DOTS:
3183                 str = _("Use \"...\" to shorten long completions.");
3184                 break;
3185
3186         case RC_AUTOCORRECTION_MATH:
3187                 str = _("Allow TeXMacs shorthand, like => converting to \Rightarrow.");
3188                 break;
3189
3190         case RC_NUMLASTFILES:
3191                 str = bformat(_("Maximal number of lastfiles. Up to %1$d can appear in the file menu."),
3192                         maxlastfiles);
3193                 break;
3194
3195         case RC_PATH_PREFIX:
3196                 str = _("Specify those directories which should be "
3197                          "prepended to the PATH environment variable. "
3198                          "Use the OS native format.");
3199                 break;
3200
3201         case RC_PREVIEW:
3202                 str = _("Shows a typeset preview of things such as math");
3203                 break;
3204
3205         case RC_PREVIEW_HASHED_LABELS:
3206                 str = _("Previewed equations will have \"(#)\" labels rather than numbered ones");
3207                 break;
3208
3209         case RC_PREVIEW_SCALE_FACTOR:
3210                 str = _("Scale the preview size to suit.");
3211                 break;
3212
3213         case RC_PRINTCOLLCOPIESFLAG:
3214                 str = _("The option for specifying whether the copies should be collated.");
3215                 break;
3216
3217         case RC_PRINTCOPIESFLAG:
3218                 str = _("The option for specifying the number of copies to print.");
3219                 break;
3220
3221         case RC_PRINTER:
3222                 str = _("The default printer to print on. If none is specified, LyX will use the environment variable PRINTER.");
3223                 break;
3224
3225         case RC_PRINTEVENPAGEFLAG:
3226                 str = _("The option to print only even pages.");
3227                 break;
3228
3229         case RC_PRINTEXSTRAOPTIONS:
3230                 str = _("Extra options to pass to printing program after everything else, but before the filename of the DVI file to be printed.");
3231                 break;
3232
3233         case RC_PRINTFILEEXTENSION:
3234                 str = _("Extension of printer program output file. Usually \".ps\".");
3235                 break;
3236
3237         case RC_PRINTLANDSCAPEFLAG:
3238                 str = _("The option to print out in landscape.");
3239                 break;
3240
3241         case RC_PRINTODDPAGEFLAG:
3242                 str = _("The option to print only odd pages.");
3243                 break;
3244
3245         case RC_PRINTPAGERANGEFLAG:
3246                 str = _("The option for specifying a comma-separated list of pages to print.");
3247                 break;
3248
3249         case RC_PRINTPAPERDIMENSIONFLAG:
3250                                    str = _("Option to specify the dimensions of the print paper.");
3251                 break;
3252
3253         case RC_PRINTPAPERFLAG:
3254                 str = _("The option to specify paper type.");
3255                 break;
3256
3257         case RC_PRINTREVERSEFLAG:
3258                 str = _("The option to reverse the order of the pages printed.");
3259                 break;
3260
3261         case RC_PRINTSPOOL_COMMAND:
3262                 str = _("When set, this printer option automatically prints to a file and then calls a separate print spooling program on that file with the given name and arguments.");
3263                 break;
3264
3265         case RC_PRINTSPOOL_PRINTERPREFIX:
3266                 str = _("If you specify a printer name in the print dialog, the following argument is prepended along with the printer name after the spool command.");
3267                 break;
3268
3269         case RC_PRINTTOFILE:
3270                 str = _("Option to pass to the print program to print to a file.");
3271                 break;
3272
3273         case RC_PRINTTOPRINTER:
3274                 str = _("Option to pass to the print program to print on a specific printer.");
3275                 break;
3276
3277         case RC_PRINT_ADAPTOUTPUT:
3278                 str = _("Select for LyX to pass the name of the destination printer to your print command.");
3279                 break;
3280
3281         case RC_PRINT_COMMAND:
3282                 str = _("Your favorite print program, e.g. \"dvips\", \"dvilj4\".");
3283                 break;
3284
3285         case RC_RTL_SUPPORT:
3286                 str = _("Select to enable support of right-to-left languages (e.g. Hebrew, Arabic).");
3287                 break;
3288
3289         case RC_VISUAL_CURSOR:
3290                 str = _("Select to have visual bidi cursor movement, unselect for logical movement.");
3291                 break;
3292
3293         case RC_SCREEN_DPI:
3294                 str = _("DPI (dots per inch) of your monitor is auto-detected by LyX. If that goes wrong, override the setting here.");
3295                 break;
3296
3297         case RC_SCREEN_FONT_ROMAN:
3298         case RC_SCREEN_FONT_SANS:
3299         case RC_SCREEN_FONT_TYPEWRITER:
3300                 str = _("The screen fonts used to display the text while editing.");
3301                 break;
3302
3303         case RC_SCREEN_FONT_ROMAN_FOUNDRY:
3304         case RC_SCREEN_FONT_SANS_FOUNDRY:
3305         case RC_SCREEN_FONT_TYPEWRITER_FOUNDRY:
3306                 break;
3307
3308         case RC_SCREEN_FONT_SCALABLE:
3309                 str = _("Allow bitmap fonts to be resized. If you are using a bitmap font, selecting this option may make some fonts look blocky in LyX. Deselecting this option makes LyX use the nearest bitmap font size available, instead of scaling.");
3310                 break;
3311
3312         case RC_SCREEN_FONT_SIZES:
3313                 str = _("The font sizes used for calculating the scaling of the screen fonts.");
3314                 break;
3315
3316         case RC_SCREEN_ZOOM:
3317                 //xgettext:no-c-format
3318                 str = _("The zoom percentage for screen fonts. A setting of 100% will make the fonts roughly the same size as on paper.");
3319                 break;
3320
3321         case RC_GEOMETRY_SESSION:
3322                 str = _("Allow session manager to save and restore windows geometry.");
3323                 break;
3324
3325         case RC_SERVERPIPE:
3326                 str = _("This starts the lyxserver. The pipes get an additional extension \".in\" and \".out\". Only for advanced users.");
3327                 break;
3328
3329         case RC_SET_COLOR:
3330                 break;
3331
3332         case RC_SHOW_BANNER:
3333                 str = _("De-select if you don't want the startup banner.");
3334                 break;
3335
3336         case RC_TEMPDIRPATH:
3337                 str = _("LyX will place its temporary directories in this path. They will be deleted when you quit LyX.");
3338                 break;
3339
3340         case RC_THESAURUSDIRPATH:
3341                 str = _("This is the place where the files of the thesaurus library reside.");
3342                 break;
3343
3344         case RC_TEMPLATEPATH:
3345                 str = _("The path that LyX will set when offering to choose a template. An empty value selects the directory LyX was started from.");
3346                 break;
3347
3348         case RC_TEX_ALLOWS_SPACES:
3349                 break;
3350
3351         case RC_TEX_EXPECTS_WINDOWS_PATHS:
3352                 break;
3353
3354         case RC_UIFILE:
3355                 str = _("The UI (user interface) file. Can either specify an absolute path, or LyX will look in its global and local ui/ directories.");
3356                 break;
3357
3358         case RC_USER_EMAIL:
3359                 break;
3360
3361         case RC_USER_NAME:
3362                 break;
3363
3364         case RC_USETEMPDIR:
3365                 break;
3366
3367         case RC_USE_TOOLTIP:
3368                 str = _("Enable the automatic appearance of tool tips in the work area.");
3369                 break;
3370
3371         case RC_USE_PIXMAP_CACHE:
3372                 str = _("Enable the pixmap cache that might improve performance on Mac and Windows.");
3373                 break;
3374
3375         case RC_USE_SPELL_LIB:
3376                 break;
3377
3378         case RC_VIEWDVI_PAPEROPTION:
3379                 _("Specify the paper command to DVI viewer (leave empty or use \"-paper\")");
3380                 break;
3381
3382         case RC_VIEWER:
3383                 break;
3384
3385         case RC_LAST:
3386                 break;
3387         }
3388
3389         return str;
3390 }
3391 #endif
3392
3393
3394 // The global instance
3395 LyXRC lyxrc;
3396
3397 // The global copy of the system lyxrc entries (everything except preferences)
3398 LyXRC system_lyxrc;
3399
3400
3401 } // namespace lyx