From 6d13d7de51b478d8a002550a3712726f4de36e02 Mon Sep 17 00:00:00 2001 From: rocky Date: Sat, 10 Dec 2022 15:45:18 -0500 Subject: [PATCH 1/2] Work around autoload not working for execute --- mathicsscript/__main__.py | 9 ++++++--- mathicsscript/data/inputrc-no-unicode | 2 +- mathicsscript/data/inputrc-unicode | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/mathicsscript/__main__.py b/mathicsscript/__main__.py index 4bf37dc..051dacd 100755 --- a/mathicsscript/__main__.py +++ b/mathicsscript/__main__.py @@ -288,7 +288,9 @@ def main( definitions, style, want_readline, completion, unicode, prompt ) - load_settings(shell) + # FIXME: why does load_settings fail when execute (-e) is set? + if not execute: + load_settings(shell) if run: with open(run, "r") as ifile: feeder = MathicsFileLineFeeder(ifile) @@ -378,6 +380,7 @@ def main( TeXForm = Symbol("System`TeXForm") definitions.set_line_no(0) + while True: try: if have_readline and shell.using_readline: @@ -389,11 +392,11 @@ def main( "Settings`$ShowFullFormInput" ).replace.to_python() style = definitions.get_ownvalue("Settings`$PygmentsStyle") - fmt = lambda x: x + fmt = lambda x: x # noqa if style: style = style.replace.get_string_value() if shell.terminal_formatter: - fmt = lambda x: highlight( + fmt = lambda x: highlight( # noqa str(query), mma_lexer, shell.terminal_formatter ) diff --git a/mathicsscript/data/inputrc-no-unicode b/mathicsscript/data/inputrc-no-unicode index 23fdc01..c1cb63c 100644 --- a/mathicsscript/data/inputrc-no-unicode +++ b/mathicsscript/data/inputrc-no-unicode @@ -1,5 +1,5 @@ # GNU Readline input unicode translations -# Autogenerated from mathics_scanner.generate.rl_inputrc on Wed Oct 26 04:49:35 PM EDT 2022 +# Autogenerated from mathics_scanner.generate.rl_inputrc on Wed Oct 26 05:37:20 PM EDT 2022 "\ea'\e": "á" "\ea-\e": "ā" diff --git a/mathicsscript/data/inputrc-unicode b/mathicsscript/data/inputrc-unicode index 23fdc01..c1cb63c 100644 --- a/mathicsscript/data/inputrc-unicode +++ b/mathicsscript/data/inputrc-unicode @@ -1,5 +1,5 @@ # GNU Readline input unicode translations -# Autogenerated from mathics_scanner.generate.rl_inputrc on Wed Oct 26 04:49:35 PM EDT 2022 +# Autogenerated from mathics_scanner.generate.rl_inputrc on Wed Oct 26 05:37:20 PM EDT 2022 "\ea'\e": "á" "\ea-\e": "ā" From d337b9a0e1c4cbb5903426754093f3403a373975 Mon Sep 17 00:00:00 2001 From: rocky Date: Sat, 10 Dec 2022 15:52:36 -0500 Subject: [PATCH 2/2] Show black diffs --- .github/workflows/autoblack.yml | 2 +- mathicsscript/__main__.py | 4 +--- mathicsscript/autoload/settings.m | 15 ++++++++------- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/.github/workflows/autoblack.yml b/.github/workflows/autoblack.yml index 9ecad8c..91a8daa 100644 --- a/.github/workflows/autoblack.yml +++ b/.github/workflows/autoblack.yml @@ -23,7 +23,7 @@ jobs: - name: If needed, commit black changes to the pull request if: failure() run: | - black . + black --diff . git config --global user.name 'autoblack' git config --global user.email 'rocky@users.noreply.github.com' git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY diff --git a/mathicsscript/__main__.py b/mathicsscript/__main__.py index 051dacd..75f2a52 100755 --- a/mathicsscript/__main__.py +++ b/mathicsscript/__main__.py @@ -288,9 +288,7 @@ def main( definitions, style, want_readline, completion, unicode, prompt ) - # FIXME: why does load_settings fail when execute (-e) is set? - if not execute: - load_settings(shell) + load_settings(shell) if run: with open(run, "r") as ifile: feeder = MathicsFileLineFeeder(ifile) diff --git a/mathicsscript/autoload/settings.m b/mathicsscript/autoload/settings.m index d265f4b..46c817a 100644 --- a/mathicsscript/autoload/settings.m +++ b/mathicsscript/autoload/settings.m @@ -13,27 +13,28 @@ " Settings`$ShowFullFormInput = False + +Settings`$PygmentsStyle = "inkpot" Settings`$PygmentsStyle::usage = "This variable sets the Pygments style used to colorize output. The value should be a string. The default value changes background depending on whether the terminal has a light or dark background. You can also set the color style used on the command with the ``--style`` option, or look at the variable ```Settings`PygmentsStylesAvailable```. Or it can be set in the settings.m file." -Settings`$PygmentsShowTokens::usage = "Setting this variable True will show Pygments tokenization of the output." - Settings`$PygmentsShowTokens = False +Settings`$PygmentsShowTokens::usage = "Setting this variable True will show Pygments tokenization of the output." -Settings`$UseUnicode::usage = "This Boolean variable sets whether Unicode is used in terminal input and output." Settings`$UseUnicode = True +Settings`$UseUnicode::usage = "This Boolean variable sets whether Unicode is used in terminal input and output." -Settings`$UseAsymptote::usage = "This Boolean variable sets whether 3D Graphics should render using Asymptote." Settings`$UseAsymptote = True +Settings`$UseAsymptote::usage = "This Boolean variable sets whether 3D Graphics should render using Asymptote." -Settings`$UseMatplotlib::usage = "This Boolean variable sets whether 2D Graphics should render using Matplotlib." Settings`$UseMatplotlib = True +Settings`$UseMatplotlib::usage = "This Boolean variable sets whether 2D Graphics should render using Matplotlib." Settings`MathicsScriptVersion::usage = "This string is the version of MathicsScript we are running." -System`$Notebooks::usage = "Set True if the Mathics is being used with a notebook-based front end." System`$Notebooks = False +System`$Notebooks::usage = "Set True if the Mathics is being used with a notebook-based front end." -Settings`$GroupAutocomplete::usage = "This Boolean variable sets whether mathicsscript should automatically close braces." Settings`$GroupAutocomplete = True +Settings`$GroupAutocomplete::usage = "This Boolean variable sets whether mathicsscript should automatically close braces."