]> git.lyx.org Git - lyx.git/blob - src/LyXRC.cpp
471873d0b7e99afa384d21c2e16383d671f23d9a
[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 = 25; // lasgouttes: remove qimage
63
64 // when adding something to this array keep it sorted!
65 LexerKeyword lyxrcTags[] = {
66         { "\\accept_compound", LyXRC::RC_ACCEPT_COMPOUND },
67         { "\\allow_geometry_session", LyXRC::RC_GEOMETRY_SESSION },
68         { "\\alternate_language", LyXRC::RC_ALT_LANG },
69         { "\\auto_number", LyXRC::RC_AUTO_NUMBER },
70         { "\\auto_region_delete", LyXRC::RC_AUTOREGIONDELETE },
71         { "\\auto_reset_options", LyXRC::RC_AUTORESET_OPTIONS },
72         { "\\autocorrection_math", LyXRC::RC_AUTOCORRECTION_MATH },
73         { "\\autosave", LyXRC::RC_AUTOSAVE },
74         { "\\backupdir_path", LyXRC::RC_BACKUPDIR_PATH },
75         { "\\bibtex_alternatives", LyXRC::RC_BIBTEX_ALTERNATIVES },
76         { "\\bibtex_command", LyXRC::RC_BIBTEX_COMMAND },
77         { "\\bind_file", LyXRC::RC_BINDFILE },
78         { "\\check_lastfiles", LyXRC::RC_CHECKLASTFILES },
79         { "\\chktex_command", LyXRC::RC_CHKTEX_COMMAND },
80         { "\\close_buffer_with_last_view", LyXRC::RC_CLOSE_BUFFER_WITH_LAST_VIEW },
81         { "\\completion_cursor_text", LyXRC::RC_COMPLETION_CURSOR_TEXT },
82         { "\\completion_inline_delay", LyXRC::RC_COMPLETION_INLINE_DELAY },
83         { "\\completion_inline_dots", LyXRC::RC_COMPLETION_INLINE_DOTS },
84         { "\\completion_inline_math", LyXRC::RC_COMPLETION_INLINE_MATH },
85         { "\\completion_inline_text", LyXRC::RC_COMPLETION_INLINE_TEXT },
86         { "\\completion_minlength", LyXRC::RC_COMPLETION_MINLENGTH },
87         { "\\completion_popup_after_complete", LyXRC::RC_COMPLETION_POPUP_AFTER_COMPLETE },
88         { "\\completion_popup_delay", LyXRC::RC_COMPLETION_POPUP_DELAY },
89         { "\\completion_popup_math", LyXRC::RC_COMPLETION_POPUP_MATH },
90         { "\\completion_popup_text", LyXRC::RC_COMPLETION_POPUP_TEXT },
91         { "\\converter", LyXRC::RC_CONVERTER },
92         { "\\converter_cache_maxage", LyXRC::RC_CONVERTER_CACHE_MAXAGE },
93         { "\\copier", LyXRC::RC_COPIER },
94         { "\\cursor_follows_scrollbar", LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR },
95         { "\\cursor_width", LyXRC::RC_CURSOR_WIDTH },
96         { "\\date_insert_format", LyXRC::RC_DATE_INSERT_FORMAT },
97         { "\\def_file", LyXRC::RC_DEFFILE },
98         { "\\default_decimal_point", LyXRC::RC_DEFAULT_DECIMAL_POINT },
99         { "\\default_length_unit", LyXRC::RC_DEFAULT_LENGTH_UNIT },
100         { "\\default_otf_view_format", LyXRC::RC_DEFAULT_OTF_VIEW_FORMAT },
101         { "\\default_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_native_filedialog", LyXRC::RC_USE_NATIVE_FILEDIALOG },
199         { "\\use_pixmap_cache", LyXRC::RC_USE_PIXMAP_CACHE },
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         use_native_filedialog = true;
277         load_session = false;
278         make_backup = true;
279         save_compressed = false;
280         save_origin = false;
281         backupdir_path.erase();
282         display_graphics = true;
283         // Spellchecker settings:
284 // FIXME: this check should test the target platform (darwin)
285 #if defined(USE_MACOSX_PACKAGING)
286         spellchecker = "native";
287 #elif defined(USE_ASPELL)
288         spellchecker = "aspell";
289 #elif defined(USE_HUNSPELL)
290         spellchecker = "hunspell";
291 #else
292         spellchecker = "aspell";
293 #endif
294         spellchecker_accept_compound = false;
295         spellcheck_continuously = false;
296         completion_minlength = 6;
297         spellcheck_notes = true;
298         use_kbmap = false;
299         visual_cursor = false;
300         auto_number = true;
301         mark_foreign_language = true;
302         language_auto_begin = true;
303         language_auto_end = true;
304         language_global_options = true;
305         language_package_selection = LP_AUTO;
306         language_custom_package = "\\usepackage{babel}";
307         language_command_begin = "\\selectlanguage{$$lang}";
308         language_command_local = "\\foreignlanguage{$$lang}{";
309         sort_layouts = false;
310         group_layouts = true;
311         gui_language = "auto";
312         show_banner = true;
313         windows_style_tex_paths = false;
314         tex_allows_spaces = false;
315         date_insert_format = "%x";
316         cursor_follows_scrollbar = false;
317         scroll_below_document = false;
318         scroll_wheel_zoom = SCROLL_WHEEL_ZOOM_CTRL;
319         paragraph_markers = false;
320         mac_dontswap_ctrl_meta = false;
321         mac_like_cursor_movement = false;
322         macro_edit_style = MACRO_EDIT_INLINE_BOX;
323         dialogs_iconify_with_main = false;
324         preview = PREVIEW_OFF;
325         preview_hashed_labels  = false;
326         preview_scale_factor = 1.0;
327         use_converter_cache = true;
328         use_converter_needauth_forbidden = true;
329         use_converter_needauth = true;
330         use_system_colors = false;
331         use_tooltip = true;
332         use_pixmap_cache = false;
333         converter_cache_maxage = 6 * 30 * 24 * 3600; // 6 months
334         user_name = to_utf8(support::user_name());
335         user_email = to_utf8(support::user_email());
336         open_buffers_in_tabs = true;
337         single_close_tab_button = false;
338         single_instance = true;
339         forward_search_dvi = string();
340         forward_search_pdf = string();
341         export_overwrite = NO_FILES;
342
343         // Fullscreen settings
344         full_screen_limit = false;
345         full_screen_toolbars = true;
346         full_screen_tabbar = true;
347         full_screen_menubar = true;
348         full_screen_statusbar = true;
349         full_screen_scrollbar = true;
350         full_screen_width = 700;
351
352         completion_cursor_text = true;
353         completion_popup_math = true;
354         completion_popup_text = false;
355         completion_popup_delay = 2.0;
356         completion_popup_after_complete = true;
357         autocorrection_math = false;
358         completion_inline_math = true;
359         completion_inline_text = false;
360         completion_inline_dots = -1;
361         completion_inline_delay = 0.2;
362         default_decimal_point = ".";
363         default_length_unit = Length::CM;
364         cursor_width = 1;
365         close_buffer_with_last_view = "yes";
366         mouse_middlebutton_paste = true;
367 }
368
369
370 namespace {
371
372 void oldFontFormat(string & family, string & foundry)
373 {
374         if (family.empty() || family[0] != '-')
375                 return;
376         foundry = token(family, '-', 1);
377         family = token(family, '-', 2);
378         if (foundry == "*")
379                 foundry.erase();
380 }
381
382 } // namespace
383
384
385 bool LyXRC::read(FileName const & filename, bool check_format)
386 {
387         Lexer lexrc(lyxrcTags);
388         lexrc.setFile(filename);
389         LYXERR(Debug::LYXRC, "Reading '" << filename << "'...");
390         ReturnValues retval = read(lexrc, check_format);
391         if (!check_format || retval != FormatMismatch)
392                 return retval == ReadOK;
393
394         LYXERR(Debug::FILES, "Converting LyXRC file to " << LYXRC_FILEFORMAT);
395         TempFile tmp("convert_lyxrc");
396         FileName const tempfile = tmp.name();
397         bool const success = prefs2prefs(filename, tempfile, false);
398         if (!success) {
399                 LYXERR0 ("Unable to convert " << filename.absFileName() <<
400                         " to format " << LYXRC_FILEFORMAT);
401                 return false;
402         } else {
403                 // Keep this in the else branch, such that lexrc2 goes out
404                 // of scope and releases the lock on tempfile before we
405                 // attempt to remove it. This matters on Windows.
406                 Lexer lexrc2(lyxrcTags);
407                 lexrc2.setFile(tempfile);
408                 LYXERR(Debug::LYXRC, "Reading '" << tempfile << "'...");
409                 retval = read(lexrc2, check_format);
410         }
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 rc_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                                 rc_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_NATIVE_FILEDIALOG:
877                         lexrc >> use_native_filedialog;
878                         break;
879                 case RC_USE_SYSTEM_COLORS:
880                         lexrc >> use_system_colors;
881                         break;
882                 case RC_USE_TOOLTIP:
883                         lexrc >> use_tooltip;
884                         break;
885                 case RC_USE_PIXMAP_CACHE:
886                         lexrc >> use_pixmap_cache;
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 && rc_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_NATIVE_FILEDIALOG:
2414                 if (ignore_system_lyxrc ||
2415                     use_native_filedialog != system_lyxrc.use_native_filedialog) {
2416                         os << "\\use_native_filedialog "
2417                            << convert<string>(use_native_filedialog)
2418                            << '\n';
2419                 }
2420                 if (tag != RC_LAST)
2421                         break;
2422                 // fall through
2423         case RC_USE_SYSTEM_COLORS:
2424                 if (ignore_system_lyxrc ||
2425                     use_system_colors != system_lyxrc.use_system_colors) {
2426                         os << "\\use_system_colors "
2427                            << convert<string>(use_system_colors)
2428                            << '\n';
2429                 }
2430                 if (tag != RC_LAST)
2431                         break;
2432                 // fall through
2433         case RC_USE_TOOLTIP:
2434                 if (ignore_system_lyxrc ||
2435                     use_tooltip != system_lyxrc.use_tooltip) {
2436                         os << "\\use_tooltip "
2437                            << convert<string>(use_tooltip)
2438                            << '\n';
2439                 }
2440                 if (tag != RC_LAST)
2441                         break;
2442                 // fall through
2443         case RC_USE_PIXMAP_CACHE:
2444                 if (ignore_system_lyxrc ||
2445                     use_pixmap_cache != system_lyxrc.use_pixmap_cache) {
2446                         os << "\\use_pixmap_cache "
2447                            << convert<string>(use_pixmap_cache)
2448                            << '\n';
2449                 }
2450                 if (tag != RC_LAST)
2451                         break;
2452                 // fall through
2453
2454                 os << "\n#\n"
2455                    << "# LANGUAGE SUPPORT SECTION ##########################\n"
2456                    << "#\n\n";
2457
2458         // fall through
2459         case RC_DEFAULT_DECIMAL_POINT:
2460                 if (ignore_system_lyxrc ||
2461                     default_decimal_point != system_lyxrc.default_decimal_point) {
2462                         os << "\\default_decimal_point " << default_decimal_point << '\n';
2463                 }
2464                 if (tag != RC_LAST)
2465                         break;
2466                 // fall through
2467         case RC_DEFAULT_LENGTH_UNIT:
2468                 if (ignore_system_lyxrc ||
2469                     default_length_unit != system_lyxrc.default_length_unit) {
2470                         os << "\\default_length_unit " << int(default_length_unit) << '\n';
2471                 }
2472                 if (tag != RC_LAST)
2473                         break;
2474                 // fall through
2475         case RC_SPELLCHECKER:
2476                 if (ignore_system_lyxrc ||
2477                     spellchecker != system_lyxrc.spellchecker) {
2478                         os << "\\spellchecker " << spellchecker << '\n';
2479                 }
2480                 if (tag != RC_LAST)
2481                         break;
2482                 // fall through
2483         case RC_SPELLCHECK_CONTINUOUSLY:
2484                 if (ignore_system_lyxrc ||
2485                     spellcheck_continuously != system_lyxrc.spellcheck_continuously) {
2486                         os << "\\spellcheck_continuously " << convert<string>(spellcheck_continuously)
2487                            << '\n';
2488                 }
2489                 if (tag != RC_LAST)
2490                         break;
2491                 // fall through
2492         case RC_SPELLCHECK_NOTES:
2493                 if (ignore_system_lyxrc ||
2494                     spellcheck_notes != system_lyxrc.spellcheck_notes) {
2495                         os << "\\spellcheck_notes " << convert<string>(spellcheck_notes)
2496                            << '\n';
2497                 }
2498                 if (tag != RC_LAST)
2499                         break;
2500                 // fall through
2501         case RC_VISUAL_CURSOR:
2502                 if (ignore_system_lyxrc ||
2503                         visual_cursor != system_lyxrc.visual_cursor) {
2504                         os << "\\visual_cursor " << convert<string>(visual_cursor) << '\n';
2505                 }
2506                 if (tag != RC_LAST)
2507                         break;
2508                 // fall through
2509         case RC_CLOSE_BUFFER_WITH_LAST_VIEW:
2510                 if (ignore_system_lyxrc ||
2511                         close_buffer_with_last_view != system_lyxrc.close_buffer_with_last_view) {
2512                         os << "# When closing last view, buffer closes (yes), hides (no), or ask the user (ask)\n";
2513                         os << "\\close_buffer_with_last_view " << close_buffer_with_last_view << '\n';
2514                 }
2515                 if (tag != RC_LAST)
2516                         break;
2517                 // fall through
2518         case RC_LANGUAGE_CUSTOM_PACKAGE:
2519                 if (ignore_system_lyxrc ||
2520                     language_custom_package != system_lyxrc.language_custom_package) {
2521                         os << "\\language_custom_package \"" << language_custom_package
2522                            << "\"\n";
2523                 }
2524                 if (tag != RC_LAST)
2525                         break;
2526                 // fall through
2527         case RC_LANGUAGE_GLOBAL_OPTIONS:
2528                 if (ignore_system_lyxrc ||
2529                     language_global_options
2530                     != system_lyxrc.language_global_options) {
2531                         os << "\\language_global_options \""
2532                            << convert<string>(language_global_options)
2533                            << "\"\n";
2534                 }
2535                 if (tag != RC_LAST)
2536                         break;
2537                 // fall through
2538         case RC_LANGUAGE_PACKAGE_SELECTION:
2539                 if (ignore_system_lyxrc ||
2540                     language_package_selection != system_lyxrc.language_package_selection) {
2541                         os << "\\language_package_selection ";
2542                         switch (language_package_selection) {
2543                         case LP_AUTO:
2544                                 os << "0\n";
2545                                 break;
2546                         case LP_BABEL:
2547                                 os << "1\n";
2548                                 break;
2549                         case LP_CUSTOM:
2550                                 os << "2\n";
2551                                 break;
2552                         case LP_NONE:
2553                                 os << "3\n";
2554                                 break;
2555                         }
2556                 }
2557                 if (tag != RC_LAST)
2558                         break;
2559                 // fall through
2560         case RC_LANGUAGE_COMMAND_BEGIN:
2561                 if (ignore_system_lyxrc ||
2562                     language_command_begin
2563                     != system_lyxrc.language_command_begin) {
2564                         os << "\\language_command_begin \""
2565                            << language_command_begin
2566                            << "\"\n";
2567                 }
2568                 if (tag != RC_LAST)
2569                         break;
2570                 // fall through
2571         case RC_LANGUAGE_COMMAND_END:
2572                 if (ignore_system_lyxrc ||
2573                     language_command_end
2574                     != system_lyxrc.language_command_end) {
2575                         os << "\\language_command_end \"" << language_command_end
2576                            << "\"\n";
2577                 }
2578                 if (tag != RC_LAST)
2579                         break;
2580                 // fall through
2581         case RC_LANGUAGE_COMMAND_LOCAL:
2582                 if (ignore_system_lyxrc ||
2583                     language_command_local
2584                     != system_lyxrc.language_command_local) {
2585                         os << "\\language_command_local \""
2586                            << language_command_local
2587                            << "\"\n";
2588                 }
2589                 if (tag != RC_LAST)
2590                         break;
2591                 // fall through
2592         case RC_LANGUAGE_AUTO_BEGIN:
2593                 if (ignore_system_lyxrc ||
2594                     language_auto_begin != system_lyxrc.language_auto_begin) {
2595                         os << "\\language_auto_begin "
2596                            << convert<string>(language_auto_begin) << '\n';
2597                 }
2598                 if (tag != RC_LAST)
2599                         break;
2600                 // fall through
2601         case RC_LANGUAGE_AUTO_END:
2602                 if (ignore_system_lyxrc ||
2603                     language_auto_end != system_lyxrc.language_auto_end) {
2604                         os << "\\language_auto_end "
2605                            << convert<string>(language_auto_end) << '\n';
2606                 }
2607                 if (tag != RC_LAST)
2608                         break;
2609                 // fall through
2610         case RC_MARK_FOREIGN_LANGUAGE:
2611                 if (ignore_system_lyxrc ||
2612                     mark_foreign_language
2613                     != system_lyxrc.mark_foreign_language) {
2614                         os << "\\mark_foreign_language " <<
2615                                 convert<string>(mark_foreign_language) << '\n';
2616                 }
2617                 if (tag != RC_LAST)
2618                         break;
2619
2620                 os << "\n#\n"
2621                    << "# 2nd MISC SUPPORT SECTION ##########################\n"
2622                    << "#\n\n";
2623
2624         // fall through
2625         case RC_AUTO_NUMBER:
2626                 if (ignore_system_lyxrc ||
2627                     auto_number != system_lyxrc.auto_number) {
2628                         os << "\\auto_number " << convert<string>(auto_number) << '\n';
2629                 }
2630                 if (tag != RC_LAST)
2631                         break;
2632                 // fall through
2633         case RC_GUI_LANGUAGE:
2634                 if (ignore_system_lyxrc ||
2635                     gui_language != system_lyxrc.gui_language) {
2636                         os << "\\gui_language " << gui_language << '\n';
2637                 }
2638                 if (tag != RC_LAST)
2639                         break;
2640                 // fall through
2641         case RC_EXPORT_OVERWRITE:
2642                 if (ignore_system_lyxrc ||
2643                     export_overwrite != system_lyxrc.export_overwrite) {
2644                         string status;
2645                         switch (export_overwrite) {
2646                         case NO_FILES:
2647                                 status = "ask";
2648                                 break;
2649                         case MAIN_FILE:
2650                                 status = "main";
2651                                 break;
2652                         case ALL_FILES:
2653                                 status = "all";
2654                                 break;
2655                         }
2656                         os << "\\export_overwrite " << status << '\n';
2657                 }
2658                 if (tag != RC_LAST)
2659                         break;
2660                 // fall through
2661         case RC_SCROLL_WHEEL_ZOOM:
2662                 if (ignore_system_lyxrc ||
2663                         scroll_wheel_zoom != system_lyxrc.scroll_wheel_zoom) {
2664                         string status;
2665                         switch (scroll_wheel_zoom) {
2666                         case SCROLL_WHEEL_ZOOM_OFF:
2667                                 status = "off";
2668                                 break;
2669                         case SCROLL_WHEEL_ZOOM_CTRL:
2670                                 status = "ctrl";
2671                                 break;
2672                         case SCROLL_WHEEL_ZOOM_SHIFT:
2673                                 status = "shift";
2674                                 break;
2675                         case SCROLL_WHEEL_ZOOM_ALT:
2676                                 status = "alt";
2677                                 break;
2678                         }
2679                         os << "\\scroll_wheel_zoom " << status << '\n';
2680                 }
2681                 if (tag != RC_LAST)
2682                         break;
2683
2684                 os << "\n#\n"
2685                    << "# FORMATS SECTION ##########################\n"
2686                    << "#\n\n";
2687
2688         // fall through
2689         case RC_FILEFORMAT:
2690                 // New/modified formats
2691                 for (Formats::const_iterator cit = theFormats().begin();
2692                      cit != theFormats().end(); ++cit) {
2693                         Format const * format =
2694                                 theSystemFormats().getFormat(cit->name());
2695                         if (!format ||
2696                             format->extensions() != cit->extensions() ||
2697                             format->prettyname() != cit->prettyname() ||
2698                             format->shortcut() != cit->shortcut() ||
2699                             format->viewer() != cit->viewer() ||
2700                             format->editor() != cit->editor() ||
2701                             format->documentFormat() != cit->documentFormat() ||
2702                             format->vectorFormat() != cit->vectorFormat() ||
2703                             format->inExportMenu() != cit->inExportMenu() ||
2704                             format->mime() != cit->mime()) {
2705                                 os << "\\format \"" << cit->name() << "\" \""
2706                                    << cit->extensions() << "\" \""
2707                                    << to_utf8(cit->prettyname()) << "\" \""
2708                                    << cit->shortcut() << "\" \""
2709                                    << escapeCommand(cit->viewer()) << "\" \""
2710                                    << escapeCommand(cit->editor()) << "\" \"";
2711                                 vector<string> flags;
2712                                 if (cit->documentFormat())
2713                                         flags.push_back("document");
2714                                 if (cit->vectorFormat())
2715                                         flags.push_back("vector");
2716                                 if (cit->zippedNative())
2717                                         flags.push_back("zipped=native");
2718                                 if (cit->inExportMenu())
2719                                         flags.push_back("menu=export");
2720
2721                                 os << getStringFromVector(flags);
2722                                 os << "\" \"" << cit->mime() << "\"\n";
2723                         }
2724                 }
2725
2726                 // Look for deleted formats
2727                 for (Formats::const_iterator cit = theSystemFormats().begin();
2728                      cit != theSystemFormats().end(); ++cit)
2729                         if (!theFormats().getFormat(cit->name()))
2730                                 os << "\\format \"" << cit->name()
2731                                    << "\" \"\" \"\" \"\" \"\" \"\" \"\" \"\"\n";
2732                 if (tag != RC_LAST)
2733                         break;
2734                 // fall through
2735         case RC_VIEWER_ALTERNATIVES: {
2736                 Alternatives::const_iterator it = viewer_alternatives.begin();
2737                 Alternatives::const_iterator const en = viewer_alternatives.end();
2738                 Alternatives::const_iterator const sysend =
2739                                 system_lyxrc.viewer_alternatives.end();
2740                 for (; it != en; ++it) {
2741                         string const & fmt = it->first;
2742                         CommandSet const & cmd = it->second;
2743                         CommandSet::const_iterator sit = cmd.begin();
2744                         CommandSet::const_iterator const sen = cmd.end();
2745                         Alternatives::const_iterator const sysfmt = ignore_system_lyxrc ?
2746                                         system_lyxrc.viewer_alternatives.begin() : // we won't use it in this case
2747                                         system_lyxrc.viewer_alternatives.find(fmt);
2748                         for (; sit != sen; ++sit) {
2749                                 string const & cmd = *sit;
2750                                 if (ignore_system_lyxrc
2751                                     || sysfmt == sysend               // format not found
2752                                          || sysfmt->second.count(cmd) == 0 // this command not found
2753                                    )
2754                                         os << "\\viewer_alternatives " << fmt << " \"" << escapeCommand(cmd) << "\"\n";
2755                         }
2756                 }
2757                 if (tag != RC_LAST)
2758                         break;
2759         }
2760         // fall through
2761         case RC_EDITOR_ALTERNATIVES: {
2762                 Alternatives::const_iterator it = editor_alternatives.begin();
2763                 Alternatives::const_iterator const en = editor_alternatives.end();
2764                 Alternatives::const_iterator const sysend =
2765                                 system_lyxrc.editor_alternatives.end();
2766                 for (; it != en; ++it) {
2767                         string const & fmt = it->first;
2768                         CommandSet const & cmd = it->second;
2769                         CommandSet::const_iterator sit = cmd.begin();
2770                         CommandSet::const_iterator const sen = cmd.end();
2771                         Alternatives::const_iterator const sysfmt = ignore_system_lyxrc ?
2772                                         system_lyxrc.editor_alternatives.begin() : // we won't use it in this case
2773                                         system_lyxrc.editor_alternatives.find(fmt);
2774                         for (; sit != sen; ++sit) {
2775                                 string const & cmd = *sit;
2776                                 if (ignore_system_lyxrc
2777                                     || sysfmt == sysend               // format not found
2778                                     || sysfmt->second.count(cmd) == 0 // this command not found
2779                                    )
2780                                         os << "\\editor_alternatives " << fmt << " \"" << escapeCommand(cmd) << "\"\n";
2781                         }
2782                 }
2783                 if (tag != RC_LAST)
2784                         break;
2785         }
2786         // fall through
2787         case RC_DEFAULT_OTF_VIEW_FORMAT:
2788                 if ((ignore_system_lyxrc ||
2789                      default_otf_view_format != system_lyxrc.default_otf_view_format)
2790                     && !default_otf_view_format.empty()) {
2791                         os << "\\default_otf_view_format " << default_otf_view_format << '\n';
2792                 }
2793                 if (tag != RC_LAST)
2794                         break;
2795                 // fall through
2796         case RC_DEFAULT_PLATEX_VIEW_FORMAT:
2797                 if ((ignore_system_lyxrc ||
2798                      default_platex_view_format != system_lyxrc.default_platex_view_format)
2799                     && !default_platex_view_format.empty()) {
2800                         os << "\\default_platex_view_format " << default_platex_view_format << '\n';
2801                 }
2802                 if (tag != RC_LAST)
2803                         break;
2804                 // fall through
2805         case RC_DEFAULT_VIEW_FORMAT:
2806                 if (ignore_system_lyxrc ||
2807                     default_view_format != system_lyxrc.default_view_format) {
2808                         os << "\\default_view_format " << default_view_format << '\n';
2809                 }
2810                 if (tag != RC_LAST)
2811                         break;
2812                 // fall through
2813         case RC_VIEWER:
2814                 // Ignore it
2815                 if (tag != RC_LAST)
2816                         break;
2817
2818                 os << "\n#\n"
2819                    << "# CONVERTERS SECTION ##########################\n"
2820                    << "#\n\n";
2821
2822         // fall through
2823         case RC_CONVERTER:
2824                 // Look for new converters
2825                 for (Converters::const_iterator cit = theConverters().begin();
2826                      cit != theConverters().end(); ++cit) {
2827                         Converter const * converter =
2828                                 theSystemConverters().getConverter(cit->from(),
2829                                                                    cit->to());
2830                         if (!converter ||
2831                             converter->command() != cit->command() ||
2832                             converter->flags() != cit->flags())
2833                                 os << "\\converter \"" << cit->from() << "\" \""
2834                                    << cit->to() << "\" \""
2835                                    << escapeCommand(cit->command()) << "\" \""
2836                                    << cit->flags() << "\"\n";
2837                 }
2838
2839                 // New/modifed converters
2840                 for (Converters::const_iterator cit = theSystemConverters().begin();
2841                      cit != theSystemConverters().end(); ++cit)
2842                         if (!theConverters().getConverter(cit->from(), cit->to()))
2843                                 os << "\\converter \"" << cit->from()
2844                                    << "\" \"" << cit->to() << "\" \"\" \"\"\n";
2845                 if (tag != RC_LAST)
2846                         break;
2847                 // fall through
2848         case RC_COPIER:
2849                 if (tag == RC_LAST)
2850                         os << "\n#\n"
2851                            << "# COPIERS SECTION ##########################\n"
2852                            << "#\n\n";
2853
2854                 // Look for new movers
2855                 Movers::const_iterator const sysbegin = theSystemMovers().begin();
2856                 Movers::const_iterator const sysend = theSystemMovers().end();
2857                 Movers::const_iterator it = theMovers().begin();
2858                 Movers::const_iterator end = theMovers().end();
2859
2860                 for (; it != end; ++it) {
2861                         Movers::const_iterator const sysit =
2862                                 find_if(sysbegin, sysend, SameMover(*it));
2863                         if (sysit == sysend) {
2864                                 string const & fmt = it->first;
2865                                 string const & command =
2866                                         it->second.command();
2867
2868                                 os << "\\copier " << fmt
2869                                    << " \"" << escapeCommand(command) << "\"\n";
2870                         }
2871                 }
2872                 if (tag != RC_LAST)
2873                         break;
2874
2875                 // We don't actually delete SpecialisedMover(s) from the
2876                 // map, just clear their 'command', so there's no need
2877                 // to test for anything else.
2878         }
2879
2880         os.flush();
2881 }
2882
2883
2884 void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new)
2885 {
2886         // Why the switch you might ask. It is a trick to ensure that all
2887         // the elements in the LyXRCTags enum is handled. As you can see
2888         // there are no breaks at all. So it is just a huge fall-through.
2889         // The nice thing is that we will get a warning from the compiler
2890         // if we forget an element.
2891         LyXRC::LyXRCTags tag = LyXRC::RC_LAST;
2892         switch (tag) {
2893         case LyXRC::RC_LAST:
2894         case LyXRC::RC_ACCEPT_COMPOUND:
2895                 if (lyxrc_orig.spellchecker_accept_compound != lyxrc_new.spellchecker_accept_compound)
2896                         if (theSpellChecker()) theSpellChecker()->advanceChangeNumber();
2897                 // fall through
2898         case LyXRC::RC_ALT_LANG:
2899         case LyXRC::RC_PLAINTEXT_LINELEN:
2900         case LyXRC::RC_AUTOCORRECTION_MATH:
2901         case LyXRC::RC_AUTOREGIONDELETE:
2902         case LyXRC::RC_AUTORESET_OPTIONS:
2903         case LyXRC::RC_AUTOSAVE:
2904         case LyXRC::RC_AUTO_NUMBER:
2905         case LyXRC::RC_BACKUPDIR_PATH:
2906         case LyXRC::RC_BIBTEX_ALTERNATIVES:
2907         case LyXRC::RC_BIBTEX_COMMAND:
2908         case LyXRC::RC_BINDFILE:
2909         case LyXRC::RC_CHECKLASTFILES:
2910         case LyXRC::RC_COMPLETION_CURSOR_TEXT:
2911         case LyXRC::RC_COMPLETION_INLINE_DELAY:
2912         case LyXRC::RC_COMPLETION_INLINE_DOTS:
2913         case LyXRC::RC_COMPLETION_INLINE_MATH:
2914         case LyXRC::RC_COMPLETION_INLINE_TEXT:
2915         case LyXRC::RC_COMPLETION_POPUP_AFTER_COMPLETE:
2916         case LyXRC::RC_COMPLETION_POPUP_DELAY:
2917         case LyXRC::RC_COMPLETION_POPUP_MATH:
2918         case LyXRC::RC_COMPLETION_POPUP_TEXT:
2919         case LyXRC::RC_COMPLETION_MINLENGTH:
2920         case LyXRC::RC_USELASTFILEPOS:
2921         case LyXRC::RC_LOADSESSION:
2922         case LyXRC::RC_CHKTEX_COMMAND:
2923         case LyXRC::RC_CONVERTER:
2924         case LyXRC::RC_CONVERTER_CACHE_MAXAGE:
2925         case LyXRC::RC_COPIER:
2926         case LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR:
2927         case LyXRC::RC_SCROLL_BELOW_DOCUMENT:
2928         case LyXRC::RC_DATE_INSERT_FORMAT:
2929         case LyXRC::RC_GUI_LANGUAGE:
2930         case LyXRC::RC_DEFAULT_OTF_VIEW_FORMAT:
2931         case LyXRC::RC_DEFAULT_PLATEX_VIEW_FORMAT:
2932         case LyXRC::RC_DEFAULT_VIEW_FORMAT:
2933         case LyXRC::RC_DEFFILE:
2934         case LyXRC::RC_DIALOGS_ICONIFY_WITH_MAIN:
2935         case LyXRC::RC_DISPLAY_GRAPHICS:
2936         case LyXRC::RC_DOCUMENTPATH:
2937                 if (lyxrc_orig.document_path != lyxrc_new.document_path) {
2938                         FileName path(lyxrc_new.document_path);
2939                         if (path.exists() && path.isDirectory())
2940                                 package().document_dir() = FileName(lyxrc.document_path);
2941                 }
2942                 // fall through
2943         case LyXRC::RC_EDITOR_ALTERNATIVES:
2944         case LyXRC::RC_ESC_CHARS:
2945         case LyXRC::RC_EXAMPLEPATH:
2946         case LyXRC::RC_FONT_ENCODING:
2947         case LyXRC::RC_FILEFORMAT:
2948         case LyXRC::RC_GROUP_LAYOUTS:
2949         case LyXRC::RC_HUNSPELLDIR_PATH:
2950         case LyXRC::RC_ICON_SET:
2951         case LyXRC::RC_INDEX_ALTERNATIVES:
2952         case LyXRC::RC_INDEX_COMMAND:
2953         case LyXRC::RC_JBIBTEX_COMMAND:
2954         case LyXRC::RC_JBIBTEX_ALTERNATIVES:
2955         case LyXRC::RC_JINDEX_COMMAND:
2956         case LyXRC::RC_NOMENCL_COMMAND:
2957         case LyXRC::RC_PYGMENTIZE_COMMAND:
2958         case LyXRC::RC_INPUT:
2959         case LyXRC::RC_KBMAP:
2960         case LyXRC::RC_KBMAP_PRIMARY:
2961         case LyXRC::RC_KBMAP_SECONDARY:
2962         case LyXRC::RC_LANGUAGE_AUTO_BEGIN:
2963         case LyXRC::RC_LANGUAGE_AUTO_END:
2964         case LyXRC::RC_LANGUAGE_COMMAND_BEGIN:
2965         case LyXRC::RC_LANGUAGE_COMMAND_END:
2966         case LyXRC::RC_LANGUAGE_COMMAND_LOCAL:
2967         case LyXRC::RC_LANGUAGE_GLOBAL_OPTIONS:
2968         case LyXRC::RC_LANGUAGE_CUSTOM_PACKAGE:
2969         case LyXRC::RC_LANGUAGE_PACKAGE_SELECTION:
2970         case LyXRC::RC_LYXRCFORMAT:
2971         case LyXRC::RC_MAC_DONTSWAP_CTRL_META:
2972         case LyXRC::RC_MAC_LIKE_CURSOR_MOVEMENT:
2973         case LyXRC::RC_MACRO_EDIT_STYLE:
2974         case LyXRC::RC_MAKE_BACKUP:
2975         case LyXRC::RC_MARK_FOREIGN_LANGUAGE:
2976         case LyXRC::RC_MOUSE_WHEEL_SPEED:
2977         case LyXRC::RC_MOUSE_MIDDLEBUTTON_PASTE:
2978         case LyXRC::RC_NUMLASTFILES:
2979         case LyXRC::RC_PARAGRAPH_MARKERS:
2980         case LyXRC::RC_PATH_PREFIX:
2981                 if (lyxrc_orig.path_prefix != lyxrc_new.path_prefix) {
2982                         prependEnvPath("PATH", lyxrc_new.path_prefix);
2983                         // Resets python path
2984                         support::os::python(true);
2985                 }
2986                 // fall through
2987         case LyXRC::RC_PREVIEW:
2988         case LyXRC::RC_PREVIEW_HASHED_LABELS:
2989         case LyXRC::RC_PREVIEW_SCALE_FACTOR:
2990         case LyXRC::RC_PRINTLANDSCAPEFLAG:
2991         case LyXRC::RC_PRINTPAPERDIMENSIONFLAG:
2992         case LyXRC::RC_PRINTPAPERFLAG:
2993         case LyXRC::RC_SAVE_COMPRESSED:
2994         case LyXRC::RC_SAVE_ORIGIN:
2995         case LyXRC::RC_SCREEN_DPI:
2996         case LyXRC::RC_SCREEN_FONT_ROMAN:
2997         case LyXRC::RC_SCREEN_FONT_ROMAN_FOUNDRY:
2998         case LyXRC::RC_SCREEN_FONT_SANS:
2999         case LyXRC::RC_SCREEN_FONT_SANS_FOUNDRY:
3000         case LyXRC::RC_SCREEN_FONT_SCALABLE:
3001         case LyXRC::RC_SCREEN_FONT_SIZES:
3002         case LyXRC::RC_SCREEN_FONT_TYPEWRITER:
3003         case LyXRC::RC_SCREEN_FONT_TYPEWRITER_FOUNDRY:
3004         case LyXRC::RC_GEOMETRY_SESSION:
3005         case LyXRC::RC_SCREEN_ZOOM:
3006         case LyXRC::RC_SERVERPIPE:
3007         case LyXRC::RC_SET_COLOR:
3008         case LyXRC::RC_SHOW_BANNER:
3009         case LyXRC::RC_OPEN_BUFFERS_IN_TABS:
3010         case LyXRC::RC_SPELLCHECKER:
3011                 if (lyxrc_orig.spellchecker != lyxrc_new.spellchecker)
3012                         setSpellChecker();
3013                 // fall through
3014         case LyXRC::RC_SPELLCHECK_CONTINUOUSLY:
3015         case LyXRC::RC_SPELLCHECK_NOTES:
3016         case LyXRC::RC_SPLITINDEX_COMMAND:
3017         case LyXRC::RC_TEMPDIRPATH:
3018         case LyXRC::RC_TEMPLATEPATH:
3019         case LyXRC::RC_TEX_ALLOWS_SPACES:
3020         case LyXRC::RC_TEX_EXPECTS_WINDOWS_PATHS:
3021                 if (lyxrc_orig.windows_style_tex_paths != lyxrc_new.windows_style_tex_paths) {
3022                         os::windows_style_tex_paths(lyxrc_new.windows_style_tex_paths);
3023                 }
3024                 // fall through
3025         case LyXRC::RC_TEXINPUTS_PREFIX:
3026         case LyXRC::RC_THESAURUSDIRPATH:
3027         case LyXRC::RC_UIFILE:
3028         case LyXRC::RC_USER_EMAIL:
3029         case LyXRC::RC_USER_NAME:
3030         case LyXRC::RC_USE_CONVERTER_CACHE:
3031         case LyXRC::RC_USE_CONVERTER_NEEDAUTH_FORBIDDEN:
3032         case LyXRC::RC_USE_CONVERTER_NEEDAUTH:
3033         case LyXRC::RC_USE_NATIVE_FILEDIALOG:
3034         case LyXRC::RC_USE_SYSTEM_COLORS:
3035         case LyXRC::RC_USE_TOOLTIP:
3036         case LyXRC::RC_USE_PIXMAP_CACHE:
3037         case LyXRC::RC_USE_SYSTEM_THEME_ICONS:
3038         case LyXRC::RC_VIEWDVI_PAPEROPTION:
3039         case LyXRC::RC_SINGLE_CLOSE_TAB_BUTTON:
3040         case LyXRC::RC_SINGLE_INSTANCE:
3041         case LyXRC::RC_SORT_LAYOUTS:
3042         case LyXRC::RC_FULL_SCREEN_LIMIT:
3043         case LyXRC::RC_FULL_SCREEN_SCROLLBAR:
3044         case LyXRC::RC_FULL_SCREEN_MENUBAR:
3045         case LyXRC::RC_FULL_SCREEN_STATUSBAR:
3046         case LyXRC::RC_FULL_SCREEN_TABBAR:
3047         case LyXRC::RC_FULL_SCREEN_TOOLBARS:
3048         case LyXRC::RC_FULL_SCREEN_WIDTH:
3049         case LyXRC::RC_VISUAL_CURSOR:
3050         case LyXRC::RC_CLOSE_BUFFER_WITH_LAST_VIEW:
3051         case LyXRC::RC_VIEWER:
3052         case LyXRC::RC_VIEWER_ALTERNATIVES:
3053         case LyXRC::RC_FORWARD_SEARCH_DVI:
3054         case LyXRC::RC_FORWARD_SEARCH_PDF:
3055         case LyXRC::RC_EXPORT_OVERWRITE:
3056         case LyXRC::RC_DEFAULT_DECIMAL_POINT:
3057         case LyXRC::RC_DEFAULT_LENGTH_UNIT:
3058         case LyXRC::RC_SCROLL_WHEEL_ZOOM:
3059         case LyXRC::RC_CURSOR_WIDTH:
3060                 break;
3061         }
3062 }
3063
3064
3065 #if 0
3066 string const LyXRC::getDescription(LyXRCTags tag)
3067 {
3068         docstring str;
3069
3070         switch (tag) {
3071         case RC_ACCEPT_COMPOUND:
3072                 str = _("Consider run-together words, such as \"diskdrive\" for \"disk drive\", as legal words?");
3073                 break;
3074
3075         case RC_ALT_LANG:
3076                 str = _("Specify an alternate language. The default is to use the language of the document.");
3077                 break;
3078
3079         case RC_PLAINTEXT_LINELEN:
3080                 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.");
3081                 break;
3082
3083         case RC_AUTOREGIONDELETE:
3084                 str = _("De-select if you don't want the current selection to be replaced automatically by what you type.");
3085                 break;
3086
3087         case RC_AUTORESET_OPTIONS:
3088                 str = _("De-select if you don't want the class options to be reset to defaults after class change.");
3089                 break;
3090
3091         case RC_AUTOSAVE:
3092                 str = _("The time interval between auto-saves (in seconds). 0 means no auto-save.");
3093                 break;
3094
3095         case RC_AUTO_NUMBER:
3096                 break;
3097
3098         case RC_BACKUPDIR_PATH:
3099                 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.");
3100                 break;
3101
3102         case RC_BIBTEX_COMMAND:
3103                 str = _("Define the options of bibtex (cf. man bibtex) or select an alternative compiler (e.g. mlbibtex or bibulus).");
3104                 break;
3105
3106         case RC_JBIBTEX_COMMAND:
3107                 str = _("Define the options of the bibtex program for PLaTeX (Japanese LaTeX).");
3108                 break;
3109
3110         case RC_BINDFILE:
3111                 str = _("Keybindings file. Can either specify an absolute path, or LyX will look in its global and local bind/ directories.");
3112                 break;
3113
3114         case RC_CHECKLASTFILES:
3115                 str = _("Select to check whether the lastfiles still exist.");
3116                 break;
3117
3118         case RC_CHKTEX_COMMAND:
3119                 str = _("Define how to run chktex. E.g. \"chktex -n11 -n1 -n3 -n6 -n9 -22 -n25 -n30 -n38\" Refer to the ChkTeX documentation.");
3120                 break;
3121
3122         case RC_CONVERTER:
3123                 break;
3124
3125         case RC_CONVERTER_NEEDAUTH_FORBIDDEN:
3126                 str = _("Forbid use of external converters with 'needauth' option to prevent undesired effects.");
3127                 break;
3128
3129         case RC_CONVERTER_NEEDAUTH:
3130                 str = _("Ask user before calling external converters with 'needauth' option to prevent undesired effects.");
3131                 break;
3132
3133         case RC_COPIER:
3134                 break;
3135
3136         case RC_CURSOR_FOLLOWS_SCROLLBAR:
3137                 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.");
3138                 break;
3139
3140         case RC_CURSOR_WIDTH:
3141                 str = _("Configure the width of the text cursor. Automatic zoom-controlled cursor width used when set to 0.");
3142                 break;
3143
3144         case RC_SCROLL_BELOW_DOCUMENT:
3145                 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");
3146                 break;
3147
3148         case RC_MAC_DONTSWAP_CTRL_META:
3149                 str = _("Make Apple key act as Meta and Control key as Ctrl.");
3150                 break;
3151
3152         case RC_MAC_LIKE_CURSOR_MOVEMENT:
3153                 str = _("Use the Mac OS X conventions for cursor movement");
3154                 break;
3155
3156         case RC_SHOW_MACRO_LABEL:
3157                 str = _("Show a small box around a Math Macro with the macro name when the cursor is inside.");
3158                 break;
3159
3160         case RC_DATE_INSERT_FORMAT:
3161                 //xgettext:no-c-format
3162                 str = _("This accepts the normal strftime formats; see man strftime for full details. E.g.\"%A, %e. %B %Y\".");
3163                 break;
3164
3165         case RC_DEFFILE:
3166                 str = _("Command definition file. Can either specify an absolute path, or LyX will look in its global and local commands/ directories.");
3167                 break;
3168
3169         case RC_DEFAULT_OTF_VIEW_FORMAT:
3170                 str = _("The default format used with LFUN_BUFFER_[VIEW|UPDATE] with non-TeX fonts.");
3171                 break;
3172
3173         case RC_DEFAULT_VIEW_FORMAT:
3174                 str = _("The default format used with LFUN_BUFFER_[VIEW|UPDATE].");
3175                 break;
3176
3177         case RC_DIALOGS_ICONIFY_WITH_MAIN:
3178                 str = _("Iconify the dialogs when the main window is iconified. (Affects only dialogs shown after the change has been made.)");
3179                 break;
3180
3181         case RC_DISPLAY_GRAPHICS:
3182                 str = _("Select how LyX will display any graphics.");
3183                 break;
3184
3185         case RC_DOCUMENTPATH:
3186                 str = _("The default path for your documents. An empty value selects the directory LyX was started from.");
3187                 break;
3188
3189         case RC_ESC_CHARS:
3190                 str = _("Specify additional chars that can be part of a word.");
3191                 break;
3192
3193         case RC_EXAMPLEPATH:
3194                 str = _("The path that LyX will set when offering to choose an example. An empty value selects the directory LyX was started from.");
3195                 break;
3196
3197         case RC_FONT_ENCODING:
3198                 str = _("The font encoding used for the LaTeX2e fontenc package. T1 is highly recommended for non-English languages.");
3199                 break;
3200
3201         case RC_FILEFORMAT:
3202                 break;
3203
3204         case RC_INDEX_COMMAND:
3205                 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\".");
3206                 break;
3207
3208         case RC_JINDEX_COMMAND:
3209                 str = _("Define the options of the index program for PLaTeX (Japanese LaTeX).");
3210                 break;
3211
3212         case RC_NOMENCL_COMMAND:
3213                 str = _("Define the options of makeindex (cf. man makeindex) to be used for nomenclatures. This might differ from the index processing options.");
3214                 break;
3215
3216         case RC_PYGMENTIZE_COMMAND:
3217                 str = _("The command to run the python pygments syntax highlighter.");
3218                 break;
3219
3220         case RC_INPUT:
3221                 break;
3222
3223         case RC_KBMAP:
3224         case RC_KBMAP_PRIMARY:
3225         case RC_KBMAP_SECONDARY:
3226                 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.");
3227                 break;
3228
3229         case RC_LANGUAGE_AUTO_BEGIN:
3230                 str = _("Select if a language switching command is needed at the beginning of the document.");
3231                 break;
3232
3233         case RC_LANGUAGE_AUTO_END:
3234                 str = _("Select if a language switching command is needed at the end of the document.");
3235                 break;
3236
3237         case RC_LANGUAGE_COMMAND_BEGIN:
3238                 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.");
3239                 break;
3240
3241         case RC_LANGUAGE_COMMAND_END:
3242                 str = _("The LaTeX command for changing back to the language of the document.");
3243                 break;
3244
3245         case RC_LANGUAGE_COMMAND_LOCAL:
3246                 str = _("The LaTeX command for local changing of the language.");
3247                 break;
3248
3249         case RC_LANGUAGE_GLOBAL_OPTIONS:
3250                 str = _("De-select if you don't want the language(s) used as an argument to \\documentclass.");
3251                 break;
3252
3253         case RC_LANGUAGE_CUSTOM_PACKAGE:
3254                 str = _("The LaTeX command for loading the language package. E.g. \"\\usepackage{babel}\", \"\\usepackage{omega}\".");
3255                 break;
3256
3257         case RC_LANGUAGE_PACKAGE_SELECTION:
3258                 str = _("De-select if you don't want babel to be used when the language of the document is the default language.");
3259                 break;
3260
3261         case RC_USELASTFILEPOS:
3262                 str = _("De-select if you do not want LyX to scroll to saved position.");
3263                 break;
3264
3265         case RC_LOADSESSION:
3266                 str = _("De-select to prevent loading files opened from the last LyX session.");
3267                 break;
3268
3269         case RC_MAKE_BACKUP:
3270                 str = _("De-select if you don't want LyX to create backup files.");
3271                 break;
3272
3273         case RC_MARK_FOREIGN_LANGUAGE:
3274                 str = _("Select to control the highlighting of words with a language foreign to that of the document.");
3275                 break;
3276
3277         case RC_MOUSE_WHEEL_SPEED:
3278                 str = _("The scrolling speed of the mouse wheel.");
3279                 break;
3280
3281         case RC_COMPLETION_POPUP_DELAY:
3282                 str = _("The completion popup delay.");
3283                 break;
3284
3285         case RC_COMPLETION_POPUP_MATH:
3286                 str = _("Select to display the completion popup in math mode.");
3287                 break;
3288
3289         case RC_COMPLETION_POPUP_TEXT:
3290                 str = _("Select to display the completion popup in text mode.");
3291                 break;
3292
3293         case RC_COMPLETION_POPUP_AFTER_COMPLETE:
3294                 str = _("Show the completion popup without delay after non-unique completion attempt.");
3295                 break;
3296
3297         case RC_COMPLETION_POPUP_TEXT:
3298                 str = _("Show a small triangle on the cursor to indicate that a completion is available.");
3299                 break;
3300
3301         case RC_COMPLETION_POPUP_DELAY:
3302                 str = _("The inline completion delay.");
3303                 break;
3304
3305         case RC_COMPLETION_INLINE_MATH:
3306                 str = _("Select to display the inline completion in math mode.");
3307                 break;
3308
3309         case RC_COMPLETION_INLINE_TEXT:
3310                 str = _("Select to display the inline completion in text mode.");
3311                 break;
3312
3313         case RC_COMPLETION_INLINE_DOTS:
3314                 str = _("Use \"...\" to shorten long completions.");
3315                 break;
3316
3317         case RC_AUTOCORRECTION_MATH:
3318                 str = _("Allow TeXMacs shorthand, like => converting to \\Rightarrow.");
3319                 break;
3320
3321         case RC_NUMLASTFILES:
3322                 str = bformat(_("Maximal number of lastfiles. Up to %1$d can appear in the file menu."),
3323                         maxlastfiles);
3324                 break;
3325
3326         case RC_PATH_PREFIX:
3327                 str = _("Specify those directories which should be "
3328                          "prepended to the PATH environment variable.\n"
3329                          "Use the OS native format.");
3330                 break;
3331
3332         case RC_PREVIEW:
3333                 str = _("Shows a typeset preview of things such as math");
3334                 break;
3335
3336         case RC_PREVIEW_HASHED_LABELS:
3337                 str = _("Previewed equations will have \"(#)\" labels rather than numbered ones");
3338                 break;
3339
3340         case RC_PREVIEW_SCALE_FACTOR:
3341                 str = _("Scale the preview size to suit.");
3342                 break;
3343
3344         case RC_PRINTLANDSCAPEFLAG:
3345                 str = _("The option to print out in landscape.");
3346                 break;
3347
3348         case RC_PRINTPAPERDIMENSIONFLAG:
3349                 str = _("Option to specify the dimensions of the print paper.");
3350                 break;
3351
3352         case RC_PRINTPAPERFLAG:
3353                 str = _("The option to specify paper type.");
3354                 break;
3355
3356         case RC_VISUAL_CURSOR:
3357                 str = _("Select to have visual bidi cursor movement, unselect for logical movement.");
3358                 break;
3359
3360         case RC_CLOSE_BUFFER_WITH_LAST_VIEW:
3361                 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).");
3362                 break;
3363
3364         case RC_SCREEN_DPI:
3365                 str = _("DPI (dots per inch) of your monitor is auto-detected by LyX. If that goes wrong, override the setting here.");
3366                 break;
3367
3368         case RC_SCREEN_FONT_ROMAN:
3369         case RC_SCREEN_FONT_SANS:
3370         case RC_SCREEN_FONT_TYPEWRITER:
3371                 str = _("The screen fonts used to display the text while editing.");
3372                 break;
3373
3374         case RC_SCREEN_FONT_ROMAN_FOUNDRY:
3375         case RC_SCREEN_FONT_SANS_FOUNDRY:
3376         case RC_SCREEN_FONT_TYPEWRITER_FOUNDRY:
3377                 break;
3378
3379         case RC_SCREEN_FONT_SCALABLE:
3380                 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.");
3381                 break;
3382
3383         case RC_SCREEN_FONT_SIZES:
3384                 str = _("The font sizes used for calculating the scaling of the screen fonts.");
3385                 break;
3386
3387         case RC_SCREEN_ZOOM:
3388                 //xgettext:no-c-format
3389                 str = _("The zoom percentage for screen fonts. A setting of 100% will make the fonts roughly the same size as on paper.");
3390                 break;
3391
3392         case RC_GEOMETRY_SESSION:
3393                 str = _("Allow session manager to save and restore windows geometry.");
3394                 break;
3395
3396         case RC_SERVERPIPE:
3397                 str = _("This starts the lyxserver. The pipes get an additional extension \".in\" and \".out\". Only for advanced users.");
3398                 break;
3399
3400         case RC_SET_COLOR:
3401                 break;
3402
3403         case RC_SHOW_BANNER:
3404                 str = _("De-select if you don't want the startup banner.");
3405                 break;
3406
3407         case RC_TEMPDIRPATH:
3408                 str = _("LyX will place its temporary directories in this path. They will be deleted when you quit LyX.");
3409                 break;
3410
3411         case RC_THESAURUSDIRPATH:
3412                 str = _("This is the place where the files of the thesaurus library reside.");
3413                 break;
3414
3415         case RC_TEMPLATEPATH:
3416                 str = _("The path that LyX will set when offering to choose a template. An empty value selects the directory LyX was started from.");
3417                 break;
3418
3419         case RC_TEX_ALLOWS_SPACES:
3420                 break;
3421
3422         case RC_TEX_EXPECTS_WINDOWS_PATHS:
3423                 break;
3424
3425         case RC_TEXINPUTS_PREFIX:
3426                 str = _("Specify those directories which should be "
3427                          "prepended to the TEXINPUTS environment variable.\n"
3428                          "A '.' represents the current document directory. "
3429                          "Use the OS native format.");
3430                 break;
3431
3432         case RC_UIFILE:
3433                 str = _("The UI (user interface) file. Can either specify an absolute path, or LyX will look in its global and local ui/ directories.");
3434                 break;
3435
3436         case RC_USER_EMAIL:
3437                 break;
3438
3439         case RC_USER_NAME:
3440                 break;
3441
3442         case RC_USE_USE_SYSTEM_COLORS:
3443                 str = _("Enable use the system colors for some things like main window background and selection.");
3444                 break;
3445
3446         case RC_USE_TOOLTIP:
3447                 str = _("Enable the automatic appearance of tool tips in the work area.");
3448                 break;
3449
3450         case RC_USE_PIXMAP_CACHE:
3451                 str = _("Enable the pixmap cache that might improve performance on Mac and Windows.");
3452                 break;
3453
3454         case RC_VIEWDVI_PAPEROPTION:
3455                 _("Specify the paper command to DVI viewer (leave empty or use \"-paper\")");
3456                 break;
3457
3458         case RC_VIEWER:
3459                 break;
3460
3461         case RC_LAST:
3462                 break;
3463         }
3464
3465         return str;
3466 }
3467 #endif
3468
3469
3470 // The global instance
3471 LyXRC lyxrc;
3472
3473 // The global copy of the system lyxrc entries (everything except preferences)
3474 LyXRC system_lyxrc;
3475
3476
3477 } // namespace lyx