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