Only new and modified views are saved; old ones are saved also if there are no new, modified or deleted view with same name.
This allows editing view list in concurrent gitk sessions without losing the changes. Signed-off-by: Max Kirillov <m...@max630.net> --- gitk | 42 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/gitk b/gitk index 6e22024..3394415 100755 --- a/gitk +++ b/gitk @@ -2807,7 +2807,11 @@ proc doprogupdate {} { proc config_variable_change_cb {name name2 op} { global config_variable_changed if {$op eq "write"} { - set config_variable_changed($name) 1 + if {$name2 eq ""} { + set config_variable_changed($name) 1 + } else { + set config_variable_changed($name,$name2) 1 + } } } @@ -2861,12 +2865,38 @@ proc savestuff {w} { puts $f "set geometry(botwidth) [winfo width .bleft]" puts $f "set geometry(botheight) [winfo height .bleft]" + array set view_save {} + array set views {} + foreach view $permviews { + set view_save([lindex $view 0]) 1 + set views([lindex $view 0]) $view + } puts -nonewline $f "set permviews {" for {set v 0} {$v < $current_nextviewnum} {incr v} { - if {$current_viewperm($v)} { - puts $f "{[list $current_viewname($v) $current_viewfiles($v) $current_viewargs($v) $current_viewargscmd($v)]}" + if {$config_variable_changed(viewname,$v) || + $config_variable_changed(viewfiles,$v) || + $config_variable_changed(viewargs,$v) || + $config_variable_changed(viewargscmd,$v) || + $config_variable_changed(viewperm,$v)} { + if {$current_viewperm($v)} { + set views($current_viewname($v)) [list $current_viewname($v) $current_viewfiles($v) $current_viewargs($v) $current_viewargscmd($v)] + } else { + set view_save($current_viewname($v)) 0 + } + lappend views_modified_names $current_viewname($v) } } + # write old and updated view to their places and append remaining to the end + foreach view $permviews { + set view_name [lindex $view 0] + if {$view_save($view_name)} { + puts $f "{$views($view_name)}" + } + unset views($view_name) + } + foreach view_name [array names views] { + puts $f "{$views($view_name)}" + } puts $f "}" close $f file rename -force $config_file_tmp $config_file @@ -12828,6 +12858,12 @@ if {[info exists permviews]} { addviewmenu $n } } +foreach var {viewname viewfiles viewargs viewargscmd viewperm} { + for {set v 0} {$v < $nextviewnum} {incr v} { + set config_variable_changed($var,$v) 0 + } + trace add variable $var write config_variable_change_cb +} if {[tk windowingsystem] eq "win32"} { focus -force . -- 2.0.1.1697.g73c6810 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html