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