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