[LyX/master] Make continuous spellcheck the default.

Richard Kimberly Heck rikiheck at lyx.org
Mon Feb 15 16:00:21 UTC 2021


commit 01dc665a2580f93007fcc25b6b897b67f507b664
Author: Richard Kimberly Heck <rikiheck at lyx.org>
Date:   Mon Feb 15 11:02:58 2021 -0500

    Make continuous spellcheck the default.
    
    Convert old preferences to preserve previous setting, as well.
---
 lib/configure.py                 |    2 +-
 lib/scripts/prefs2prefs.py       |   13 +++++++++----
 lib/scripts/prefs2prefs_prefs.py |   38 +++++++++++++++++++++++++++++++++-----
 src/LyXRC.cpp                    |    2 +-
 src/LyXRC.h                      |    2 +-
 5 files changed, 45 insertions(+), 12 deletions(-)

diff --git a/lib/configure.py b/lib/configure.py
index edfde33..bb69291 100644
--- a/lib/configure.py
+++ b/lib/configure.py
@@ -1944,7 +1944,7 @@ if __name__ == '__main__':
     lyx_check_config = True
     lyx_kpsewhich = True
     outfile = 'lyxrc.defaults'
-    lyxrc_fileformat = 34
+    lyxrc_fileformat = 36
     rc_entries = ''
     lyx_keep_temps = False
     version_suffix = ''
diff --git a/lib/scripts/prefs2prefs.py b/lib/scripts/prefs2prefs.py
index 353cf9e..597ba82 100644
--- a/lib/scripts/prefs2prefs.py
+++ b/lib/scripts/prefs2prefs.py
@@ -163,10 +163,15 @@ def main(argv):
             abort("Something is wrong with the conversion chain.")
 
         for c in convert:
-            for i in range(len(lines)):
-                (update, newline) = c(lines[i])
-                if update:
-                    lines[i] = newline
+            try:
+                # first see if the routine will accept a list of lines
+                c(lines)
+            except:
+                # if not, it wants individual lines
+                for i in range(len(lines)):
+                    (update, newline) = c(lines[i])
+                    if update:
+                        lines[i] = newline
 
         update_format(lines)
         format = get_format(lines)
diff --git a/lib/scripts/prefs2prefs_prefs.py b/lib/scripts/prefs2prefs_prefs.py
index d3a70d2..08c1f38 100644
--- a/lib/scripts/prefs2prefs_prefs.py
+++ b/lib/scripts/prefs2prefs_prefs.py
@@ -10,10 +10,26 @@
 
 # This file houses conversion information for the preferences file.
 
-# The converter functions take a line as argument and return a list:
-# 	(Bool, NewLine),
-# where the Bool says if  we've modified anything and the NewLine is
+# There are two kinds of converter functions.
+# 
+# Most of them take a line as argument and return a list:
+#     (Bool, NewLine),
+# where the Bool says if we've modified anything and the NewLine is
 # the new line, if so, which will be used to replace the old line.
+# This can be used to erase lines (return (True, "")) or to modify 
+# existing preference lines.
+# 
+# It is also possible for conversion routines to accept the whole
+# list of lines and process that. This is useful (as in the change
+# to format 35) when you need to add a preference if it's not already
+# there.
+
+
+######################################################################
+#
+# FORMAT CHANGES
+#
+######################################################################
 
 # Incremented to format 2, r39670 by jrioux
 #   Support for multiple file extensions per format.
@@ -141,8 +157,13 @@
 #   \set_color now takes three arguments
 #   \set_color lyxname x11hexname x11darkhexname
 
+# Incremented to format 36, by rkh
+#   Set spellcheck_continuously to FALSE if it is not otherwise set
+#   (the new default is true, so this keeps behavior the same for 
+#   existing users)
+
 # NOTE: The format should also be updated in LYXRC.cpp and
-# in configure.py.
+# in configure.py (search for lyxrc_fileformat).
 
 import re
 
@@ -465,6 +486,12 @@ def add_dark_color(line):
 	line += " " + m.group(2)
 	return (True, line)
 
+def add_spellcheck_default(lines):
+	for l in lines:
+		if l.startswith("\\spellcheck_continuously"):
+			return
+	lines.append("\\spellcheck_continuously false")
+
 # End conversions for LyX 2.3 to 2.4
 ####################################
 
@@ -514,5 +541,6 @@ conversions = [
 	[ 32, []],
 	[ 33, []],
 	[ 34, [rename_cyrillic_kmap_files]],
-	[ 35, [add_dark_color]]
+	[ 35, [add_dark_color]],
+	[ 36, [add_spellcheck_default]]
 ]
diff --git a/src/LyXRC.cpp b/src/LyXRC.cpp
index afa3000..e683286 100644
--- a/src/LyXRC.cpp
+++ b/src/LyXRC.cpp
@@ -60,7 +60,7 @@ namespace {
 
 // The format should also be updated in configure.py, and conversion code
 // should be added to prefs2prefs_prefs.py.
-static unsigned int const LYXRC_FILEFORMAT = 35; // spitz: dark mode colors
+static unsigned int const LYXRC_FILEFORMAT = 36; // rkh: spellcheck_continuously default
 // when adding something to this array keep it sorted!
 LexerKeyword lyxrcTags[] = {
 	{ "\\accept_compound", LyXRC::RC_ACCEPT_COMPOUND },
diff --git a/src/LyXRC.h b/src/LyXRC.h
index 530a781..cf6a012 100644
--- a/src/LyXRC.h
+++ b/src/LyXRC.h
@@ -370,7 +370,7 @@ public:
 	/// Accept compound words in spellchecker?
 	bool spellchecker_accept_compound = false;
 	/// spellcheck continuously?
-	bool spellcheck_continuously = false;
+	bool spellcheck_continuously = true;
 	/// spellcheck notes and comments?
 	bool spellcheck_notes = true;
 	///


More information about the lyx-cvs mailing list