The emacs text editor is widely used by computer programmers. It is rich in primitives and extensible too. A glossary of basic emacs concepts and a selection of command specifications are provided in Appendix 2 on emacs.
A collection of commands which prove useful to a beginning study of Java are provided in the the file java_env.el which can be loaded for use with the emacs "load-file" command. Among these are the following.Collectively these commands, as well as a few others, can considerably lighten the burden of mechanics associated with learning to program.
- The basic Java application template generator.
- A command to find the next slot to be filled with particular program information.
- A command to delete the "previous" slot, the slot just found.
- A command to transfer a demo of a program from a shell running in an emacs window to a slot in sources which correspond to Java applications.
The slot and filler emacs commands will be used to get a template, find and fill various slots of the template, and transfer a demo of the program to the <?DEMO> slot of the template. The basic approach is described below. Details of just how to do certain things are provided in the laboratory challenge which immediately follows.Generating a Template
" Generate a basic application template. "
[ You are in emacs. ]
[ You have loaded java_env.el. ]
< Create a buffer in which to place the program you are going to write. >
( Use C-x X-f. )
{ If you are not interacting with a buffer of appropriate emacs mode, which may be obtained with C-x C-f, the slot and filler commands will not work. }
[ You have a proper buffer before you. ]
< Issue the M-x java-app-template command. >
Find and Fill the Slots
You will find and fill each slot, except for the <?DEMO> slot, by doing the following for each slot.
" Find and fill the next slot. "
[ You are in the buffer with the template. ]
< Move to the next slot. >
( Type C-j. )
< Delete the slot just moved to. >
( Type M-j ).
< Type in the filler. >
Transfering your Demo
Once your program is correct, you will want to run it. You can transfer the output from the program as follows.
" Transfer your demo. "
[ You have run your program. ]
[ The other window contains your source program. ]
< Move the cursor to the start of the demo. >
< Issue the M-x transfer-demo command. >
If you are not using emacs, you can still choose to use the "slot and filler" approach to creating a source file. One way to proceed would be to create the templates yourself. Then you would " Generate a basic application template. " by simply loading the proper template file, write it to disk under a different name. You would " Find and fill in the next slot. " with whatever commands your editor provides. Finally, you would " Transfer you demo. " with whatever cutting and pasting mechanisms your editor provides.