Ping on this. We should make a decision about this before too long.

On 12/1/20 3:53 PM, Richard Kimberly Heck wrote:
Hi, all,

It has been suggested on the list that some (perhaps many) new users don't realize that LyX can do continuous spellcheck and would very much like it if it did. So it was proposed to enable it by default in 2.4.0. Existing users (meaning ones who have an earlier user directory that needs to be converted) will retain whatever setting they had. I.e., if it was off, it will be set to off; if it was on, it will remain on.

Although I never use continuous spellcheck myself, I agree myself that it is easier to figure out that you can turn this off than it is to realize you can turn it on, so have written a patch, attached, to do the prefs2prefs conversion. The only other change needed would be the default in LyXRC.h.

This is not yet a call for a vote (which I hope we will not need) but merely for discussion.

Riki




>From 5891fa7c3e4b3139aeb3a7c9e256f71d9a9122bf Mon Sep 17 00:00:00 2001
From: Richard Kimberly Heck <rikih...@lyx.org>
Date: Sun, 1 Nov 2020 18:05:17 -0500
Subject: [PATCH] Make default TRUE for continuous spellcheck.

Also, set preference to FALSE for existing users who do not have it
set to true (so behavior does not change for them).
---
 lib/configure.py                 |  2 +-
 lib/scripts/prefs2prefs.py       | 19 ++++++++++------
 lib/scripts/prefs2prefs_prefs.py | 38 +++++++++++++++++++++++++++-----
 src/LyXRC.cpp                    |  2 +-
 4 files changed, 47 insertions(+), 14 deletions(-)

diff --git a/lib/configure.py b/lib/configure.py
index ca62e65d63..38503c7c5d 100644
--- a/lib/configure.py
+++ b/lib/configure.py
@@ -1863,7 +1863,7 @@ if __name__ == '__main__':
     lyx_check_config = True
     lyx_kpsewhich = True
     outfile = 'lyxrc.defaults'
-    lyxrc_fileformat = 34
+    lyxrc_fileformat = 35
     rc_entries = ''
     lyx_keep_temps = False
     version_suffix = ''
diff --git a/lib/scripts/prefs2prefs.py b/lib/scripts/prefs2prefs.py
index 493ddf57bf..351deb4e02 100644
--- a/lib/scripts/prefs2prefs.py
+++ b/lib/scripts/prefs2prefs.py
@@ -4,7 +4,7 @@
 # This file is part of LyX, the document processor.
 # Licence details can be found in the file COPYING.
 
-# author Richard Heck
+# author Richard Kimberly Heck
 
 # Full author contact details are available in file CREDITS
 
@@ -16,13 +16,13 @@
 # the preferences file.
 #
 # I've organized it this way because, in many ways, converting bind and ui
-# files  lfuns) and converting the preferences file are the same task. It's
+# files (lfuns) and converting the preferences file are the same task. It's
 # very line-by-line, unlike lyx2lyx and layout2layout, where changes can be
 # more "global". So we read the file, line by line, and give a bunch of
 # converter functions a chance to see if they want to modify that line.
 
 # The converter functions are all in the subsidiary files. They take a line
-# as  argument and return a list: (Bool, NewLine), where the Bool says if
+# 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.
 
@@ -176,10 +176,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 598c06b794..4693d9a7e4 100644
--- a/lib/scripts/prefs2prefs_prefs.py
+++ b/lib/scripts/prefs2prefs_prefs.py
@@ -4,16 +4,32 @@
 # This file is part of LyX, the document processor.
 # Licence details can be found in the file COPYING.
 
-# author Richard Heck
+# author Richard Kimberly Heck
 
 # Full author contact details are available in file CREDITS
 
 # This file houses conversion information for the preferences file.
 
-# The converter functions take a line as argument and return a list:
+# 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
+# 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.
@@ -137,8 +153,13 @@
 # Incremented to format 34, by yuriy
 #   Rename *.kmap files for Cyrillic languages
 
+# Incremented to format 35, 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
 
@@ -451,6 +472,12 @@ def rename_cyrillic_kmap_files(line):
 	line = line.replace('"koi8-u"', '"ukrainian"')
 	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
 ####################################
 
@@ -499,5 +526,6 @@ conversions = [
 	[ 31, []],
 	[ 32, []],
 	[ 33, []],
-	[ 34, [rename_cyrillic_kmap_files]]
+	[ 34, [rename_cyrillic_kmap_files]],
+	[ 35, [add_spellcheck_default]]
 ]
diff --git a/src/LyXRC.cpp b/src/LyXRC.cpp
index 4fd5a287ca..a63dac086a 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 = 34; // yuriy: rename kmap files
+static unsigned int const LYXRC_FILEFORMAT = 35; // rkh: spellcheck_continuously default
 // when adding something to this array keep it sorted!
 LexerKeyword lyxrcTags[] = {
 	{ "\\accept_compound", LyXRC::RC_ACCEPT_COMPOUND },
-- 
2.26.2

-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel

Reply via email to