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