Time-stamp: "xxx"the "xxx" part will be replaced by a time-stamp, every time you save the file. Of course one could also tell from file mtime, but if you have e.g. undated printouts, such time-stamps can help tell which is the newer. As Sunday is fun project time, I tried to emulate that feature "in 10 LOC or less". I needed 10, but here it is, usable for a text widget:}
proc timestamp w { set token {Time-stamp: "} set pos [$w search $token 1.0 5.end] if {$pos eq ""} return set from [$w index $pos+[string length $token]c] set to [$w search \" $from 5.end] if {$to eq ""} return $w delete $from $to $w insert $from [clock format [clock sec] -format %Y-%m-%d,%H:%M:%S] }#-- For testing, hit <F1> (in practice one would call timestamp before saving)
pack [text .t] .t insert end "# Demo\n# Time-stamp: \"whatever\"\n# more text..." bind .t <F1> {timestamp %W}Though stand-alone, this is part of e: a tiny editor plugin for eTcl, which again is part of Sepp.
Arts and crafts of Tcl-Tk programming