• lremove usage

    From Jacob@JacobLambeth@clevelandgolf.com to comp.lang.tcl on Wed Mar 11 11:24:03 2026
    From Newsgroup: comp.lang.tcl

    I'm looking at documentation for lremove and it says it removes by
    index. However, it appears to remove by a string match. Am I crazy? Is
    the documentation wrong or is the command implemented wrongly?

    Well I wrote this then answered my own question. Tkcon appears to
    override the built-in lremove command with a different one. FYI.

    (bin) 50 % info body lremove

    array set opts {-all 0 pattern -exact}
    while {[string match -* [lindex $args 0]]} {
    switch -glob -- [lindex $args 0] {
    -a* { set opts(-all) 1 }
    -g* { set opts(pattern) -glob }
    -r* { set opts(pattern) -regexp }
    -- { set args [lreplace $args 0 0]; break }
    default {return -code error "unknown option \"[lindex $args 0]\""}
    }
    set args [lreplace $args 0 0]
    }
    set l [lindex $args 0]
    foreach i [join [lreplace $args 0 0]] {
    if {[set ix [lsearch $opts(pattern) $l $i]] == -1} continue
    set l [lreplace $l $ix $ix]
    if {$opts(-all)} {
    while {[set ix [lsearch $opts(pattern) $l $i]] != -1} {
    set l [lreplace $l $ix $ix]
    }
    }
    }
    return $l

    (bin) 51 %
    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From meshparts@alexandru.dadalau@meshparts.de to comp.lang.tcl on Thu Mar 12 06:32:49 2026
    From Newsgroup: comp.lang.tcl

    Am 11.03.2026 um 19:24 schrieb Jacob:
    I'm looking at documentation for lremove and it says it removes by
    index. However, it appears to remove by a string match. Am I crazy? Is
    the documentation wrong or is the command implemented wrongly?

    Well I wrote this then answered my own question. Tkcon appears to
    override the built-in lremove command with a different one. FYI.

    (bin) 50 % info body lremove

    -a-a-a array set opts {-all 0 pattern -exact}
    -a-a-a while {[string match -* [lindex $args 0]]} {
    -a-a-a-aswitch -glob -- [lindex $args 0] {
    -a-a-a-a-a-a-a -a*-a-a-a { set opts(-all) 1 }
    -a-a-a-a-a-a-a -g*-a-a-a { set opts(pattern) -glob }
    -a-a-a-a-a-a-a -r*-a-a-a { set opts(pattern) -regexp }
    -a-a-a-a-a-a-a ---a-a-a { set args [lreplace $args 0 0]; break }
    -a-a-a-a-a-a-a default {return -code error "unknown option \"[lindex $args 0]\""}
    -a-a-a-a}
    -a-a-a-aset args [lreplace $args 0 0]
    -a-a-a }
    -a-a-a set l [lindex $args 0]
    -a-a-a foreach i [join [lreplace $args 0 0]] {
    -a-a-a-aif {[set ix [lsearch $opts(pattern) $l $i]] == -1} continue
    -a-a-a-aset l [lreplace $l $ix $ix]
    -a-a-a-aif {$opts(-all)} {
    -a-a-a-a-a-a-a while {[set ix [lsearch $opts(pattern) $l $i]] != -1} {
    -a-a-a-a-a-a-a set l [lreplace $l $ix $ix]
    -a-a-a-a-a-a-a }
    -a-a-a-a}
    -a-a-a }
    -a-a-a return $l

    (bin) 51 %

    You are probably using a custom package, that's overwritting the lremove command. Look out in you Tcl lib directory for the packages. I would
    open all *.tcl files with my text editor and use the find function over
    all opened files.
    --- Synchronet 3.21d-Linux NewsLink 1.2