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