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