[comp.os.msdos.programmer] QEdit 2.1 macros for C programmers

minar@reed.bitnet (Nelson Minar,L08,x640,7776519) (08/21/90)

Sorry for the bad wrapping job, but I'm on a DOS machine currently :)
The following are some QEdit 2.1 macros for helping C development.

-----------------------------progmac.doc-----------------------------

                   Simple macros for the C programmer
                            Using QEdit 2.1

Summary:  expanded functionality for the following tasks:
   f11: make
  #f11: tcc -c [currentfile]
  @f11: Dos command
   f12: locate error
  #f12: search for next error
  @f12: search for next warning
  ^tab: indent for comment


Description:
  This is a small macro package I find useful when programming. I hate
Turbo C's IDE, even if it is almost acceptable with the release of TC++
1.0 (its just too bulky - an 840k executable?) So, I use QEdit to do my
editing.  As such, quick access to compilation, making, and analyzing
the results of those actions is crucial.

  These macros fill that need. The two major macros are those by default
assigned to f11 and #f11.  f11 runs make, and #f11 compiles the current
working file.  These on their own are fairly simple, being inspired by
the comments in the distribution qconfig.dat. However, among other
things my display of the results of the make (the q.tmp file) is more
reliable.  These make and compile macros also have an extra 'feature.'
If text is currently highlighted (a block), that text is cut out of the
file and pasted into the command line.  This gives you the ability to
specify command line options on these commands. Example:

  f11:
    Expands to "make >q.tmp," then pulls up the error file for examination

  f11 with the text "-n" highlighted:
    Expands to "make -n >q.tmp," then pulls up the results for examination

  #f11 with the text "-wall" highlighted:
    Expands to "tcc -c -wall "[currentfile]

  There is an extra macro that uses this idea: @f11. It simply executes the
highlighted text with " >q.tmp" affixed.  Its sort of silly, but this way
you don't have to leave QEdit very often (now, to implement the EMACS
shell major-mode)

  There are other support macros.  The f12 macro, when invoked within
the output of tcc, will find the file and line number that error occured
in. Its not quite as powerful as the IDE's error finding feature, which
manages somehow to find the character the error occured on, not just the
line. I wish that information were available from tcc!

  The #f12 and @f12 macros are sort of silly, and just search for the next
warning or error message in the output from tcc.

  Finally, ^tab makes it a easier to deal with comments (by default, on
column 50).  C++ advocates might want to make it insert a "//", too.


Ruminations:
  Originally, I had intended to just reserve special scratchbuffer names
to add the ability to specify command line options.  Having a scratchbuffer
named 'make', and a scratchbuffer named 'tcc' is nice and clean, but its a
hassle to use, and not easy to macroize.  As such, the idea of having
highlighted text is used instead to allow substitution into command lines.
  The f12 macro set is Turbo C - output specific.  I've never seen any
of the other MS-DOS command line compilers.  I suspect it would be easy
to adapt this.
  The #f11 macro assumes the compiler is named tcc. Its not hard to change..
  It would be nice if the handling of the q.tmp file were better.
Currently, it throws away all of your open windows, except for the
current one.  Its annoying, but seems to be required to make sure that
the q.tmp file is refreshed and put on screen. Ideally, windows would
have names, and it would be easier to revert a file from disk than it is
currently.
  Some text is repeated in the macros (like the ' >q.tmp' appearing
twice in one macro). This is due to a strange bug involving the paste
command while within a Dos command.

  With the addition of JTrue and JFalse in QEdit 2.1, it is turning into
quite a powerful little macro editor.  There are still some things
missing, and what looks like a couple of little bugs.  Mostly, I would
really love to see QEdit generalize more - to make all dialog boxes
windows on their own accord (sure, we can Paste in a dialog box now, but
why can't we paste from a ScratchBuffer?).  It would also be nice if we
could give macros names, to make it easier to program.  And while I'm at
it, how about a few variables?  And an entire emacs emulation mode.. :)
Whatever the case, its a hell of a good editor now, and with a little
work and thought you can make it do some nifty things.


Legal crud:
  As far as I am concerned, this file and the macros are yours. All I ask is
that if you improve it, write me back and let me know.

                                          minar@reed.bitnet
                                          (soon to be minar@reed.edu)

-------------------------------cut-here-----------------------------------

------------------------------progmac.qm------------------------------------

* QEdit 2.1 macros for C programmers by minar@reed.bitnet
* As you may have noticed, these are all extended keyboard keys. Of course,
* you can change this.

* Make. If something is marked as a block, it will be put on the command line.
f11 MacroBegin
       Cut JFalse 1:                                     * can we cut?
       Dos 'make ' Paste ' >q.tmp' Return Return Jump 2: * yes, make w/paste
 1:    Dos 'make >q.tmp' Return Return                   * no, simple make
 2:    EditFile 'q.tmp' Return Quit                      * refresh q.tmp
       HorizontalWindow EditFile 'q.tmp' Return          * put it in a window

* tcc -c the current file.  Extra options can be put in a block.
#f11 MacroBegin
       Cut JFalse 1:
       Dos 'tcc -c ' Paste ' '  CurrentFileName ' >q.tmp'* tcc with paste
         Return Return Jump 2:
 1:    Dos 'tcc -c ' CurrentFileName ' >q.tmp'           * tcc simple
         Return Return
 2:    EditFile 'q.tmp' Return Quit                      * do the tmp stuff
       HorizontalWindow EditFile 'q.tmp' Return

* execute whatever is in the current block, saving the output
@f11 MacroBegin
       Cut JFalse 1:                                     * anything to do?
       Dos Paste ' >q.tmp' Return Return                 * yes, paste and go
       EditFile 'q.tmp' Return Quit                      * tmp file
       HorizontalWindow EditFile 'q.tmp' Return
 1:                                                      * done

* Given the output of tcc, go to the right file and line # on errors.
f12 MacroBegin
       BegLine WordRight AltWordSet MarkWord Copy        * find the file name
       NextWindow EditFile Paste Return                  * get the file
       PrevWindow WordRight MarkWord Copy BegLine        * get the line number
       NextWindow GotoLine Paste Return                  * go there
       MakeCtrOfScreen                                   * center
       DefaultWordSet                                    * quit

* Move to the next error in the tcc generated file (q.tmp).
#f12 MacroBegin
       Find 'Error' Return
       'W' Return

* Move to the next warning in the tcc generated file.
@f12 MacroBegin
       Find 'Warning' Return
       'W' Return

* Tab out to the comment field.
^tab MacroBegin
       GotoColumn '50' Return

-------------------------------cut-here-----------------------------------
__
\/ minar@reed.bitnet                         You know in your heart its flat.