From: villate <vi...@us...> - 2025-07-23 20:53:39
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Maxima CAS". The branch, master has been updated via 253a9581aa0fae31ba113d1ff0bc2af149b93009 (commit) from 1ba3ab1ff56ad80cbb0907dbab33554acf0ad595 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 253a9581aa0fae31ba113d1ff0bc2af149b93009 Author: villate <vi...@fe...> Date: Wed Jul 23 21:47:16 2025 +0100 Parses the configuration file .xmaximarc, intead of "running" it. Only lines with a relevant key and a value (separated by spaces) will be used to update the xmaxima default array. This will work correctly with .xmaximarc files created by older versions of Xmaxima and will prevent unnecessary keys and values to be introduced. TO DO: I will next change the configuration file from ~/.xmaximarc to ~/.config/xmaxima/xmaxima_default diff --git a/interfaces/xmaxima/Tkmaxima/Browser.tcl b/interfaces/xmaxima/Tkmaxima/Browser.tcl index 1b3500f33..ef2c33d19 100644 --- a/interfaces/xmaxima/Tkmaxima/Browser.tcl +++ b/interfaces/xmaxima/Tkmaxima/Browser.tcl @@ -1060,27 +1060,29 @@ proc savePreferences {} { set ::xmaxima_default(iConsoleWidth) [textWindowWidth $console] set ::xmaxima_default(iConsoleHeight) [textWindowHeight $console] + # Saves the ::maxima_default array into .xmaximarc + # Each line will contain a key and value separated by space + # and the keys will be in alphabetical order catch { if {[winfo exists .browser]} { set ::xmaxima_default(browser) 1 } else { set ::xmaxima_default(browser) 0} - set fi [open "$::xmaxima_priv(home)/.xmaximarc" w] - puts $fi "array set ::xmaxima_default {" + set fileId [open "$::xmaxima_priv(home)/.xmaximarc" w] foreach {k v} [array get ::xmaxima_default *] { lappend all [list $k $v] } set all [lsort $all] - foreach v $all { puts $fi $v } - puts $fi "}" + foreach v $all { puts $fileId $v } #mike FIXME: make this a _default - if { [info exists ::xmaxima_priv(proxy,http)] && \ - [llength $::xmaxima_priv(proxy,http)] == 2 } { - puts $fi [list array set ::xmaxima_priv [array get ::xmaxima_priv proxy,http] - ] - } - close $fi + # if { [info exists ::xmaxima_priv(proxy,http)] && \ + # [llength $::xmaxima_priv(proxy,http)] == 2 } { + # puts $fileId [list array set ::xmaxima_priv [array get ::xmaxima_priv proxy,http] + # ] + # } Villate: This block seems wrong to me. + + close $file } catch { set hf [open "$::xmaxima_priv(home)/.xmaxima_history" w] diff --git a/interfaces/xmaxima/Tkmaxima/Constants.tcl b/interfaces/xmaxima/Tkmaxima/Constants.tcl index 6b753bed9..baec0bc37 100644 --- a/interfaces/xmaxima/Tkmaxima/Constants.tcl +++ b/interfaces/xmaxima/Tkmaxima/Constants.tcl @@ -35,7 +35,6 @@ proc cMAXINITBeforeIni {} { set ::xmaxima_default(OpenDir) "$::xmaxima_priv(home)/" # The last files opened and saved. Any default value serves # but a good starting value is Xmaxima's initialization file. - # TO DO: change ~ for a home directory customized for each system. set ::xmaxima_default(OpenFile) "$::xmaxima_priv(home)/.xmaximarc" set ::xmaxima_default(SaveFile) "$::xmaxima_priv(home)/.xmaximarc" @@ -49,13 +48,24 @@ proc cMAXINITBeforeIni {} { set ::xmaxima_priv(cachedir) "$::xmaxima_priv(home)/.xmaxima/cache" } +# Reads the xmaxima configuration file and if a line contains +# a key valid key and a value, separated by space, the value +# associated to that key in ::xmaxima_default will be set to +# that value. proc cMAXINITReadIni {} { if {[file isfile "$::xmaxima_priv(home)/.xmaximarc"]} { - if {[catch {uplevel "#0" [list source "$::xmaxima_priv(home)/.xmaximarc"]}\ - err]} { - tk_messageBox -title Error -icon error -message \ - [mc "Error sourcing %s\n%s" [file native ~/.xmaximarc] $err] - } + set fileId [open ~/.xmaximarc r] + foreach line [split [read $fileId] \n] { + if {![catch {llength $line}]} { + if {[llength $line] == 2} { + set key [lindex $line 0] + if {[info exists ::xmaxima_default($key)]} { + set ::xmaxima_default($key) [lindex $line 1] + } + } + } + } + close $fileId } } diff --git a/interfaces/xmaxima/Tkmaxima/Myhtml.tcl b/interfaces/xmaxima/Tkmaxima/Myhtml.tcl index 45a122d09..a9298fce2 100644 --- a/interfaces/xmaxima/Tkmaxima/Myhtml.tcl +++ b/interfaces/xmaxima/Tkmaxima/Myhtml.tcl @@ -1076,7 +1076,6 @@ proc xHMsetDefaultPreferences {} { } xHMsetDefaultPreferences -catch { source ~/.xmaximarc } proc dputs {x} { puts $x ; flush stdout ----------------------------------------------------------------------- Summary of changes: interfaces/xmaxima/Tkmaxima/Browser.tcl | 22 ++++++++++++---------- interfaces/xmaxima/Tkmaxima/Constants.tcl | 22 ++++++++++++++++------ interfaces/xmaxima/Tkmaxima/Myhtml.tcl | 1 - 3 files changed, 28 insertions(+), 17 deletions(-) hooks/post-receive -- Maxima CAS |