if 0 {[Richard Suchenwirth] 2006-02-12 - One of [emacs]'s many features is that when you have, in the first five (or so) lines of a file, the string 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] puts pos:$pos if {$pos eq ""} return set from [$w index $pos+[string length $token]c] set to [$w search \" $from 5.end] puts from:$from,to:$to 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 (in practice one would call ''timestamp'' before saving) pack [text .t] .t insert end "# Demo\n# Time-stamp: \"whatever\"\n# more text..." bind .t {timestamp %W} ---- [Arts and crafts of Tcl-Tk programming]