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