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