home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Media Share 9
/
MEDIASHARE_09.ISO
/
clarion
/
brfcla2.zip
/
UP_PAREN.M
< prev
Wrap
Text File
|
1989-06-07
|
3KB
|
75 lines
;;* up_paren.m
;;* This macro will insert a pair of parentheses at the current cursor
;;* position and uppercase the immediately preceeding word if the file
;;* extension of the current buffer is in the list VALID_EXT. If the
;;* extension is not in the list, a pair of parentheses are inserted,
;;* the cursor is placed on the closing paren and the insert mode
;;* is turned on.
;;* Example for file extension of CLA:
;;* clock --> CLOCK()
;;* ^cursor starts here ^cursor is left here
;;* Example for file extension not in VALID_EXT:
;;* clock --> clock()
;;* ^cursor starts here ^cursor is left here
;;* When this macro is initially loaded, it is assigned to Alt=
;;* Revision History
;;* ================
;;* 7-June-1989 Kevin Baradet Incept Date
;;*
;;* Installation
;;* ============
;;* 1) Compile this macro
;;* 2) To invoke type <F10> up_paren <enter>. Macro is now assigned to
;;* <Alt=>.
;;* 3) Or include the following in your initials macro to autoload it:
;;* (autoload "up_paren" "up_paren")
;;* Define valid file extensions for this macro. Add new ext's if you wish
;;* Don't forget to uppercase the extension and terminate it with a slash.
#define VALID_EXT "/CLA/MDL/BAS/INC/"
(macro _init ;;* Initialization macro
(
(assign_to_key "#-32000" "up_paren") ;;* Assign to Alt=
)
)
(macro up_paren
(
(extern toupper)
(string extension)
(inq_names NULL extension NULL) ;;* Get file extension of buffer
(= extension (+ (upper (+= "/" extension)) "/"))
(if (!(inq_mode)) (insert_mode)) ;;* Turn on insert mode if off
(if (index VALID_EXT extension) ;;* If ext in list then
(
(insert "()") ;;* Insert pair of parens
;;* Comment next line out if you want the cursor left after the parens
(move_rel 0 -1)
(save_position) ;;* Push pos onto stack
(search_back "[~\\(\\)]") ;;* Look for end of keyword/fn
(drop_anchor 0) ;;* Drop a normal mark
(search_back "[ \\t]\\c") ;;* Find start of keyword/fn
(toupper) ;;* Convert marked to uppercase
(raise_anchor) ;;* Raise the anchor
(restore_position) ;;* Restore position from stack
)
;else
(
(insert "()") ;;* Just insert a pair of parens
;;* Comment next line out if you want the cursor left after the parens
(move_rel 0 -1)
)
)
)
)