Check-in [c4f34cdde5]
Not logged in
Overview
Comment: tclreadlineSetup.tcl.in
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: c4f34cdde59ed5db71bd10a3651e129416a57d66
User & Date: johannes@zellner.org on 1999-09-06 12:08:46
Other Links: manifest | tags
Context
1999-09-08
16:35
Modified Files: Makefile.in configure.in sample.tclshrc tclreadline.c tclreadlineInit.tcl.in tclreadlineSetup.tcl.in Added Files: tclreadlineCompleter.tcl check-in: ad8b77b1ed user: johannes@zellner.org tags: trunk
1999-09-06
12:08
tclreadlineSetup.tcl.in check-in: c4f34cdde5 user: johannes@zellner.org tags: trunk
09:30
configure.in tclreadlineSetup.tcl.in check-in: 067d518401 user: johannes@zellner.org tags: trunk
Changes

Modified tclreadlineSetup.tcl.in from [eb1ce940bb] to [f3762613c5].

1
2
3

4
5
6
7
8
9
10
1
2

3
4
5
6
7
8
9
10


-
+







#!/usr/locanl/bin/tclsh
# FILE: "/diska/home/joze/src/tclreadline/tclreadlineSetup.tcl.in"
# LAST MODIFICATION: "Mon Sep  6 11:21:53 1999 (joze)"
# LAST MODIFICATION: "Mon Sep  6 14:07:26 1999 (joze)"
# (C) 1998, 1999 by Johannes Zellner, <johannes@zellner.org>
# $Id$
# ---
#
# tclreadline -- gnu readline for tcl
# Copyright (C) 1999  Johannes Zellner
#
221
222
223
224
225
226
227
228

229
230
231
232
233
234
235
221
222
223
224
225
226
227

228
229
230
231
232
233
234
235







-
+







        }
    }
    return -code error "invalid command name \"$name\""
}

namespace eval tclreadline {

namespace export Setup Glob Loop InitCmds InitTclCmds InitTkCmds Print ls
namespace export Setup Glob Loop InitTclCmds InitTkCmds Print ls

proc FirstNonOption {line} {
    set expr_pos 1
    foreach word [lrange ${line} 1 end] {; # 0 is the command itself
        if {"-" != [string index ${word} 0]} {
            break
        } else {
383
384
385
386
387
388
389
390

391
392
393
394

395
396
397
398


399
400
401
402
403
404




405
406
407
408
409
410
411
412
413
383
384
385
386
387
388
389

390
391
392
393

394
395
396


397
398






399
400
401
402


403
404
405
406
407
408
409







-
+



-
+


-
-
+
+
-
-
-
-
-
-
+
+
+
+
-
-







        return [list \"${value}\"]
    } else {
        return [list ${left}${value}${right}]
    }
}

proc InChannelId {text} {
    return [ChannelId ${text} <inChannel> {stdin}]
    return [ChannelId ${text} inChannel {stdin}]
}

proc OutChannelId {text} {
    return [ChannelId ${text} <outChannel> {stdout stderr}]
    return [ChannelId ${text} outChannel {stdout stderr}]
}

proc ChannelId {text {default <channelId>} {chs {stdin stdout stderr}}} {
    if {[llength ${text}]} {
proc ChannelId {text {default channelId} {chs {stdin stdout stderr}}} {
     if {[llength [set channel [MenuFromList ${text} ${chs}]]]} {
        set channel [AttemptFromList $text ${chs}]
        if {[llength [lindex ${channel} 0]]} {
            return ${channel}
        } else {
            return ""
        }
         return ${channel}
     } else {
         return [Menu ${default}]
     }
    }
    return ${default}
}

proc QuoteQuotes {line} {
    regsub -all -- \" $line {\"} line
    regsub -all -- \{ $line {\{} line; # \}\} (keep the editor happy)
    return $line
}
911
912
913
914
915
916
917
918

919
920
921
922
923
924
925
907
908
909
910
911
912
913

914
915
916
917
918
919
920
921







-
+







        }
    }
    set ::tclreadline::errorMsg [readline initialize $historyfile]
    if {$::tclreadline::errorMsg != ""} {
        puts stderr $::tclreadline::errorMsg
    }

    InitCmds
    # InitCmds

    rename Setup ""
}

proc HistoryFileGet {} {
    variable historyfile
    return $historyfile
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011









1012
1013
1014



1015
1016


1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037





















1038
1039

1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082






































1083
1084


1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125









































1126
1127


1128


1129
1130
1131
1132
1133
1134
1135
996
997
998
999
1000
1001
1002





1003
1004
1005
1006
1007
1008
1009
1010
1011



1012
1013
1014


1015
1016





















1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037


1038











































1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076


1077
1078









































1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119


1120
1121

1122
1123
1124
1125
1126
1127
1128
1129
1130







-
-
-
-
-
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
-
+
+







    if [regexp -nocase \(true\|yes\|1\) $args] {
        set PRINT yes
    } elseif [regexp -nocase \(false\|no\|0\) $args] {
        set PRINT no
    }
    return $PRINT
}

proc InitCmds {} {
    global tcl_version tk_version
    if {[info exists tcl_version]} {
        InitTclCmds
# 
# 
# proc InitCmds {} {
#     # XXX
#     return 
#     # XXX
#     global tcl_version tk_version
#     if {[info exists tcl_version]} {
#         InitTclCmds
    }
    if {[info exists tk_version]} {
        InitTkCmds
#     }
#     if {[info exists tk_version]} {
#         InitTkCmds
    }
    rename InitCmds ""
#     }
#     rename InitCmds ""
}

proc InitTclCmds {} {
    variable known_cmds
    foreach line {
        "after option ?arg arg ...?"
        "append varName ?value value ...?"
        "array option arrayName ?arg ...?"
        "bgerror"
        "break"
        "catch command ?varName?"
        "cd"
        "clock"
        "close <channelId>"
        "concat"
        "continue"
        "eof <channelId>"
        "error message ?errorInfo? ?errorCode?"
        "eval arg ?arg ...?"
        "exec ?switches? arg ?arg ...?"
        "exit ?returnCode?"
# }
# 
# proc InitTclCmds {} {
#     variable known_cmds
#     foreach line {
#         "after option ?arg arg ...?"
#         "append varName ?value value ...?"
#         "array option arrayName ?arg ...?"
#         "bgerror"
#         "break"
#         "catch command ?varName?"
#         "cd"
#         "clock"
#         "close <channelId>"
#         "concat"
#         "continue"
#         "eof <channelId>"
#         "error message ?errorInfo? ?errorCode?"
#         "eval arg ?arg ...?"
#         "exec ?switches? arg ?arg ...?"
#         "exit ?returnCode?"
        "expr arg ?arg ...?"
        "fblocked <channelId>"
#         "fblocked <channelId>"
        "fconfigure <channelId> ?optionName? ?value? ?optionName value?..."
        "fcopy input output ?-size size? ?-command callback?"
        "file"
        "fileevent channelId event ?script?"
        "flush channelId"
        "for start test next command"
        "foreach varList list ?varList list ...? command"
        "format formatString ?arg arg ...?"
        "gets channelId ?varName?"
        "glob"
        "global varName ?varName ...?"
        "incr varName ?increment?"
        "info option ?arg arg ...?"
        "interp cmd ?arg ...?"
        "join list ?joinString?"
        "lappend varName ?value value ...?"
        "lindex list index"
        "linsert list <index> <element> ?element ...?"
        "list"
        "llength list"
        "lrange list first last"
        "lreplace list first last ?element element ...?"
        "lsearch ?mode? list pattern"
        "lsort ?options? list"
        "namespace"
        "package option ?arg arg ...?"
        "proc name args body"
        "read ?-nonewline? channelId"
        "regexp ?switches? exp string ?matchVar? ?subMatchVar subMatchVar ...?"
        "rename oldName newName"
        "scan <string> <format> ?varName varName ...?"
        "set varName ?newValue?"
        "split <string> ?splitChars?"
        "subst ?-nobackslashes? ?-nocommands? ?-novariables? string"
        "switch ?switches? string pattern body ... ?default body?"
        "time <command> ?count?"
        "unknown <cmdName> ?arg? ?...?"
        "uplevel ?level? command ?arg ...?"
        "vwait name"
        "while test command"
    } {
        readline add $line
        set known_cmds([lindex $line 0]) ${line}
#         "for start test next command"
#         "foreach varList list ?varList list ...? command"
#         "format formatString ?arg arg ...?"
#         "gets channelId ?varName?"
#         "glob"
#         "global varName ?varName ...?"
#         "incr varName ?increment?"
#         "info option ?arg arg ...?"
#         "interp cmd ?arg ...?"
#         "join list ?joinString?"
#         "lappend varName ?value value ...?"
#         "lindex list index"
#         "linsert list <index> <element> ?element ...?"
#         "list"
#         "llength list"
#         "lrange list first last"
#         "lreplace list first last ?element element ...?"
#         "lsearch ?mode? list pattern"
#         "lsort ?options? list"
#         "namespace"
#         "package option ?arg arg ...?"
#         "proc name args body"
#         "read ?-nonewline? channelId"
#         "regexp ?switches? exp string ?matchVar? ?subMatchVar subMatchVar ...?"
#         "rename oldName newName"
#         "scan <string> <format> ?varName varName ...?"
#         "set varName ?newValue?"
#         "split <string> ?splitChars?"
#         "subst ?-nobackslashes? ?-nocommands? ?-novariables? string"
#         "switch ?switches? string pattern body ... ?default body?"
#         "time <command> ?count?"
#         "unknown <cmdName> ?arg? ?...?"
#         "uplevel ?level? command ?arg ...?"
#         "vwait name"
#         "while test command"
#     } {
#         readline add $line
#         set known_cmds([lindex $line 0]) ${line}
    }
    rename InitTclCmds ""
#     }
#     rename InitTclCmds ""
}

proc InitTkCmds {} {
    variable known_cmds
    foreach line {
        "bind window ?pattern? ?command?"
        "bindtags window ?tags?"
        "button pathName ?options?"
        "canvas pathName ?options?"
        "checkbutton pathName ?options?"
        "clipboard option ?arg arg ...?"
        "entry pathName ?options?"
        "event option ?arg1?"
        "font option ?arg?"
        "frame pathName ?options?"
        "grab option ?arg arg ...?"
        "grid option arg ?arg ...?"
        "image option ?args?"
        "label pathName ?options?"
        "listbox pathName ?options?"
        "lower window ?belowThis?"
        "menu pathName ?options?"
        "menubutton pathName ?options?"
        "message pathName ?options?"
        "option cmd arg ?arg ...?"
        "pack option arg ?arg ...?"
        "radiobutton pathName ?options?"
        "raise window ?aboveThis?"
        "scale pathName ?options?"
        "scrollbar pathName ?options?"
        "selection option ?arg arg ...?"
        "send ?options? interpName arg ?arg ...?"
        "text pathName ?options?"
        "tk option ?arg?"
        "tkwait variable|visibility|window name"
        "toplevel pathName ?options?"
        "winfo option ?arg?"
        "wm option window ?arg ...?"
    } {
        readline add $line
        set known_cmds([lindex $line 0]) ${line}
# }
# 
# proc InitTkCmds {} {
#     variable known_cmds
#     foreach line {
#         "bind window ?pattern? ?command?"
#         "bindtags window ?tags?"
#         "button pathName ?options?"
#         "canvas pathName ?options?"
#         "checkbutton pathName ?options?"
#         "clipboard option ?arg arg ...?"
#         "entry pathName ?options?"
#         "event option ?arg1?"
#         "font option ?arg?"
#         "frame pathName ?options?"
#         "grab option ?arg arg ...?"
#         "grid option arg ?arg ...?"
#         "image option ?args?"
#         "label pathName ?options?"
#         "listbox pathName ?options?"
#         "lower window ?belowThis?"
#         "menu pathName ?options?"
#         "menubutton pathName ?options?"
#         "message pathName ?options?"
#         "option cmd arg ?arg ...?"
#         "pack option arg ?arg ...?"
#         "radiobutton pathName ?options?"
#         "raise window ?aboveThis?"
#         "scale pathName ?options?"
#         "scrollbar pathName ?options?"
#         "selection option ?arg arg ...?"
#         "send ?options? interpName arg ?arg ...?"
#         "text pathName ?options?"
#         "tk option ?arg?"
#         "tkwait variable|visibility|window name"
#         "toplevel pathName ?options?"
#         "winfo option ?arg?"
#         "wm option window ?arg ...?"
#     } {
#         readline add $line
#         set known_cmds([lindex $line 0]) ${line}
    }
    rename InitTkCmds ""
#     }
#     rename InitTkCmds ""
}
# }
# 


# explicit command completers
#

# -------------------------------------
#                 TCL
1231
1232
1233
1234
1235
1236
1237
1238
1239


1240
1241
1242
1243
1244
1245


1246
1247
1248
1249
1250
1251


1252
1253
1254

1255
1256
1257
1258
1259
1260
1261
1262
1263


1264
1265

1266
1267
1268


1269
1270

1271
1272
1273
1274
1275








1276
1277
1278
1279

1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291













1292
1293
1294
1295
1296
1297

1298

1299
1300
1301




1302
1303
1304
1305
1306
1307





1308
1309


1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329

1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346



















1347
1348
1349
1350



1351
1352

1353
1354
1355
1356
1357



1358
1359
1360


1361
1362
1363

1364
1365
1366

1367


1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380











1381
1382
1383
1384


1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430








































1431
1432
1433
1434
1435




1436
1437
1438
1439
1440
1441
1442
1443

1444
1445
1446
1447
1448
1449
1450
1451
1452
1453











1454
1455
1456


1457

1458
1459
1460
1461
1462


1463

1464
1465
1466
1467
1468
1469
1470






1471
1472
1473
1474
1475
1476
1477
1226
1227
1228
1229
1230
1231
1232


1233
1234
1235
1236
1237
1238


1239
1240
1241
1242
1243
1244


1245
1246
1247
1248
1249
1250
1251
1252
1253






1254
1255


1256



1257
1258


1259





1260
1261
1262
1263
1264
1265
1266
1267




1268












1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288

1289



1290
1291
1292
1293






1294
1295
1296
1297
1298


1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321

















1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340




1341
1342
1343


1344
1345




1346
1347
1348



1349
1350



1351



1352

1353
1354
1355
1356
1357
1358
1359








1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370




1371
1372
1373
1374

1375
1376
1377
1378
1379






































1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420




1421
1422
1423
1424



1425
1426
1427
1428
1429
1430
1431
1432
1433







1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445


1446
1447
1448
1449
1450
1451
1452


1453
1454
1455
1456
1457
1458
1459




1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472







-
-
+
+




-
-
+
+




-
-
+
+



+



-
-
-
-
-
-
+
+
-
-
+
-
-
-
+
+
-
-
+
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+






+
-
+
-
-
-
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
-
-
+
+




















+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
+
+
+
-
-
+

-
-
-
-
+
+
+
-
-
-
+
+
-
-
-
+
-
-
-
+
-
+
+





-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
+
+


-





-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

-
-
-
-
+
+
+
+
-
-
-





+



-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+

-
-
+
+

+



-
-
+
+

+



-
-
-
-
+
+
+
+
+
+







    set cmd [lindex $line 1]
    switch -- $pos {
        1 {
            return [AttemptFromList $text {format scan}]
        }
        2 {
            switch -- $cmd {
                format - { return [Menu formatString] }
                scan - { return [Menu string] }
                format { return [Menu formatString] }
                scan   { return [Menu string] }
            }
        }
        3 {
            switch -- $cmd {
                format - { return [Menu ?arg?] }
                scan - { return [Menu formatString] }
                format { return [Menu ?arg?] }
                scan   { return [Menu formatString] }
            }
        }
        default {
            switch -- $cmd {
                format - { return [Menu ?arg?] }
                scan - { return [Menu ?varName?] }
                format { return [Menu ?arg?] }
                scan   { return [Menu ?varName?] }
            }
        }
    }
    return ""
}

proc complete(clock) {text start end line pos mod} {
    if {1 == $pos} {
        set cmds {clicks format scan seconds}
        return [AttemptFromList $text $cmds]
    } elseif {2 == $pos} {
        set cmd [lindex $line 1]
        switch -- $cmd {
    set cmd [lindex $line 1]
    switch -- $pos {
            clicks {}
            format {
        1 {
                if {"" == [lindex $line 2]} {
                    return <clockValue>
                }
            return [AttemptFromList $text {clicks format scan seconds}]
        }
            }
            scan {
        2 {
                if {"" == [lindex $line 2]} {
                    return <dateString>
                }
            }
            seconds {}
            switch -- $cmd {
                format  { return [Menu clockValue] }
                scan    { return [Menu dateString] }
                clicks  -
                seconds {}
            }
        }
        3 {
        }
    } elseif {3 == $pos} {
        set cmd [lindex $line 1]
        switch -- $cmd {
            switch -- $cmd {
            clicks {}
            format {
                set sub [lindex $line 3]
                set subcmds {-fmt -gmt}
                return [AttemptFromList $text $subcmds]
            }
            scan {
                set sub [lindex $line 3]
                set subcmds {-base -gmt}
                return [AttemptFromList $text $subcmds]
            }
            seconds {}
                format {
                    set sub [lindex $line 3]
                    set subcmds {-fmt -gmt}
                    return [AttemptFromList $text $subcmds]
                }
                scan {
                    set sub [lindex $line 3]
                    set subcmds {-base -gmt}
                    return [AttemptFromList $text $subcmds]
                }
                clicks  -
                seconds {}
            }
        }
    }
    return ""
}

proc complete(encoding) {text start end line pos mod} {
    set cmd [lindex $line 1]
    if {1 == $pos} {
    switch -- $pos {
        set cmds {convertfrom convertto names system}
        return [AttemptFromList $text $cmds]
    } elseif {2 == $pos} {
        1 {
            return [AttemptFromList $text {convertfrom convertto names system}]
        }
        2 {
        set cmd [lindex $line 1]
        switch -- $cmd {
            names {}
            convertfrom -
            convertto -
            system {
            switch -- $cmd {
                names {}
                convertfrom -
                convertto -
                system {
                set enc [encoding names]
                return [AttemptFromList ${text} ${enc}]
                    return [AttemptFromList ${text} [encoding names]]
                }
            }
        }
    }
    return ""
}

proc complete(expr) {text start end line pos mod} {
    set cmds {
        acos    cos     hypot   sinh 
        asin    cosh    log     sqrt 
        atan    exp     log10   tan 
        atan2   floor   pow     tanh 
        ceil    fmod    sin     abs 
        double  int     rand    round 
        srand 
    }
    return [AttemptFromList $text $cmds]
}

proc complete(fconfigure) {text start end line pos mod} {
    set cmd [lindex $line 1]
    if {1 == $pos} {
        return [ChannelId ${mod}]
    } else {
        set option [PreviousWord ${start} ${line}]
        switch -- $option {
            -blocking {
                return [AttemptFromList ${text} {yes no}]
            }
            -buffering {
                return [AttemptFromList ${text} {full line none}]
            }
            -buffersize {
                if {![llength ${text}} {
                    return <newSize>
                }
            }
            -encoding {
    switch -- $pos {
        1 {
            return [ChannelId ${mod}]
        }
        default {
            set option [PreviousWord ${start} ${line}]
            switch -- $option {
                -blocking {
                    return [AttemptFromList ${text} {yes no}]
                }
                -buffering {
                    return [AttemptFromList ${text} {full line none}]
                }
                -buffersize {
                    if {![llength ${text}]} {
                        return [Menu newSize]
                    }
                }
                -encoding {
                set enc [encoding names]
                return [AttemptFromList ${text} ${enc}]
            }
            -eofchar {
                    return [AttemptFromList ${text} [encoding names]]
                }
                -eofchar {
                if {![llength ${text}]} {
                    return [list {{<inChar> <outChar>}}]
                    return [Menu {\{inChar\ outChar\}}]
                }
            }
            -translation {
                return [AttemptFromList ${text} {auto binary cr crlf lf}]
            }
                -translation {
                    return [AttemptFromList ${text} {auto binary cr crlf lf}]
                }
        }
        set cmds {
            -blocking
                default {return [AttemptFromList $text {
                    -blocking -buffering -buffersize
            -buffering
            -buffersize
            -encoding
                    -encoding -eofchar -translation}]
            -eofchar
            -translation
        }
                }
        return [AttemptFromList $text $cmds]
            }
        }
    }
    return ""
}

proc complete(fcopy) {text start end line pos mod} {
    if {1 == $pos} {
        return [InChannelId ${mod}]
    } elseif {2 == $pos} {
        return [OutChannelId ${mod}]
    } else {
        set option [PreviousWord ${start} ${line}]
        switch -- $option {
            -size {
    switch -- $pos {
        1 {
            return [InChannelId ${mod}]
        }
        2 {
            return [OutChannelId ${mod}]
        }
        default {
            set option [PreviousWord ${start} ${line}]
            switch -- $option {
                -size    { return [Menu size] }
                if {![llength ${mod}]} { return <size> }
            }
            -command {
                if {![llength ${mod}]} { return <callback> }
                -command { return [Menu callback] }
                default  { return [AttemptFromList $text {-size -command}] }
            }
        }
        return [AttemptFromList $text {-size -command}]
    }
    return ""
}

proc complete(file) {text start end line pos mod} {
    if {1 == $pos} {
        set cmds {
            atime attributes copy delete dirname executable exists
            extension isdirectory isfile join lstat mtime mkdir
            nativename owned pathtype readable readlink rename
            rootname size split stat tail type volumes writable
        }
        return [AttemptFromList $text $cmds]
    } elseif {2 == $pos} {
        set cmd [lindex $line 1]
        switch -- $cmd {
            atime -
            attributes -
            dirname -
            executable -
            exists -
            extension -
            isdirectory -
            isfile -
            join -
            lstat -
            mtime -
            mkdir -
            nativename -
            owned -
            pathtype -
            readable -
            readlink -
            rootname -
            size -
            split -
            stat -
            tail -
            type -
            volumes -
            writable {
                return ""
            }
    switch -- $pos {
        1 {
            set cmds {
                atime attributes copy delete dirname executable exists
                extension isdirectory isfile join lstat mtime mkdir
                nativename owned pathtype readable readlink rename
                rootname size split stat tail type volumes writable
            }
            return [AttemptFromList $text $cmds]
        }
        2 {
            set cmd [lindex $line 1]
            switch -- $cmd {
                atime -
                attributes -
                dirname -
                executable -
                exists -
                extension -
                isdirectory -
                isfile -
                join -
                lstat -
                mtime -
                mkdir -
                nativename -
                owned -
                pathtype -
                readable -
                readlink -
                rootname -
                size -
                split -
                stat -
                tail -
                type -
                volumes -
                writable {
                    return ""
                }

            copy -
            delete -
            rename {
                set match [AttemptFromList ${mod} {-force}]
                copy -
                delete -
                rename {
                #    set match [MenuFromList ${mod} {-force}]
                if {[llength ${match}] && [llength ${mod}]} {
                    return ${match}
                } else {
                    return ""
                }
            }
        }
    }
    return ""
}

proc complete(fileevent) {text start end line pos mod} {
    if {1 == $pos} {
        return [ChannelId ${mod}]
    } elseif {2 == $pos} {
        return [AttemptFromList ${mod} {readable writable}]
    }
}

    switch -- $pos {
        1 {
            return [ChannelId ${mod}]
        }
        2 {
            return [CompleteFromList ${mod} {readable writable}]
        }
    }
    return ""
}

proc complete(flush) {text start end line pos mod} {
    if {1 == $pos} {
        return [ChannelId ${mod}]
    switch -- $pos {
        1 { return [ChannelId ${mod}] }
    }
    return ""
}

proc complete(gets) {text start end line pos mod} {
    if {1 == $pos} {
        return [InChannelId ${mod}]
    switch -- $pos {
        1 { return [InChannelId ${mod}] }
    }
    return ""
}

proc complete(glob) {text start end line pos mod} {
    if {1 == $pos} {
        set matches [AttemptFromList ${mod} {-nocomplain --}]
        if {[llength [string trim ${mod}]] && [llength ${matches}]} {
            return ${matches}
    switch -- $pos {
        1 {
            set matches [AttemptFromList ${mod} {-nocomplain --}]
            if {[llength [string trim ${mod}]] && [llength ${matches}]} {
                return ${matches}
            }
        }
    }
    return ""
}

proc complete(global) {text start end line pos mod} {
    return [VarCompletion ${text}]