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