home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / wp / brfmac.zip / BRFMAC.TXT next >
Text File  |  1989-05-01  |  3KB  |  90 lines

  1. ;****************************************************************************
  2. ;
  3. ;  BRIEF macros to jump forward/backward in source code by indent level
  4. ;
  5. ;  Written by Gene Smilgiewicz, UBM Corporation, NY  (212) 889-3898
  6. ;
  7. ;
  8. ;  If these make your editing life any easier and you're a Clipper guy/gal, 
  9. ;  please let me know of any great BRIEF macro(s) you may using ...
  10. ;
  11. ;****************************************************************************
  12. ;
  13. ;  I wrote these 'cause it's silly to waste time finding the beginning or end
  14. ;  of an indented block of code and couldn't find anyone who crossed this 
  15. ;  bridge before me.
  16. ;
  17. ;
  18. ;  move_to_end_indent
  19. ;
  20. ;     Moves the cursor down a column until it 
  21. ;     finds a non-whitespace character (space, 
  22. ;     tab, or newline) or winds up at the end 
  23. ;     of the buffer.
  24. ;
  25. ;
  26. ;  move_to_start_indent 
  27. ;
  28. ;     Moves the cursor up a column until it finds
  29. ;     a non-whitespace character (as above) or 
  30. ;     winds up on line 1.
  31. ;
  32. ;
  33. ;  For these macros to work well for you, assign them to keys that are 
  34. ;  intuitive.  I use the following in the macro routine associated with 
  35. ;  my initials:
  36. ;
  37. ;      (assign_to_key "^]" "move_to_end_indent")
  38. ;      (assign_to_key "^[" "move_to_start_indent")
  39. ;
  40. ;  With these assignments, whenever you want to jump to the end of an 
  41. ;  indented block, position the cursor at the beginning and press Ctrl-].  
  42. ;
  43. ;  Assuming you line up your if/else/endifs or braces, you'll wind up at 
  44. ;  the end of the block (or eof) pretty quickly.  With slight modifications
  45. ;  of the index and read expressions, these puppies can be useful for myriad 
  46. ;  other purposes when dealing with any type of structured text.
  47. ;
  48. ;****************************************************************************
  49.  
  50.  
  51. (macro move_to_end_indent
  52.    (
  53.       (message "Searching next non-blank in column")
  54.  
  55.       (move_rel 1 0)
  56.  
  57.       ;Modify the index string_to_search if you want 
  58.       ;to ignore formfeed or comment characters too.
  59.  
  60.       (while (&& (> (index " \t\n" (read 1)) 0) (! (inq_position)))
  61.          (move_rel 1 0)
  62.       )
  63.       (message "")
  64.    )
  65. )
  66.  
  67. (macro move_to_start_indent
  68.    (
  69.       (int line)
  70.  
  71.       (message "Searching previous non-blank in column")
  72.  
  73.       (move_rel -1 0)
  74.  
  75.       ;Modify the index string_to_search if you want 
  76.       ;to ignore formfeed or comment characters too.
  77.  
  78.       (while (> (index " \t\n" (read 1)) 0)
  79.          (
  80.             (inq_position line NULL)
  81.             (if (== line 1)
  82.                (break)
  83.             )
  84.             (move_rel -1 0)
  85.          )
  86.       )
  87.       (message "")
  88.    )
  89. )
  90.