Posted to tcl by bairui at Thu Jul 19 12:51:13 GMT 2018view raw

  1. #--- Heredoc style proc with margin to survive editor reformatting
  2. # and optional indent additional to that offset from the margin.
  3.  
  4. proc <<- {doc {margin >} {indent 0}} {
  5. set indent [string repeat { } $indent]
  6. set doc [string trim $doc]
  7. tailcall subst [regsub -all -lineanchor "^\\s*$margin" $doc $indent]
  8. }
  9.  
  10. # example:
  11.  
  12. proc usage {argv0 argv} {
  13. set usageError [<<- {
  14. >ERROR: [file tail ${argv0}]
  15. > ?--auto-update?
  16. > --rolback PIPTYPE PIPPACKAGE
  17. } > ]
  18. puts $usageError
  19. }
  20.  
  21. usage $argv0 $argv
  22.