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