home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / clarion / brfcla2.zip / UP_PAREN.M < prev   
Text File  |  1989-06-07  |  3KB  |  75 lines

  1. ;;* up_paren.m
  2. ;;* This macro will insert a pair of parentheses at the current cursor
  3. ;;* position and uppercase the immediately preceeding word if the file
  4. ;;* extension of the current buffer is in the list VALID_EXT. If the
  5. ;;* extension is not in the list, a pair of parentheses are inserted,
  6. ;;* the cursor is placed on the closing paren and the insert mode 
  7. ;;* is turned on.
  8. ;;*   Example for file extension of CLA: 
  9. ;;*           clock              -->      CLOCK()
  10. ;;*                ^cursor starts here          ^cursor is left here
  11. ;;*   Example for file extension not in VALID_EXT: 
  12. ;;*           clock              -->      clock()
  13. ;;*                ^cursor starts here          ^cursor is left here
  14.  
  15. ;;* When this macro is initially loaded, it is assigned to Alt=
  16.  
  17. ;;* Revision History
  18. ;;* ================
  19. ;;*  7-June-1989        Kevin Baradet     Incept Date
  20. ;;*
  21. ;;* Installation 
  22. ;;* ============
  23. ;;*     1) Compile this macro
  24. ;;*     2) To invoke type <F10> up_paren <enter>. Macro is now assigned to 
  25. ;;*         <Alt=>.
  26. ;;*     3) Or include the following in your initials macro to autoload it:
  27. ;;*        (autoload "up_paren" "up_paren")
  28. ;;* Define valid file extensions for this macro. Add new ext's if you wish
  29. ;;* Don't forget to uppercase the extension and terminate it with a slash.
  30.  
  31. #define VALID_EXT "/CLA/MDL/BAS/INC/"        
  32.  
  33. (macro _init                                ;;* Initialization macro
  34.    (
  35.    (assign_to_key "#-32000" "up_paren")    ;;* Assign to Alt=
  36.    )
  37. )
  38.  
  39. (macro up_paren
  40.    (
  41.    (extern toupper)
  42.    (string extension)
  43.    (inq_names NULL extension NULL)          ;;* Get file extension of buffer
  44.    (= extension (+ (upper (+= "/" extension)) "/"))
  45.    (if (!(inq_mode)) (insert_mode))         ;;* Turn on insert mode if off
  46.    (if (index VALID_EXT extension)          ;;* If ext in list then 
  47.       (
  48.       (insert "()")                         ;;* Insert pair of parens
  49.  
  50.       ;;* Comment next line out if you want the cursor left after the parens
  51.       (move_rel 0 -1)                        
  52.       (save_position)                       ;;* Push pos onto stack
  53.       (search_back "[~\\(\\)]")             ;;* Look for end of keyword/fn
  54.       (drop_anchor 0)                       ;;* Drop a normal mark
  55.       (search_back "[ \\t]\\c")             ;;* Find start of keyword/fn
  56.       (toupper)                             ;;* Convert marked to uppercase
  57.       (raise_anchor)                        ;;* Raise the anchor
  58.       (restore_position)                    ;;* Restore position from stack
  59.       )
  60.    ;else
  61.       (
  62.       (insert "()")                         ;;* Just insert a pair of parens
  63.       ;;* Comment next line out if you want the cursor left after the parens
  64.       (move_rel 0 -1)
  65.       )
  66.    )
  67.    )
  68. )
  69.  
  70.                     
  71.  
  72.  
  73.  
  74.  
  75.