Skip to content

Commit 5b8103a

Browse files
committed
gitk: use $config_variables as list for save/restore
gitk includes many user defined configuration variables, has all of these are listed in $config_variables. But this list is not used to define the variables to be loaded, saved, or restored when cancelling the configuration dialog, and developers must maintain separate lists of variables for these purposes. This leads to unnecessary errors and merge conflicts. Let's replace those separate lists with $config_variables to make maintenance easier. While we are on topic, sort the list of names in $config_variables. This makes it simpler to scan and has fewer chances of conflicts when new names are introduced. Helped-by: Johannes Sixt <[email protected]> Signed-off-by: Mark Levedahl <[email protected]>
1 parent b70227f commit 5b8103a

File tree

1 file changed

+66
-30
lines changed

1 file changed

+66
-30
lines changed

gitk

Lines changed: 66 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -11669,10 +11669,8 @@ proc create_prefs_page {w} {
1166911669
}
1167011670
1167111671
proc prefspage_general {notebook} {
11672-
global NS maxwidth maxgraphpct showneartags showlocalchanges
11673-
global tabstop wrapcomment wrapdefault limitdiffs
11674-
global autocopy autoselect autosellen extdifftool perfile_attrs
11675-
global hideremotes want_ttk have_ttk maxrefs web_browser
11672+
global NS have_ttk
11673+
global {*}$::config_variables
1167611674
1167711675
set page [create_prefs_page $notebook.general]
1167811676
@@ -11833,20 +11831,16 @@ proc prefspage_fonts {notebook} {
1183311831
}
1183411832
1183511833
proc doprefs {} {
11836-
global maxwidth maxgraphpct use_ttk NS
11837-
global oldprefs prefstop showneartags showlocalchanges
11838-
global uicolor bgcolor fgcolor ctext diffcolors selectbgcolor markbgcolor
11839-
global tabstop limitdiffs autoselect autosellen extdifftool perfile_attrs
11840-
global hideremotes want_ttk have_ttk wrapcomment wrapdefault
11834+
global use_ttk NS oldprefs prefstop
11835+
global {*}$::config_variables
1184111836
1184211837
set top .gitkprefs
1184311838
set prefstop $top
1184411839
if {[winfo exists $top]} {
1184511840
raise $top
1184611841
return
1184711842
}
11848-
foreach v {maxwidth maxgraphpct showneartags showlocalchanges \
11849-
limitdiffs tabstop perfile_attrs hideremotes want_ttk wrapcomment wrapdefault} {
11843+
foreach v $::config_variables {
1185011844
set oldprefs($v) [set $v]
1185111845
}
1185211846
ttk_toplevel $top
@@ -11970,10 +11964,9 @@ proc setfg {c} {
1197011964
1197111965
proc prefscan {} {
1197211966
global oldprefs prefstop
11967+
global {*}$::config_variables
1197311968
11974-
foreach v {maxwidth maxgraphpct showneartags showlocalchanges \
11975-
limitdiffs tabstop perfile_attrs hideremotes want_ttk wrapcomment wrapdefault} {
11976-
global $v
11969+
foreach v $::config_variables {
1197711970
set $v $oldprefs($v)
1197811971
}
1197911972
catch {destroy $prefstop}
@@ -11982,11 +11975,8 @@ proc prefscan {} {
1198211975
}
1198311976
1198411977
proc prefsok {} {
11985-
global maxwidth maxgraphpct
11986-
global oldprefs prefstop showneartags showlocalchanges
11987-
global fontpref mainfont textfont uifont
11988-
global limitdiffs treediffs perfile_attrs
11989-
global hideremotes wrapcomment wrapdefault
11978+
global oldprefs prefstop fontpref treediffs
11979+
global {*}$::config_variables
1199011980
global ctext
1199111981
1199211982
catch {destroy $prefstop}
@@ -12609,19 +12599,65 @@ catch {
1260912599
config_check_tmp_exists 50
1261012600
1261112601
set config_variables {
12612-
mainfont textfont uifont tabstop findmergefiles maxgraphpct maxwidth
12613-
cmitmode wrapcomment wrapdefault autocopy autoselect autosellen
12614-
showneartags maxrefs visiblerefs
12615-
hideremotes showlocalchanges datetimeformat limitdiffs uicolor want_ttk
12616-
bgcolor fgcolor uifgcolor uifgdisabledcolor colors diffcolors mergecolors
12617-
markbgcolor diffcontext selectbgcolor foundbgcolor currentsearchhitbgcolor
12618-
extdifftool perfile_attrs headbgcolor headfgcolor headoutlinecolor
12619-
remotebgcolor tagbgcolor tagfgcolor tagoutlinecolor reflinecolor
12620-
filesepbgcolor filesepfgcolor linehoverbgcolor linehoverfgcolor
12621-
linehoveroutlinecolor mainheadcirclecolor workingfilescirclecolor
12622-
indexcirclecolor circlecolors linkfgcolor circleoutlinecolor diffbgcolors
12602+
autocopy
12603+
autoselect
12604+
autosellen
12605+
bgcolor
12606+
circlecolors
12607+
circleoutlinecolor
12608+
cmitmode
12609+
colors
12610+
currentsearchhitbgcolor
12611+
datetimeformat
12612+
diffbgcolors
12613+
diffcolors
12614+
diffcontext
12615+
extdifftool
12616+
fgcolor
12617+
filesepbgcolor
12618+
filesepfgcolor
12619+
findmergefiles
12620+
foundbgcolor
12621+
headbgcolor
12622+
headfgcolor
12623+
headoutlinecolor
12624+
hideremotes
12625+
indexcirclecolor
12626+
limitdiffs
12627+
linehoverbgcolor
12628+
linehoverfgcolor
12629+
linehoveroutlinecolor
12630+
linkfgcolor
12631+
mainfont
12632+
mainheadcirclecolor
12633+
markbgcolor
12634+
maxgraphpct
12635+
maxrefs
12636+
maxwidth
12637+
mergecolors
12638+
perfile_attrs
12639+
reflinecolor
12640+
remotebgcolor
12641+
selectbgcolor
12642+
showlocalchanges
12643+
showneartags
12644+
tabstop
12645+
tagbgcolor
12646+
tagfgcolor
12647+
tagoutlinecolor
12648+
textfont
12649+
uicolor
12650+
uifgcolor
12651+
uifgdisabledcolor
12652+
uifont
12653+
visiblerefs
12654+
want_ttk
1262312655
web_browser
12656+
workingfilescirclecolor
12657+
wrapcomment
12658+
wrapdefault
1262412659
}
12660+
1262512661
foreach var $config_variables {
1262612662
config_init_trace $var
1262712663
trace add variable $var write config_variable_change_cb

0 commit comments

Comments
 (0)