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