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