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