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