[comp.sys.amiga] 3 DME macros for programmers

utoddl@ecsvax.UUCP (Todd M. Lewis) (03/27/89)

Below are three DME macros that I find useful and thought I would pass them
on to others.  Use them at your own risk.  Each should appear on a single
line, but I broke them across several lines for readability.  All three
require that WORDWRAP be OFF to work properly.

The first macro (Ctrl-a) aligns the current line with the cursor.  That is,
the entire line is shifted left or right so that the first nonblank
character on the line is under the cursor.  It also moves the cursor down
one line so that another Ctrl-a will align the next line as well.  This is
useful for shifting blocks of text left or right:

      map (c-a) ( insline (.) down first
                  ifelse b
                    (wleft join down)
                    (wleft join)
                  del del
                  if !b (down)
                )

The next two macros are geared toward C programmers.  The first (alt-[)
makes a C-style comment out of the text from the cursor to the end of the
line.  Like the preceeding macro, it also moves the cursor to the following
line so that commenting blocks of text is rather painless.  I wrote this
after a thread on usenet convinced me that comments spanning multiple lines
could cause problems.

      map (a-[) ( (.) left split (/*) down last ( */)
                  up last join del del
                  ( ) left left left down
                )

This last macro simply removes the comment marks inserted by the previous
macro.  Your cursor MUST be on the '/' of the "/*" for this to work, and
because the last two characters on the line are deleted, they had better
be "*/".  Also note that this macro assumes a space after the "/*", and if
it isn't there you will loose what had been the first character of your
comment.  The previous macro makes comments that work with this one.

      map (a-]) ( (.) split down last bs bs up
                  last join bs
                  del del del del down
                )

  _____        
    |      Todd M. Lewis            Disclaimer: If you want my employer's
    ||\/|  utoddl@ecsvax.uncecs.edu             ideas, you'll have to
    ||  ||                                      _buy_ them. 
     |  ||     
         |___   (Never write a program bigger than your screen.)