Newsgroups: mod.sources Subject: MicroEMACS 3.6 (Part 1 of 8) Approved: jpn@panda.UUCP Mod.sources: Volume 4, Issue 98 Submitted by: genrad!decvax!ihnp4!itivax!duncan!lawrence echo x - readme sed 's/^X//' >readme <<'*-*-END-of-readme-*-*' X MicroEMACS 3.6 new goodies X X- CMODE additions X X in CMODE, pressing a '#' when there is only preceding whitespace Xon a line causes the whitespace to be deleted. (for preprocesser Xcommands to be brought up against the left margin. X X- Next Buffer command X X The Next Buffer command (^X-X) switches the current window to Xthe next buffer in the buffer list (reading it in if needed). This is Xgood for editing lists of files (mainly on UNIX when the shell expands Xwild cards). X X- Fill paragraph modified X X The fill paragraph command ( Q) now puts two spaces after Xevery period at the end of a word. This is useful most of the time but Xoccasionally will put in spurious spaces (like after a middle initial). XAny suggestions on an algorithm for dealing with english would be Xappreciated. X X- Kill paragraph command added X X ^W is now bound to kill-paragraph. This kills the current Xparagraph which the cursor is in. A numeric argument will allow it to Xkill a number of paragraphs. X X- Global mode commands X X Set/delete global mode commands now allow the user to specify a Xdefault mode for newly created buffers. Thus, for example, if you Xalways wished to use EXACT case matching on a string, you could place a X"Set global mode exact" in your startup file and all buffers would start Xwith EXACT initially on. X X- Overwrite mode X X OVER mode allows you to type text over the top of other text Xwithout inserting it. This mode is very good for editing tables of Xinformation. X X- Insert Space command added X X The Insert Space command (^C or INSERT) inserts a space in front Xof the cursor push any text to the right one character farther to the Xright. This is a very usefull command while in OVERwrite mode. (I moved Xthe bind-to-key function to now initially be bound to -K) X X- Hunt Forward/Backward X X The hunt commands allow you to search for the last string Xsearched for without re-entering the string. Under PCDOS they are bound Xto -S and (the new function prefix proved even more Xverstile than I had thought when I wrote it. Do note the unusual Xdeclarations for them in EBIND.H) Under other environments they are not Xyet bound, and are probably best bound to a function key. X X- Amiga Function/Cursor keys: X X are now supported. Function keys 1-10 are FN 0 - FN 9, shifted Xfunction keys are FN P - FN Y, cursor keys are FN A - FN D, shifted Xcursor keys are FN S, FN T, FN a, and FN @. (Use the describe-key Xfunction to find specific keys). X X- Reverse video Status lines X X The status line for each buffer can now (due to popular demand) Xbe in reverse video. This is configuable in ESTRUCT.H for people who Xmight not want it. X X- Several Bug fixes: X X A bug in DOBUF would cause non-terminated strings under some Xcompilers has been fixed. X X Tabs when expanded on the AMIGA at display time sometimes caused XMicroEMACS to hang, this is fixed. (Reported by Dawn Banks) X X The current column position was not always maintained properly Xwhen executing a keyboard macro, this is fixed. (Reported by Ernst Christen). X X Re-wrote word wrapping algorithm to be have better when Xinserting text into the middle of a paragraph. X X 's at the end of a search to replace string cause the Xreplacement to terminate after they have done the first replacement on Xthe last line of the file, preventing MicroEMACS to hang while infinitly Xreplacing s. X X X- Future enhancments may include: X X -s on command line for alternative startup file X numbered kill buffers X fence matching for CMODE X sort region command X sentence movement and deletion commands X X If you make modifications to let MicroEMACS 3.6 run under any Xnew envirnments, please send me the changes. I am also looking for the Xinclude file "rainbow.h". X X Could some please test this out under the Mark Williams C Xcompiler (which I do not have) and send me any needed changes to have it Xrun properly [most probably in termio.c]. X X Send any ideas, suggestions or futher goodies to X Daniel Lawrence X ihnp4!pur-ee!pur-phy!duncan!lawrence X X============================================================================= X MicroEMACS 3.5 X X This version of MicroEMACS is based on the version written by XDave G. Conroy, and latter modified by Steve Wilhite and George Jones. XMy thanks goes to them for writting such nice, well structured and Xdocumented code. It is nice to see that there are some people out there Xwho know how to program well. X X I intend to continue to maintain this version and will consider Xadding features and supported machines on request. Current hardware Xsupported includes: X X IBM-PC under PCDOS/MSDOS and many compatibles X Dec Rainbow X Commodore Amiga X Unix V7 X Unix and Multix BSD 4.2 X Hewlett Packard 150 and various upgrades X XFeatures added to MicroEMACS since version 2.0 include: X X- Meta repeat codes X X Striking the key followed by a numeric argument (possibly Xwith a leading minus sign) passes an argument down to a command which is Xusually used as a repeat count. This is similar to the ^U command, but Xthere is no default value. X X- Change in repositioning command X X The command to reposition the cursor now repositions it, by Xdefault, to the center of the current window, rather than the first line Xof the window. This I think is much more usefull and also consistant Xwith many other emacs'. X X- File writting message.... X X For those of us with big files, when you start a write of a file Xto disk, the message [Writing..] now appears. This is so we know the Xmachine is really still there. (Paranoids Ahead!) X X- Search strings now can have s in them X X It is very usefull to be able to have newlines in search and Xreplace strings. To do this, all text input to searching commands is now Xterminated by an . X X- Replace!!!!! X X Yes, now we can replace as well as search. There are two flavors Xof this command. R allows us to replace each occurence of a string Xwith another string from the current point to the end of the file. X ^R also queries us at each string to see if we want to replace it. XTyping a question mark here will display the options. X X- Yes/no responces X X no longer require (or want) a return typed after them. X X- Spawning X X Fixed up some MSDOS spawning messages. WARNING: If you have your Xswitchchar set to a '-' instead of a '/' Lattice C may have problems Xwhen yanking up a new command processer. It will use a line like XCOMMAND /C . You may have to rewrite this library function Xto get it to work on your system properly. X X- Suspend MicroEMACS X X Under Unix BSD 4.2 we now have code to put the editor into the Xbackground and return to the parent shell. This is initially bound to Xthe ^X D keys. X X- Function keys X X Under MSDOS on IBM-PCs and compatibles, the function keys and Xcursor arrows now do what one would expect them to. There is a new Xprefix in the editor to accodate this. (Look in MAIN.C for this) This Xcan be used to add function key support to most any machine by adding a Xsmall piece of code to reconize the keys in the getkey() routine in Xmain.c, and adding the new definitions to the ebind.h header file. X X- Abort (^G) X X now prints out [Aborted] on the command line so you know what Xhappened. X X- Editor Modes X X Buffers now have modes associated with them. These modes can be Xset with the set-mode (^X M) and the delete-mode (^X ^M) commands. X X- CMODE mode X X When a file is read in with a .c or .h extention, CMODE is set Xfor that buffer. (This can also be manually set/deleted[see above]) In XCMODE, MicroEMACS attemts to be intelligent about doing automatic Xindentation for you. It will indent any line the same as the privious Xline unless the last line ended with a brace ({). Then it will indent an Xextra tab stop (which varies depending on how tabs are set). Any lines Xbegining with a close brace (}) will by undented one tab stop if possible. X X- WRAP mode X X This mode automatically wraps words onto the next line when the Xword extends beyond the current fill column. X X- VIEW mode X X This mode disables all commands that can change the current buffer. X X- EXACT mode X X Normally all searches are done ignoring case. With this mode Xset, only strings which exactly match the search string, including case, Xare matched. X X- GOTO line command X X The goto-line ( G) command will go to a specific line Xnumber of the file. For example to go to the 76th line of a file, type: X X 76 G X X- Rename buffer X X The command rename-buffer ( ^N) allows you to change the Xname of the current buffer. X X- Paragraph movement X X The forward-paragraph ( N) and previous-paragraph ( P) Xcommands allow movement from one paragraph to another. X X- nasty algorith fixed.... X X A rather nasty algorithm in the kill buffer processing got Xrewritten which ends up reducing the speed neeeded to wipe large areas Ximmensly. This may have appeared to lock up the machine on the older Xversions when a large wipe was attempted. X X- Header files rearranged X X ESTRUCT.H Structure and option declarations X EDEF.H Global and external variable declarations X EPATH.H Help and startup file paths X EFUNC.H Name binding table X EBIND.H Initial key binding tables X X- Paragraph filling!! X X The fill-paragraph ( Q) command reformats the current Xparagraph filling to the fill column as possible. Very handy.... X X- Long lines X X Lines longer than the screen now scroll right-left as you move Xthrough them. Seeing what your editing is a big improvement. X X- word move and deletes X X Due to massive demand by my users here, I have changed the way Xword move and delete work so that they are more consistant and usefull. XBut this change is configurable by changing the value of the NFWORD Xconstant in ESTRUCT.H X X- View flag on command line X X -v on the command line causes the editor to read a file in with XVIEW mode set on. -e (edit) is the opposite causing it to read in for Xediting (which is also the default). X X- Quick EXIT has done a quick change.... X X (sorry....) Quick-exit now writes out all changed buffers before Xexiting. X X- Very long file lines X X Very long lines (>255 chars) being read from a file now get Xwrapped on multiple lines (instead of simple refusing to read any more Xof the file as before) The user is warned about them with a message at Xthe end of the read. X X- Space not clearing messages X X Many of my users complained about the space not inserting itself Xafter a message (it just cleared the message line). This is now Xconfiguable in ESTRUCT.H X X- HELP commands! X X the describe-key (^X ?) command allows the user to type in one Xcommand and the editor echos back the command name bound to that key. XThe help ( ?) command grabs the top window (or splits if if not Xthere) and reads in the EMACS.HLP file. The list of places to look for Xthe help file are in EPATH.H X X- View file command X X View-file (^X ^V) is the same as find-file (old visit-file) Xexcept it leaves the found file in VIEW mode. X X- Improved updating X X On the systems that code has been written for, the screen update Xroutines will defer updating if there is type ahead present. This makes Xall movement commands much more pleasant. The code for this is in the Xfunction typahead() in TERMIO.C. This is currently implimented for XMSDOS, BSD4.2 and possible the AMIGA (Some one please check this out. I Xonly have limited access to an AMIGA) X X- Buffer lists X X are now alphabetically maintained. X X- Insert file X X Insert-file (^X ^I) allows you to insert the contents of a file Xat the current position of the current buffer. very useful X X- Scroll next window X X Scroll-next-down ( ^V) and scroll-next-up ( ^Z) allow Xyou to scroll the next window up and down by pages. X X- Arguments to searches X X All searches and replaces now take a preceding numeric argument Xto say how many times, rather than all the way to the bottom of the Xfile. X X- Binding keys X X The bind-to-key (^C) function allows you to change what Xcommand a key invokes. It will promt you for a command name, and then a Xkeystroke sequence. This is happy. Unbind-key ( ^C) allows you to Xmake a key now longer have a function. (This is good when you accidently Xbind or a letter to something) X X- Execute named command X X Will prompt you for a command name, and then execute it. This Xallows you to execute commands that are not currently bound to any keys. X X- Command name completion X X Any time you are prompted for a command, if you type in part of Xit and hit the space bar, the editor will try to finish it. If the bell Xrighs, it means there is now command like what you are typing. X X- Describe bindings X X Describe-bindings (not bound) will display a list of all the Xcommands in a window (splitting if neccesary) and the keys bound with Xthem. These will reflect the current bindings and not the default ones. XThis is a good way to find out the name of a command you can't remember, Xor which I picked a bad name for. (The names have been changed to Xprotect the guilty (thats me) and are in EFUNC.H You too can change them Xif you are into it). X X- Executing stuff X X The execute-command-line command prompts you for a command line Xon the bottom of the screen in the form: X X {Numeric argument} { {}} X X (where {} are for optional stuff) and then executes it. X X Execute-buffer executes a number of these commands in a buffer. XIf any errors are found, the buffers current location will be set to the Xbegining of the line with the error in it. X X Execute-file will read a file into a buffer, execute it, and Xthen kill the buffer if it executed to completion with no errors. X X- Startup file X X MicroEMACS will attempt to execute a startup file (whose name is Xin EPATH.H) on startup. The MSDOS name is EMACS.RC and under unix it is Xusually .emacsrc X X- Multiple files on the command line X X MicroEMACS will now except a list of files on the command line. XThese files will all be assigned buffers, but will not be read in until Xthe buffer is brought up in a window. -v and -e switches affect all the Xfiles following them. X X- FILE LOCKING X X This is for people on multi-user UNIX systems. What this feature Xcan do is prevent two people from editing the same file and stomping on Xeach others edits. Unfortunatly, the actually locking mechanism used Xwhere I work is propritory so I could not send it out, but I have left Xall the code (conditionally defined by the FILOCK symbol in ESTRUCT.H) Xleading up to the actually locking routines so some one else can add it Xwith little effort. Here are the comments for the actual routines that Xneed to be added: X X/********************** X * X * dolock -- lock the file fname X * X * if successful, returns NULL X * if file locked, returns username of person locking the file X * if other error, returns "LOCK ERROR: explanation" X * X *********************/ X Xchar *dolock(fname) X Xchar *fname; /* file name to be locked */ X X Xand X X X/********************** X * X * undolock -- unlock the file fname X * X * if successful, returns NULL X * if other error, returns "LOCK ERROR: explanation" X * X *********************/ X Xchar *undolock(fname) X Xchar *fname; /* file name to unlock */ X X X If some one wants to write these functions so they can be Xdistributed publicly, please mail a separate file with them to me Xand I will include them with these sources for others to use. X X- HP150 function/cursor key support X X is now finished and working. X *-*-END-of-readme-*-* echo x - Makefile sed 's/^X//' >Makefile <<'*-*-END-of-Makefile-*-*' XCFLAGS= -O -I/usr/tools/include/bland X XOFILES= ansi.o basic.o bind.o buffer.o display.o file.o \ X fileio.o hp150.o line.o lock.c main.o random.o region.o \ X search.o spawn.o tcap.o termio.o vt52.o window.o word.o X XCFILES= ansi.c basic.c bind.c buffer.c display.c file.c \ X fileio.c hp150.c line.c lock.c main.c random.c region.c \ X search.c spawn.c tcap.c termio.c vt52.c window.c word.c X XHFILES= estruct.h edef.h efunc.h epath.h X Xemacs: $(OFILES) X $(CC) $(CFLAGS) $(OFILES) -ltermcap -lc -o emacs X X$(OFILES): $(HFILES) *-*-END-of-Makefile-*-* echo x - emacs.hlp sed 's/^X//' >emacs.hlp <<'*-*-END-of-emacs.hlp-*-*' X MicroEMACS 3.6 Help screens (04/18/86) X X M- means to use the key prior to using another key X ^A means to use the control key at the same time as the A key X X^V or [Pg Dn] Scroll down M-< or [HOME] Begining of file X^Z or [Pg Up] Scroll up M-> or [END] End of file X X----------------------------------------------------------------------- X (1) MOVING THE CURSOR X X^F Forward character M-F Forward word Keypad arrows X^B Backward character M-B Backward word are active! X^A Front of line X^E End of line X^N Next line M-N Front of paragraph X^P Previous line M-P End of paragraph X----------------------------------------------------------------------- X (2) SEARCHING X X^S Search forward from cursor position. Type in a string to be searched X for at the prompt and end it with ESC. Either case matches either X unless EXECT mode is set for the current buffer X^R As above, but Reverse search from cursor position. X S Search for the next occurence of the last string (IBM-PC only) X R Search for the last occurence of the last string (IBM-PC only) X----------------------------------------------------------------------- X (3) REPLACING X XM-R Replace all instances of first typed-in string with second X typed-in string. End each string with ESC. XM-^R Replace with query. Answer with: X ^G cancel . exit to entry point X ! replace the rest Y replace & continue X ? Get a list of options N no replacement & continue X----------------------------------------------------------------------- X (4) CAPITALIZING & TRANSPOSING X XM-U UPPERCASE word XM-C Capitalize word ^T Transpose characters XM-L lowercase word X^X^L lowercase region X^X^U uppercase region X^Q Quote next entry, so that control codes may be entered into text X----------------------------------------------------------------------- X (5) REGIONS & THE KILL BUFFER X XM- set MARK at current position X^X^X eXchange mark and cursor X XA REGION will then be continuously-defined as the area between the mark and Xthe current cursor position. The KILL BUFFER is the text which has been Xmost recently saved or deleted. X----------------------------------------------------------------------- X (6) DELETING & INSERTING X X<-- Delete previous character M-<-- Delete previous word X^D Delete next character M-D Delete next word X^K Close (delete) to end of line Insert a space (IBM-PC only) X^O Open (insert) line Delete next char ( " ) X^W Delete region between mark (set using M-) and cursor XM-W Copy region to kill buffer X----------------------------------------------------------------------- X (7) COPYING AND MOVING X X^W Delete (Wipe) region M-W copy region to KILL buffer X^Y Yankback save buffer at cursor XGenerally, the procedure for copying or moving text is: X 1) Mark a REGION using M- at beginning and cursor at end. X 2) Delete it (with ^W) or copy it (with M-W) into the KILL buffer. X 3) Move the cursor to the desired location and yank it back (with ^Y). X----------------------------------------------------------------------- X (8) MODES OF OPERATION X^X M Add Mode ^X ^M Delete Mode X OVER Replaces (overwrites) rather than inserts characters X WRAP Turns on word wrap (automatic carraige return). X VIEW Allows viewing file without insertion and deletion. X EXACT All searches done with exact case matching X CMODE Automatic indenting for C program entry X (automatically set on any files ending with .C or .H) X----------------------------------------------------------------------- X (9) ON-SCREEN FORMATTING X X^X F Set fill column XMn- Set tab spacing to n charecters between tabs stops XM-Q Format paragraph so that text lies between margins X^X = Position report -- displays line number, char count, size X X X----------------------------------------------------------------------- X (10) MULTIPLE WINDOWS X XMany WINDOWS may be active at once on the screen. All windows may show Xdifferent parts of the same buffer, or each may display a different one. X X^X 2 Split the current window in two ^X 1 remove all but current window X^X O cursor to next window ^X ^ Enlarge current window XM-^V scroll down, other window M-^Z scroll up, other window X----------------------------------------------------------------------- X (11) MULTIPLE BUFFERS XA BUFFER is a named area containing a document being edited. Many buffers Xmay be activated at once. X^X B Switch to another buffer. = use just-previous buffer X^X ^B Type buffer directory in a window X^X ^F Find file; read into a new buffer created from filename. X^X K Delete a non-displayed buffer. X^X X Switch to next buffer in buffer list X----------------------------------------------------------------------- X (12) READING FROM DISK X X^X^F Find file; read into a new buffer created from filename. X (This is the usual way to begin editing a new file.) X^X^R Read file into current buffer, erasing its previous contents. X No new buffer will be created. X^X^I Insert file into current buffer at cursor's location. X^X^V Find a file to make current in VIEW mode X----------------------------------------------------------------------- X (13) SAVING TO DISK X X^X^S Save current buffer to disk, using the buffer's filename X as the name of the disk file. Any disk file of that name X will be overwritten. X^X^W Write current buffer to disk. Type in a new filename at the X prompt to write to; it will become the current buffer's filename. XM-Z Write out all changed buffers and exit MicroEMACS X----------------------------------------------------------------------- X (14) ACCESSING THE OPERATING SYSTEM X X^X! Send one command to the operating system and return X^XC Start a new command processer under MicroEMACS X^XD Suspend MicroEMACS into the background (UNIX BSD4.2 only) X^X^C Exit MicroEMACS XM-Z Write out all changed buffers and then Exit MicroEMACS X X----------------------------------------------------------------------- X (15) SPECIAL KEYS AND KEY BINDINGS X X^G Cancel current command and return to top level of processing. X^U or Universal repeat. May be followed by an integer (default = 4) XM- and repeats the next command that many times. XM-X Execute a named (and possibly unbound) command XM-K Bind a key to a named command XDescribe-Bindings X List the current key bindings in a buffer *-*-END-of-emacs.hlp-*-* echo x - emacs.key sed 's/^X//' >emacs.key <<'*-*-END-of-emacs.key-*-*' X Default Key Bindings for MicroEmacs 3.6 X ======================================= X X ^A Move to start of line X ^B Move backward by characters ESC B Backup by words X ^C Insert space ESC C Initial capitalize word X ^D Forward delete ESC D Delete forward word X ^E Goto end of line X ^F Move forward by characters ESC F Advance by words X ^G Abort out of things ESC G Go to a line X ^H Backward delete X ^I Insert tab X ^J Insert CR-LF, then indent X ^K Kill forward ESC K Bind Key to function X ^L Refresh the screen ESC L Lower case word X ^M Insert CR-LF ESC M Set global mode X ^N Move forward by lines ESC N Goto End paragraph X ^O Open up a blank line X ^P Move backward by lines ESC P Goto Begining of paragraph X ^Q Insert literal ESC Q Fill current paragraph X ^R Search backwards ESC R Search and replace X ^S Search forward ESC S Suspend editor (BSD4.2 only) X ^T Transpose characters X ESC U Upper case word X ^V Move forward by pages ESC V Move backward by pages X ^W Kill region ESC W Copy region to kill buffer X ^Y Yank back from killbuffer ESC X Execute named command X ^Z Move backward by pages ESC Z Save file and exit X X ESC ^H Delete backward word ESC ! Reposition window X ESC ^K Unbind Key from function ESC < Move to start of buffer X ESC ^L Reposition window ESC > Move to end of buffer X ESC ^M Delete global mode ESC . Set mark X ESC ^N Rename current buffer ESC space Set mark X ESC ^R Search & replace w/query ESC rubout Delete backward word X ESC ^V Scroll next window down rubout Backward delete X ESC ^W Delete Paragraph X ESC ^Z Scroll next window up X X ^X ? Describe a key ^X ! Run 1 command in a subjob X ^X = Show the cursor position ^X ( Begin macro X ^X ^ Enlarge display window ^X ) End macro X ^X 1 Make current window only one X ^X 2 Split current window X X ^X ^B Display buffer list ^X B Switch a window to a buffer X ^X ^C Exit MicroEMACS ^X C Start a new command processer X ^X D Suspend MicroEMACS (BSD4.2 only) X ^X E Execute macro X ^X ^F Find file names ^X F Set fill column X ^X ^I Insert file X ^X K Make a buffer go away X ^X ^L Lower case region X ^X ^M Delete Mode ^X M Set a mode X ^X ^N Move window down ^X N Rename current filename X ^X ^O Delete blank lines ^X O Move to the next window X ^X ^P Move window up ^X P Move to the previous window X ^X ^R Get a file from disk X ^X ^S Save current file ^X S Save current file X ^X ^U Upper case region X ^X ^V View file X ^X ^W Write a file to disk ^X X Use next buffer X ^X ^X Swap "." and mark X ^X ^Z Shrink window ^X Z Enlarge display window X XOnly under PCDOS: X -S Hunt forward X -R Hunt backward X XUnbound commands: X================= Xdescribe-bindings pull the list of current bindings into a window Xexecute-buffer execute a buffer od command lines Xexecute-command-line execute a command line (n ) Xexecute-file execute a file of command lines Xexecute-named-command execute a command by name (w/command completion) Xhunt-forward find next occurance of search string Xhunt-backward find last occurance of search string X XUsable Modes X============ XWRAP Lines going past right margin "wrap" to a new line XVIEW Read-Only mode where no modifications are allowed XCMODE Change behavior of some commands to work with C better XEXACT Exact case matching on search strings XOVER Overwrite typed characters instead of inserting them *-*-END-of-emacs.key-*-* echo x - emacs.rc sed 's/^X//' >emacs.rc <<'*-*-END-of-emacs.rc-*-*' X; EMACS.RC: Startup file for MicroEMACS 3.4 X; X; This file is executed everytime the X; editor is entered X X; ***** Rebind the Function key group X Xbind-to-key execute-named-command FN; Xbind-to-key execute-file FN< Xbind-to-key hunt-forward FN= Xbind-to-key hunt-backward FN> Xbind-to-key next-window FN? Xbind-to-key execute-macro FN@ Xbind-to-key find-file FNA Xbind-to-key view-file FNB Xbind-to-key save-file FNC Xbind-to-key exit-emacs FND *-*-END-of-emacs.rc-*-* exit