hook global BufCreate .*[.](tcl) %{ set-option buffer filetype tcl } hook global WinSetOption filetype=tcl %{ require-module tcl hook window ModeChange pop:insert:.* -group tcl-trim-indent tcl-trim-indent hook window InsertChar \n -group tcl-insert tcl-insert-on-new-line hook window InsertChar \n -group tcl-indent tcl-indent-on-new-line hook -once -always window WinSetOption filetype=.* %{ remove-hooks window tcl-.+ } } hook -group tcl-highlight global WinSetOption filetype=tcl %{ add-highlighter window/tcl ref tcl hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/tcl } } # Using non-ascii characters here so that we can use the '[' command provide-module tcl %§ add-highlighter shared/tcl regions add-highlighter shared/tcl/code default-region group add-highlighter shared/tcl/comment region (? d } } define-command -hidden tcl-insert-on-new-line %[ # Copy '#' comment prefix and following white spaces try %{ execute-keys -draft k x s ^\h*\K#\h* y gh j P } ] define-command -hidden tcl-indent-on-new-line %¶ evaluate-commands -draft -itersel %@ # Preserve previous line indent try %{ execute-keys -draft K } # Filter previous line try %{ execute-keys -draft k : tcl-trim-indent } # Indent after { try %= execute-keys -draft , k x (\s|^)\{$ j = @ ¶ §