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