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