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