• 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

        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 %

    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