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