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