Loading ...
Sorry, an error occurred while loading the content.

688RE: [jasspa] Digest Number 164

Expand Messages
  • Dan Perry
    Oct 11, 2002
    • 0 Attachment
      I Just wanted to share a macro that I wrote. I work with a lot of enums in C/C++ and I hate when my fellow developers don't align all the equal signs("=") in the enumeration. So I wrote this little macro to do it for me. To use it, adjust the first = to the proper column and run the macro. It stops if it attempts to delete characters other then spaces. Please let me know what you think and any way to improve it. Like possibly aligning tables or more then one character on each line...

      Dan


      define-macro align-enums
      set-variable .TheChar @wc
      set-variable .TheColumn $window-acol

      *nextline
      forward-line

      !if &or &xsequal @wl "^[ \t]*$" &xsequal @wl "^[ \t]*//.*$"
      !goto nextline
      !endif

      !if ¬ &xsequal @wl &cat &cat ".*" .TheChar ".*"
      !goto finish
      !endif

      beginning-of-line
      !while ¬ &sin @wc .TheChar
      forward-char
      !done

      !if &equal .TheColumn $window-acol
      !goto nextline
      !endif

      !if &less $window-acol .TheColumn
      !while &less $window-acol .TheColumn
      insert-space
      !done
      !goto nextline
      !endif

      !if &great $window-acol .TheColumn
      !while &great $window-acol .TheColumn
      backward-char
      !if ¬ &seq @wc " "
      !bell
      !abort
      !endif
      1 forward-delete-char
      !done
      !goto nextline
      !endif

      *finish
      ml-write "Finished"
      !return

      !emacro
    • Show all 2 messages in this topic