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