[comp.sources.amiga] v02i001: MicroEMACS 38i 'C' Macros

phillip@cbmvax.UUCP (07/18/87)

Here are some MicroEMACS 38i macros that will walk you through your source
after an error ridden compile...It uses the compiler output to determine
the errored source file and automagically puts the error line in front of
you with the error message at the top of the screen. Currently the macros
only know about Aztec C compiler output...have fun...
-phil
==============================================================================
Phillip (Flip) Lindsay - Wake up and watch CNN at: Heather Ridge Apts. #G-115
UUCP: {ihnp4|seismo|caip}!cbmvax!phillip           Mantua, NJ 08051
No warranty is implied or otherwise given in the 
form of suggestion or example. Any opinions found here are of my making.
-----------------------cut here
;   Cmacros!
;
;   Here are a couple handy macros for MircoEMACS 38i. You can add these to 
;   your startup file ".emacsrc" or simply "execute-file" this macro file. It
;   attaches two macro programs to F9 and F10. Pressing F9 causes the source
;   in the current buffer to be compiled. ( based on buffer file name )
;   On errors a jump is made to the source line(s) with the error message(s)
;   shown as the top line of the screen. 
;   The output of the compile is sent to a error file "error.dat"...If there
;   are any errors after the compile you will be automatically positioned at the
;   error line with the corresponding error message displayed at the top of the
;   screen. Pressing F10 causes you to proceed to the next error.
;
; Compile and error check
;
; This macro will compile the source file in the current buffer. Then it
;   will call the error handling macro which looks for a magic file
;   named "error.dat"...The error handling macro takes it from there...
;   
;   This macro is bound to the F9 function key.
;
bind-to-key execute-macro-9 FN8
9   store-macro
    delete-other-windows
    delete-buffer "error.dat"
    set %command "CC "
    set %command &cat %command ">error.dat "
    set %command &cat %command $cfname
    shell-command %command
    execute-macro-8
!endm
; 
; Error handling macro.
;
;   This macro is smart in knowing the format of Aztec C's error messages.
; It will automagically look for a file named "error.dat" in the current
; directory. If found it will find the first error message and the file
; it belongs to. It then reads the file in and jumps to the first known
; error line. All this macro needs is a file in the current directory
; named "error.dat" to function. ( assuming "error.dat" is the redirected
; output from the Aztec C compiler. ) This macro can be called repeatly to
; process every error line in "error.dat"
;   
;               This macro is bound to the F10 function key.
;
bind-to-key execute-macro-8 FN9
8   store-macro
    delete-other-windows
    split-current-window
    1 next-window
    9 shrink-window
    !force find-file "error.dat"
    !if &sequal $status "FALSE"
        write-message "Error file not found."
        !return
    !endif
    beginning-of-line
    next-line
    !force search-forward ":"
    !if &sequal $status "FALSE"
        write-message "No more errors found."
        next-window
        delete-other-windows
        !return
    !endif                
    beginning-of-line
    set %file &chr $curchar
*fileget
    forward-character
    !if &equal $curchar 58
        !goto filehave
    !endif
    set %file &cat %file &chr $curchar
    !goto fileget
*filehave   
    search-forward ":"
    set %line &chr $curchar
*lineget
    forward-character
    !if &equal $curchar 58
        !goto linegot
    !endif
    set %line &cat %line &chr $curchar
    !goto lineget
*linegot
    next-window
    !force find-file %file
    !if &sequal $status "FALSE"
        write-message "Source file not found."
        !return
    !endif
    goto-line %line
!endm
; 
; labl1