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