1@style(spacing 1 lines, margins .7 inches, indent 8 chars, font Times10) 2@Define(goodstuff, fill n, font Helvetica10) 3@Define(col3, columns 3, fill n) 4@Form(ir() = "@b(@eval)@index(@eval)") 5@style(indent 8 chars, spacing 1 lines, BindingMargin .5 inches) 6@pagefooting() 7 8 9 10 11 12 13 14 15 16 17 18 19 @b1(@b[MicroEMACS]) 20 21 Full Screen Text Editor 22 Reference Manual @i(- Release Version) 23 24 Version 4.0 25 March 20, 1996 26 27 (C)Copyright 1988 - 1996 by Daniel M. Lawrence 28 Reference Manual (C)opyright 1988 - 1996 29 by Brian Straight and Daniel M. Lawrence 30 All Rights Reserved 31 32 @i[(C)Copyright 1988 - 1996 by Daniel M. Lawrence 33 MicroEMACS 4.0 can be copied and distributed freely for any 34 non-commercial purposes. Commercial users may use MicroEMACS 35 4.0 inhouse. Shareware distributors may redistribute 36 MicroEMACS 4.0 for media costs only. MicroEMACS 4.0 can only 37 be incorporated into commercial software or resold with the 38 permission of the current author.] 39@newpage 40@flushleft(@b1[Introduction]) 41 42 MicroEMACS is a tool for creating and changing documents, 43programs, and other text files. It is both relatively easy for the 44novice to use, but also very powerful in the hands of an expert. 45MicroEMACS can be extensively customized for the needs of the individual 46user. 47 48 MicroEMACS allows several files to be edited at the same time. 49The screen can be split into different windows and screens, and text may 50be moved freely from one window on any screen to the next. Depending on 51the type of file being edited, MicroEMACS can change how it behaves to 52make editing simple. Editing standard text files, program files and 53word processing documents are all possible at the same time. 54 55 There are extensive capabilities to make word processing and 56editing easier. These include commands for string searching and 57replacing, paragraph reformatting and deleting, automatic word wrapping, 58word move and deletes, easy case controlling, and automatic word counts. 59 60 For complex and repetitive editing tasks editing macroes can be 61written. These macroes allow the user a great degree of flexibility in 62determining how MicroEMACS behaves. Also, any and all the commands can 63be used by any keystroke by changing, or rebinding, what commands 64various keys invoke. A full multilevel Undo facility allows the user to 65recover from most editing errors with little effort. 66 67 Special features are also available to perform a diverse set of 68operations such as file encryption, automatic backup file generation, 69entabbing and detabbing lines, executing operating system commands and 70filtering of text through other programs (like SORT to allow sorting 71text). 72 73@flushleft(@big[History]) 74 75 EMACS was originally a text editor written by Richard Stallman 76at MIT in the early 1970s for Digital Equipment computers. Various 77versions, rewrites and clones have made an appearance since. 78 79 This version of MicroEMACS is derived from code written by Dave 80G. Conroy in 1985. Later modifications were performed by Steve Wilhite 81and George Jones. In December of 1985 Daniel Lawrence picked up the then 82current source (version 2.0) and made extensive modifications and 83additions to it over the course of the next eleven years. Updates and 84support for the current version are still available. Commercial support 85and usage and resale licences are also available. The current program 86author can be contacted by writing to: 87 88@begin(verbatim) 89 USMAIL: Daniel Lawrence 90 617 New York St 91 Lafayette, IN 47901 92 93 Internet: dan@@aquest.com 94 95 Support is provided through: 96 97 The Programmer's Room 98 14,400 Baud 99 Account: uemacs 100 Password: support 101 (317) 742-5533 no parity 8 databits no stop bits 102@end(verbatim) 103@newpage 104@flushleft(@b1[Credits]) 105 106 Many people have been involved in creating this software and we 107wish to credit some of them here. Dave Conroy, of course, wrote the very 108first version of MicroEMACS, and it is a credit to his clean coding that 109so much work was able to be done to expand it. John Gamble is 110responsible for writing the MAGIC mode search routines, and for 111maintaining all the search code. Jeff Lomicka wrote the appendix on DEC 112VMS and has supplied a lot of code to support VMS and the ATARI 1040ST 113versions. Curtis Smith wrote the original VMS code, helped supporting 114the Commodore AMIGA and did much development on various UNIX versions. 115Also Lance Jones has done a lot of work on the AMIGA code. Professor 116Suresh Konda at Carnegie Mellon University has put a lot of effort into 117writing complex macroes and finding all the bugs in the macro language 118before anyone else does. 119 120 A special thanks to Dana Hoggatt who has provided an almost 121daily sounding board for ideas, algorythms and code. He is responsible 122for the encryption code directly and has prodded me into adding many 123features with simple but poignant questions (Dan? How do we move the 124upper left corner of the screen? . . . which forced me to write the text 125windowing system). 126 127 Pierre Perrot dealt with my restrictive path to a generalized 128windowing version, and produced an excellent version for MicroSoft 129Windows. He continues to assist with this environment, forcing me to 130keep pace with him, making all the version more interesting. 131 132 As to people sending source code and text translations over 133computer networks like USENET and ARPA net, there are simply more than 134can be listed here. [The comments in the edit history in the history.c 135file mention each and the piece they contributed]. All these people 136should be thanked for the hard work they have put into MicroEMACS. 137 138 And after all this is the patients of the people waiting for my 139all too infrequent releases. A lot of work goes into each release, and 140as it is not my primary vocation, often much time passes between 141releases. We are committed to continue to improve and strenghten 142MicroEMACS with each new release into the indefinite future. 143 144@closing(Daniel M. Lawrence) 145@newpage 146@string(ChapterTitle="") 147@set(page = 0) 148@pageheading(odd, left "@title[Chapter]", right "MicroEMACS Reference Manual") 149@pageheading(even, left "MicroEMACS Reference Manual", right "@title[Chapter]") 150@pagefooting(odd, left="@value(page)") 151@pagefooting(even, right="@value(page)") 152@chapter(Installation) 153 MicroEMACS is a programmer's text editor which is very 154powerfull, customizable, and exists for a large number of different 155types of computer systems. It is particularly usefull for people who 156work on a lot of different computers and want to have a familiar and 157powerful editor which works identically no matter what computer they are 158using. But before using MicroEMACS, you must INSTALL it on your computer 159system. Since each computer is different, there is usually a different 160way to install MicroEMACS for each type of computer. 161 162@section(MSDOS, Windows 95, Windows NT, OS/2 - IBM-PCs) 163 MicroEMACS is packaged for IBM-PC compatable machines as an 164installable package which will configure to the target machine. 165Instillation is very simple. Insert the distribution floppy in the 166target machine's A: drive. Then type, from the command prompt: 167 168 a:install 169 170 The install program will lead you through the intallation 171process, step by step, installing the appropriate versions on your 172computer's hard drive. 173 174 Under @ir(Windows 95) or @ir(Windows NT), bring up the file 175manager, select the A: drive, and double click on the icon forthe 176install program. 177 178@section(UNIX) 179 There are more available varieties of UNIX than any other 180currently popular operating system. MicroEMACS is provided in source to 181attempt to allow the compilation of a version appropriate to any UNIX 182system. This usually consists of a TAR or .zip file containing the tree 183of directories needed to build any version of MicroEMACS. Follow these 184steps to build an executable: 185 186@begin(enumerate) 187Copy the distribution file to an appropriate empty directory on the 188target system. 189 190Unpack the distribution file, using tar or unzip or whatever 191appropriate unpacking program. 192 193Change directory to the directory most closely approximating the 194target system's version of unix. These include: 195 196@begin(verbatim) 197 AIX IBM's propriatary UNIX varient 198 BSD University of Berkeley's popular BSD varients 199 DGUX Data General UNIX 200 FREEBSD FreeBSD running on an IBM-PC 201 HPUX Hewlett Packard's UNIX 202 SUN Sun Microsystem's UNIX 203 XENIX Microsoft UNIX 204@end(verbatim) 205 206Copy ../h/estruct.h to the current directory. 207 208Edit estruct.h to turn on the proper Operating system, Compiler and 209option switches by changing the value of their #defines from 0 to 1. 210 211Issue a "make" command to build the executable. 212 213Change to the BIN subdirectory. 214 215copy the resulting executable, and the files of the CMD subdirectory 216from the root of the package into an appropriate directory on the UNIX 217system which will be in the user's path. 218 219Rename the emacs.rc startup file to .emacsrc. 220 221Make sure the copied executables have the proper permissions to allow 222them to be executed and read by the target users. 223@end(enumerate) 224 225 At this point, MicroEMACS should be ready for use. Remember to 226issue a REHASH command if you want to invoke it before logging out of 227the system immediately after building it. 228 229@chapter(Basic Concepts) 230 231 The current version of MicroEMACS is 4.0 (Fourth major re-write, 232initial public release), and for the rest of this document, we shall 233simply refer to this version as "EMACS". Any modifications for later 234versions will be in the file README on the MicroEMACS distribution disk. 235 236@section(Keys and the Keyboard) 237 238 Many times throughout this manual we will be talking about 239@index(special keys) commands and the keys on the keyboard needed to use 240them. There are a number of "special" keys which can be used and are 241listed here: 242 243@begin(description) 244<NL>@\NewLine which is also called RETURN, ENTER, or <NL>, this key is 245used to @index(newline) end different commands. 246 247^@\The control key can be used before any alphabetic character and some 248symbols. For example, ^C means to hold down the <CONTROL> key and type 249@index(control key) the C key at the same time. 250 251^X@\The CONTROL-X key is used at the beginning of many different 252@index(control-x) commands. 253 254META or M-@\This is a special EMACS key used to begin many commands. 255@index(meta key)This key is pressed and then released before 256typing the next character. On most systems, this is the <ESC> key, but 257it can be changed. (consult appendix E to learn what key is used for 258META on your computer). 259@end(description) 260 261Whenever a command is described, the manual will list the actual 262keystrokes needed to execute it in @b(boldface) using the above 263conventions, and also the name of the command in @i(italics). 264@section(Getting Started) 265 266 In order to use EMACS, you must call it up from your system or 267computer's command prompt. On UNIX and MSDOS machines, just type "emacs" 268from the command prompt and follow it with the <RETURN> or <ENTER> key 269(we will refer to this key as <NL> for "new-line" for the remainder of 270this manual). On the Macintosh, the Amiga, the ATARI ST, and under OS/2, 271Windows 95, Windows NT and other icon based operating systems, double 272click on the uEMACS icon. Shortly after this, a screen similar to the 273one below should appear. 274 275@section(Parts and Pieces) 276 277 The screen is divided into a number of areas or @b<windows>. On 278some systems the top window contains a function list of unshifted and 279@index(windows) shifted function keys. We will discuss these keys later. 280@index(mode line) Below them is an EMACS @b<mode line> which, as we will 281see, informs you of the present mode of operation of the editor--for 282example "(WRAP)" if you set EMACS to wrap at the end of each line. 283@index(text window) Under the mode line is the @b<text window> where text 284appears and is manipulated. Since each window has its own mode line, 285below the text window is it's mode line. The last line of the screen is 286the @b(command line) where EMACS takes commands and reports on what it 287is doing. 288@newpage 289@begin(verbatim) 290=============================================================================== 291f1 search-> f2 <-search | MicroEMACS: Text Editor 292f3 hunt-> f4 <-hunt | 293f5 fkeys f6 help | Available function key Pages include: 294f7 nxt wind f8 pg[ ] | WORD BOX EMACS PASCAL C cObal Lisp 295f9 save f10 exit | [use the f8 key to load Pages] 296=============================================================================== 297 MicroEMACS 4.0 () Function Keys 298=============================================================================== 299 300 301 302 303 304 305 306 307 308 309 310=============================================================================== 311---- MicroEMACS 4.0 [13:28] L:1 C:0 () -- Main -------------------------------- 312=============================================================================== 313 Fig 1: EMACS screen on an IBM-PC 314@end(verbatim) 315 316@section(Entering Text) 317 318Entering text in EMACS is simple. Type the following sentence fragment: 319 320@example<Fang Rock lighthouse, center of a series of mysterious and> 321 322@flushleft(The text is displayed at the top of the text window. Now type:) 323 324@example<terrifying events at the turn of the century> 325 326Notice that some of your text has dissapeared off the left side of the 327screen. Don't panic--your text is safe!!! You've just discovered that 328EMACS doesn't "wrap" text to the next line like most word processors 329unless you hit <NL>. But since EMACS is used for both word processing, 330and text editing, it has a bit of a dual personality. You can change 331@index(modes) the way it works by setting various @b(modes). In this 332case, you need to set @b(WRAP) mode, using the @i(add-mode) 333@index(add-mode) command, by typing @b(^XM). The command line at the 334base of the screen will prompt you for the mode you wish to add. Type 335@b<wrap> followed by the <NL> key and any text you now enter will be 336wrapped. However, the command doesn't wrap text already entered. To 337get rid of the long line, press and hold down the <BACKSPACE> key until 338the line is gone. Now type in the words you deleted, watch how EMACS 339goes down to the next line at the right time. @i{(In some versions of 340EMACS, @b<WRAP> is a default mode in which case you don't have to worry 341about the instructions relating to adding this mode.)} 342 343Now let's type a longer insert. Hit <NL> a couple of times to tab 344down from the text you just entered. Now type the following paragraphs. 345Press <NL> twice to indicate a paragraph break. 346 347@example<Fang Rock lighthouse, center of a series of mysterious 348and terrifying events at the turn of the century, is 349built on a rocky island a few miles of the Channel 350coast. So small is the island that wherever you stand 351its rocks are wet with sea spray. 352 353The lighthouse tower is in the center of the island. A 354steep flight of steps leads to the heavy door in its 355base. Winding stairs lead up to the crew room.> 356 357@section<Basic cursor movement> 358 359Now let's practice moving around in this text. To move the cursor back 360to the word "Winding," enter @b<M-B> @i(previous-word) 361@index(previous-word). This command moves the cursor backwards by one 362word at a time. Note you have to press the key combination every time 363the cursor steps back by one word. Continuously pressing META and 364toggling B produces an error message. To move forward to the word 365"stairs" enter @b<M-F> @i(next-word)@index(next-word), which moves the 366cursor forward by one word at a time. 367 368Notice that EMACS commands are usually mnemonic--F for forward, B for 369backward, for example. 370 371To move the cursor up one line, enter @b<^P> @i(previous-line) 372@index(previous-line), down one line @b<^N> @i(next-line) 373@index(next-line). Practice this movement by moving the cursor to the 374word "terrifying" in the second line. 375 376The cursor may also be moved forward or backward in smaller increments. 377To move forward by one character, enter @b<^F> @i(forward-character) 378@index(forward-character), to move backward, @b<^B> 379@i(backward-character) @index(backward-character). EMACS also allows 380you to specify a number which is normally used to tell a command to 381execute many times. To repeat most commands, press META and then the 382number before you enter the command. Thus, the command META 5 ^F 383(@b<M-5^F>) will move the cursor forward by five characters. Try moving 384around in the text by using these commands. For extra practice, see how 385close you can come to the word "small" in the first paragraph by giving 386an argument to the commands listed here. 387 388Two other simple cursor commands that are useful to help us move around 389in the text are @b<M-N> @i(next-paragraph) @index(next-paragraph) which 390moves the cursor to the second paragraph, and @b<M-P> 391@i(previous-paragraph) @index(previous-paragraph) which moves it back 392to the previous paragraph. The cursor may also be moved rapidly from 393one end of the line to the other. Move the cursor to the word "few" in 394the second line. Press @b<^A> @i(beginning-of-line) 395@index(beginning-of-line). Notice the cursor moves to the word 396"events" at the beginning of the line. Pressing @b<^E> @i(end-of-line) 397@index(end-of-line) moves the cursor to the end of the line. 398 399Finally, the cursor may be moved from any point in the file to the end 400or beginning of the file. Entering @b{M->} @i(end-of-file) 401@index(end-of-file) moves the cursor to the end of the buffer, @b{M-<} 402@i(beginning-of-file) @index(beginning-of-file) to the first character 403of the file. 404 405@i(On the IBM-PC, the ATARI ST and many other machines, the cursor keys 406@index(cursor keys) can also be used to move the cursor.) 407 408Practice moving the cursor in the text until you are comfortable with 409the commands we've explored in this chapter. 410 411@section(Saving your text) 412 413When you've finished practicing cursor movement, save your file. Your 414@index(buffer) file currently resides in a @b<BUFFER>. The buffer is a 415temporary storage area for your text, and is lost when the computer is 416turned off. You can save the buffer to a file by entering @b<^X^S> 417@i(save-file) @index(save-file). Notice that EMACS informs you that 418your file has no name and will not let you save it. 419 420@i(On the IBM-PC and other machines with function keys, the F9 key can 421often be used do the same as ^X^S). 422 423To save your buffer to a file with a different name than it's current 424one (which is empty), press @b<^X^W> @i(write-file) @index(write-file). 425EMACS will prompt you for the filename you wish to write. Enter the 426name @b<fang.txt> and press return. On a micro, the drive light will 427come on, and EMACS will inform you it is writing the file. When it 428finishes, it will inform you of the number of lines it has written to 429the disk. 430 431Congratulations!! You've just saved your first EMACS file! 432@newpage 433@heading(Chapter @value(chapter) Summary) 434 435 In chapter @value(chapter), you learned how to enter text, how 436to use wrap mode, how to move the cursor, and to save a buffer. The 437following is a table of the commands covered in this chapter and their 438corresponding key bindings: 439 440@begin{verbatim} 441@u(Key Binding Keystroke Effect) 442 443abort-command @b<^G> aborts current command 444 445add-mode @b<^XM> allows addition of EMACS 446 mode such as @b(WRAP) 447 448backward-character @b<^B> moves cursor left one character 449 450beginning-of-file @b{M-<} moves cursor to beginning of file 451 452beginning-of-line @b<^A> moves cursor to beginning of line 453 454end-of-file @b{M->} moves cursor to end of file 455 456end-of-line @b<^E> moves cursor to end of line 457 458forward-character @b<^F> moves cursor right one character 459 460next-line @b<^N> moves cursor to next line 461 462next-paragraph @b<M-N> moves cursor to next paragraph 463 464next-word @b<M-F> moves cursor forward one word 465 466previous-line @b<^P> moves cursor backward by one line 467 468previous-paragraph @b<M-P> moves cursor to previous paragraph 469 470previous-word @b<M-B> moves cursor backward by one word 471 472save-file @b<^X^S> saves current buffer to a file 473 474write-file @b<^X^W> save current buffer under a new name 475@end(verbatim) 476@newpage 477@chapter(Basic Editing--Simple Insertions and Deletions) 478 479@section<A Word About Windows, Buffers, Screens, and Modes> 480 481In the first chapter, you learned how to create and save a file in 482EMACS. Let's do some more editing on this file. Call up emacs by 483typing in the following command. 484 485@b<emacs fang.txt> 486 487@i(On icon oriented systems, double click on the uEMACS icon, usually a 488file dialog box of some sort will appear. Choose @b(FANG.TXT) from the 489appropriate folder.) 490 491Shortly after you invoke EMACS, the text should appear on the screen 492ready for you to edit. The text you are looking at currently resides in 493a @b<buffer>. A buffer is a temporary area of computer memory which is 494@index(buffer) the primary unit internal to EMACS -- this is the place 495where EMACS goes to work. The mode line at the bottom of the screen 496lists the buffer name, @b<FANG.TXT> and the name of the file with which 497this buffer is associated, @b<FANG.TXT> 498 499The computer talks to you through the use of its @b(screen). This 500@index(screen) screen usually has an area of 24 lines each of 80 501characters across. You can use EMACS to subdivide the screen into 502several separate work areas, or @b(windows), each of which can be 503@index(window) 'looking into' different files or sections of text. Using 504windows, you can work on several related texts at one time, copying and 505moving blocks of text between windows with ease. To keep track of what 506you are editing, each window is identified by a @b(mode line) on the 507@index(mode line) @index(buffer) last line of the window which lists the 508name of the @b(buffer) which it is looking into, the file from which the 509text was read, and how the text is being edited. 510 511An EMACS @b<mode> tells EMACS how to deal with user input. As we have 512already seen, the mode 'WRAP' controls how EMACS deals with long lines 513(lines with over 79 characters) while the user is typing them in. The 514'VIEW' mode, allows you to read a file without modifying it. Modes are 515associated with buffers and not with files; hence, a mode needs to be 516explicitly set or removed every time you edit a file. A new file read 517into a buffer with a previously specified mode will be edited under this 518mode. If you use specific modes frequently, EMACS allows you to set 519the modes which are used by all new buffers, called @b<global> modes. 520 521@section<Insertions> 522 523Your previously-saved text should look like this: 524 525@example<Fang Rock lighthouse, center of a series of mysterious 526and terrifying events at the turn of the century, is 527built on a rocky island a few miles of the Channel 528coast. So small is the island that wherever you stand 529its rocks are wet with sea spray. 530 531The lighthouse tower is in the center of the island. A 532steep flight of steps leads to the heavy door in its 533base. Winding stairs lead up to the crew room.> 534 535Let's assume you want to add a sentence in the second paragraph after 536the word "base." Move the cursor until it is on the "W" of "Winding". 537Now type the following: 538 539@example<This gives entry to the lower floor where the big steam 540generator throbs steadily away, providing power for the 541electric lantern.> 542 543If the line fails to wrap and you end up with a '$' sign in the right 544margin, just enter @b{M-Q} @i(fill-paragraph) @index(fill-paragraph) to 545reformat the paragraph. This new command attempts to fill out a 546paragraph. Long lines are divided up, and words are shuffled around to 547make the paragraph look nicer. 548 549Notice that all visible EMACS characters are self-inserting -- all you 550had to do was type the characters to insert and the existing text made 551space for it. With a few exceptions discussed later, all non-printing 552characters (such as control or escape sequences) are commands. To 553insert spaces, simply use the space bar. Now move to the first line of 554the file and type @b{^O} @i(open-line) @index(open-line) (Oh, not zero). 555You've just learned how to insert a blank line in your text. 556 557@section<Deletions> 558 559EMACS offers a number of deletion options. For example, move the cursor 560until it's under the period at the end of the insertion you just did. 561Press the backspace key. Notice the "n" on "lantern" disappeared. The 562backspace implemented on EMACS is called a @b<destructive> backspace--it 563removes text immediately before the current cursor position from the 564buffer. Now type @b<^H> @i(delete-previous-character) 565@index(delete-previous-character). Notice that the cursor moves back 566and obliterates the "r"--either command will backspace the cursor. 567 568Type in the two letters you erased to restore your text and move the 569cursor to the beginning of the buffer @b{M->} @i(beginning-of-file) 570@index(beginning-of-file). Move the cursor down one line to the 571beginning of the first paragraph. 572 573To delete the forward character, type @b{^D} @i(delete-next-character) 574@index(delete-next-character). The "F" of "Fang" disappears. Continue 575to type @b{^D} until the whole word is erased EMACS also permits the 576deletion of larger elements of text. Move the cursor to the word 577"center" in the first line of text. Pressing @b{M-<backspace>} 578@i(delete-previous-word) @index(delete-previous-word) kills the word 579immediately before the cursor. @b{M-^H} has the same effect. 580 581Notice that the commands are very similar to the control commands you 582used to delete individual letters. As a general rule in EMACS, control 583sequences affect small areas of text, META sequences larger areas. The 584word forward of the cursor position can therefore be deleted by typing 585@b{M-D} @i(delete-next-word) @index(delete-next-word). Now let's take 586out the remainder of the first line by typing @b{^K} 587@i(kill-to-end-of-line) @index(kill-to-end-of-line). You now have a 588blank line at the top of your screen. Typing @b{^K} again or @b{^X^O} 589@i(delete-blank-lines) @index(delete-blank-lines) deletes the blank line 590and flushes the second line to the top of the text. Now exit EMACS by 591typing @b{^X^C} @i(exit-emacs) @index(exit-emacs). Notice EMACS 592reminds you that you have not saved your buffer. Ignore the warning and 593exit. This way you can exit EMACS without saving any of the changes you 594just made. 595@newpage 596@heading(Chapter @value(chapter) Summary) 597 598In Chapter @value(chapter), you learned about the basic 'building 599blocks' of an EMACS text file--buffers, windows, and files. 600 601@begin{verbatim} 602@u(Key binding Keystroke Effect) 603delete-previous-character 604 @b{^H} deletes character immediately before 605 the current cursor position 606 607delete-next-character @b{^D} deletes character immediately after 608 current cursor position 609 610delete-previous-word @b{M-^H} deletes word immediately before 611 current cursor position 612 613delete-next-word @b{M-D} deletes word immediately after 614 current cursor position 615 616kill-to-end-of-line @b<^K> deletes from current cursor 617 position to end of line 618 619insert-space @b<^C> inserts a space to right of cursor 620 621open-line @b{^O} inserts blank line 622 623delete-blank-lines @b{^X^O} removes blank line 624 625exit-emacs @b{^X^C} exits emacs 626@end(verbatim) 627@chapter(Using Regions) 628 629@section(Defining and Deleting a Region) 630 631At this point its time to familiarize ourselves with two more EMACS 632terms--the @b<point> and the @b<mark>. The point is located directly 633@index(point) @index(mark) behind the current cursor position. The mark 634(as we shall see shortly) is user defined. These two elements together 635are called the current @b(region) and limit the @b<region> of text on 636which EMACS performs many of its editing functions. 637 638Let's begin by entering some new text. Don't forget to add @b(wrap) 639mode if its not set on this buffer. Start EMACS and open a file called 640@b{PUBLISH.TXT}. Type in the following text: 641 642@example{One of the largest growth areas in personal computing is 643electronic publishing. There are packages available for 644practically every machine from elegantly simple programs 645for the humble Commodore 64 to sophisticated 646professional packages for PC and Macintosh computers. 647 648Electronic publishing is as revolutionary in its way as 649the Gutenburg press. Whereas the printing press allowed 650the mass production and distribution of the written 651word, electronic publishing puts the means of production 652in the hands of nearly every individual. From the class 653magazine to the corporate report, electronic publishing 654is changing the way we produce and disseminate 655information. 656 657Personal publishing greatly increases the utility of 658practically every computer. Thousands of people who 659joined the computer revolution of this decade only to 660hide their machines unused in closets have discovered a 661new use for them as dedicated publishing workstations.} 662 663Now let's do some editing. The last paragraph seems a little out of 664place. To see what the document looks like without it we can cut it 665from the text by moving the cursor to the beginning of the paragraph. 666Enter @b(M-<space>) @i(set-mark) @index(set-mark). EMACS will respond 667with "[Mark set]". Now move the cursor to the end of the paragraph. 668You have just defined a region of text. To remove this text from the 669screen, type @b<^W> @i(kill-region) @index(kill-region). The paragraph 670disappears from the screen. 671 672On further consideration, however, perhaps the paragraph we cut wasn't 673so bad after all. The problem may have been one of placement. If we 674could tack it on to the end of the first paragraph it might work quite 675well to support and strengthen the argument. Move the cursor to the end 676of the first paragraph and enter @b<^Y> @i(yank) @index(yank). Your 677text should now look like this: 678 679@example{One of the largest growth areas in personal computing is 680electronic publishing. There are packages available for 681practically every machine from elegantly simple programs 682for the humble Commodore 64 to sophisticated 683professional packages for PC and Macintosh computers. 684Personal publishing greatly increases the utility of 685practically every computer. Thousands of people who 686joined the computer revolution of this decade only to 687hide their machines unused in closets have discovered a 688new use for them as dedicated publishing workstations. 689 690Electronic publishing is as revolutionary in its way as 691the Gutenburg press. Whereas the printing press allowed 692the mass production and distribution of the written 693word, electronic publishing puts the means of production 694in the hands of nearly every individual. From the class 695magazine to the corporate report, electronic publishing 696is changing the way we produce and disseminate 697information.} 698 699@section(Yanking a Region) 700 701The text you cut initially didn't simply just disappear, it was cut into 702a buffer that retains the 'killed' text appropriately called the @b<kill 703buffer>. @b<^Y> "yanks" the text back from this buffer into the current 704buffer. If you have a long line (indicated, remember, by the "$" 705sign), simply hit @b{M-Q} to reformat the paragraph. 706 707There are other uses to which the kill buffer can be put. Using the 708@index(kill buffer) method we've already learned, define the last 709paragraph as a region. Now type @b<M-W> @i(copy-region) 710@index(copy-region). Nothing seems to have happened; the cursor stays 711blinking at the point. But things have changed, even though you may not 712be able to see any alteration. 713 714To see what has happened to the contents of the kill buffer, move the 715cursor down a couple of lines and "yank" the contents of the kill buffer 716back with @b<^Y>. Notice the last paragraph is now repeated. The 717region you defined is "tacked on" to the end of your file because 718@b<M-W> @b<copies> a region to the kill buffer while leaving the 719original text in your working buffer. Some caution is needed however, 720because the contents of the kill buffer are updated when you delete any 721regions, lines or words. If you are moving large quantities of text, 722complete the operation before you do any more deletions or you could 723find that the text you want to move has been replaced by the most recent 724deletion. Remember--a buffer is a temporary area of computer memory 725that is lost when the machine is powered down or switched off. In order 726to make your changes permanent, they must be saved to a file before you 727leave EMACS. Let's delete the section of text we just added and save 728the file to disk. 729@newpage 730@heading(Chapter @value(chapter) Summary) 731 732In Chapter @value(chapter), you learned how to achieve longer insertions 733and deletions. The EMACS terms @b<point> and @b<mark> were introduced 734and you learned how to manipulate text with the kill buffer. 735 736@begin{verbatim} 737@begin(group) 738@u(Key Binding Keystroke Effect) 739 740set-mark @b{M-<space>} Marks the beginning of a region 741 742delete-region @b{^W} Deletes region between point and mark and 743 places it in KILL buffer 744 745copy-region @b{M-W} Copies text between point and mark into 746 KILL buffer 747 748yank-text @b{^Y} Inserts a copy of the KILL buffer into 749 current buffer at point 750@end(group) 751@end(verbatim) 752@chapter(Search and Replace) 753 754@section<Forward Search> 755 756Load EMACS and bring in the file you just saved. Your file should look 757like the one below. 758 759@example{One of the largest growth areas in personal computing is 760electronic publishing. There are packages available for 761practically every machine from elegantly simple programs 762for the humble Commodore 64 to sophisticated 763professional packages for PC and Macintosh computers. 764Personal publishing greatly increases the utility of 765practically every computer. Thousands of people who 766joined the computer revolution of this decade only to 767hide their machines unused in closets have discovered a 768new use for them as dedicated publishing workstations. 769 770Electronic publishing is as revolutionary in its way as 771the Gutenburg press. Whereas the printing press allowed 772the mass production and distribution of the written 773word, electronic publishing puts the means of production 774in the hands of nearly every individual. From the class 775magazine to the corporate report, electronic publishing 776is changing the way we produce and disseminate 777information.} 778 779Let's use EMACS to search for the word "revolutionary" in the second 780paragraph. Because EMACS searches from the current cursor position 781toward the end of buffers, and we intend to search forward, move the 782cursor to the beginning of the text. Enter @b<^S> @i(search-forward) 783@index(search-forward). Note that the command line now reads 784 785"Search [] <META>:" 786 787EMACS is prompting you to enter the @b<search string> -- the text you 788want to find. Enter the word @b<revolutionary> and hit the @b<META> 789key. The cursor moves to the end of the word "revolutionary." 790 791Notice that you must enter the <META> key to start the search. If you 792@index(<NL>) simply press <NL> the command line responds with "<NL>". 793Although this may seem infuriating to users who are used to pressing the 794return key to execute any command, EMACS' use of <META> to begin 795searches allows it to pinpoint text with great accuracy. After every 796line wrap or carriage return, EMACS 'sees' a new line character (<NL>). 797If you need to search for a word at the end of a line, you can specify 798this word uniquely in EMACS. 799 800In our sample text for example, the word "and" occurs a number of times, 801but only once at the end of a line. To search for this particular 802occurrence of the word, move the cursor to the beginning of the buffer 803and type @b(^S). Notice that EMACS stores the last specified 804@index(default string) search string as the @b<default> string. If you 805press @b{<META>} now, EMACS will search for the default string, in this 806case, "revolutionary." 807 808To change this string so we can search for our specified "and" simply 809enter the word @b{and} followed by @b{<NL>}. The command 810line now shows: 811 812"search [and<NL>]<META>:" 813 814Press @b{<META>} and the cursor moves to "and" at the end of the second 815last line. 816 817@section<Exact Searches> 818 819Most of the time EMACS does not take the case of the strings being 820searched for into account. Thus @b(And) matches @b(AND) and @b(and). 821However, if the mode EXACT is active in the current buffer, EMACS will 822only look for matches with the same upper and lower case for each 823character. Thus, for example you could search for @b{Publishing} as 824distinct from @b{publishing}. 825 826@section<Backward Search> 827 828Backward searching is very similar to forward searching except that it 829is implemented in the reverse direction. To implement a reverse search, 830type @b{^R} @i(search-reverse) @index(search-reverse). Because EMACS 831makes no distinction between forward and backward stored search strings, 832the last search item you entered appears as the default string. Try 833searching back for any word that lies between the cursor and the 834beginning of the buffer. Notice that when the item is found, the point 835moves to the beginning of the found string (i.e., the cursor appears 836under the first letter of the search item). 837 838Practice searching for other words in your text. 839 840@section<Searching and Replacing> 841 842Searching and replacing is a powerful and quick way of making changes to 843your text. Our sample text is about electronic publishing, but the 844correct term is 'desktop' publishing. To make the necessary changes we 845need to replace all occurrences of the word "electronic" with "desktop." 846First, move the cursor to the top of the current buffer with the @b(M-<) 847command. Then type @b[M-R] @i(replace-string) @index(replace-string). 848The command line responds: 849 850"Replace []<META>:" 851 852where the square brackets enclose the default string. Type the word 853@b<electronic> and hit @b{<META>}. The command line responds: 854 855"with []<META>" 856 857type @b{desktop<META>}. EMACS replaces all instances of the original 858word with your revision. Of course, you will have to capitalize the 859first letter of "desktop" where it occurs at the beginning of a 860sentence. 861 862You have just completed an @b<unconditional replace>. In this 863operation, EMACS replaces every instance of the found string with the 864replacement string. 865 866@section<Query-Replace> 867 868You may also replace text on a case by case basis. The @b{M-^R} 869@i(query-replace-string) @index(query-replace-string) command causes 870EMACS to pause at each instance of the found string. 871 872For example, assume we want to replace some instances of the word 873"desktop" with the word "personal." Go back to the beginning of the 874current buffer and enter the @b(M-^R) @i(query-replace) 875@index(query-replace) command. The procedure is very similar to that 876which you followed in the unconditional search/replace option. When the 877search begins however, you will notice that EMACS pauses at each 878instance of "publishing" and asks whether you wish to replace it with 879the replacement string. You have a number of options available for 880response: 881 882@begin(verbatim) 883@u( Response Effect) 884 Y(es) Make the current replacement and skip to the next 885 occurrence of the search string 886 887 N(o) Do not make this replacement but continue 888 889 ! Do the rest of the replacements with no more queries 890 891 U(ndo) Undo just the last replacement and query for it 892 again (This can only go back ONE time) 893 894 ^G Abort the replacement command (This action does not 895 undo previously-authorized replacements 896 897 . Same effect as ^G, but cursor returns to the point at 898 which the replacement command was given 899 900 ? This lists help for the query replacement command 901@end(verbatim) 902 903Practice searching and searching and replacing until you feel 904comfortable with the commands and their effects. 905@newpage 906@heading(Chapter @value(chapter) Summary) 907 908In this chapter, you learned how to search for specified strings of text 909in EMACS. The chapter also dealt with searching for and replacing 910elements within a buffer. 911 912@begin(group) 913@begin(verbatim) 914@u(Key Binding Keystroke Effect) 915 916search-forward @b{^S} Searches from point to end of buffer. 917 Point is moved from current location to 918 the end of the found string 919 920search-backward @b{^R} Searches from point to beginning of buffer. 921 Point is moved from current location to 922 beginning of found string 923 924replace @b{M-R} Replace ALL occurrences of search string with 925 specified (null) string from point to the 926 end of the current buffer 927 928query-replace @b{M-^R} As above, but pause at each found string 929 and query for action 930@end(verbatim) 931@end(group) 932@chapter(Windows) 933 934@section<Creating Windows>@index{Windows, Creating} 935 936We have already met windows in an earlier chapter. In this chapter, we 937will explore one of EMACS' more powerful features -- text manipulation 938through multiple windowing. Windows offer you a powerful and easy way 939to edit text. By manipulating a number of windows and buffers on the 940screen simultaneously, you can perform complete edits and revisions on 941the computer screen while having your draft text or original data 942available for reference in another window. 943 944You will recall that windows are areas of buffer text that you can see 945@index(windows) on the screen. Because EMACS can support several screen 946windows simultaneously you can use them to look into different places in 947the same buffer. You can also use them to look at text in different 948buffers. In effect, you can edit several files at the same time. 949 950Let's invoke EMACS and pull back our file on desktop publishing by 951typing 952 953@example<emacs publish.txt> 954 955When the text appears, type the @b{^X2} @i(split-current-window) 956@index{split-current-window} command. The window splits into two 957windows. The window where the cursor resides is called the @b<current> 958window -- in this case the bottom window. Notice that each window has 959a text area and a mode line. The @b(command line) @index{command line} 960is however, common to all windows on the screen. 961 962The two windows on your screen are virtually mirror images of each other 963because the new window is opened into the same buffer as the one you are 964in when you issue the @i{open-window command} @index{open-window}. All 965commands issued to EMACS are executed on the current buffer in the 966current window. 967 968To move the cursor to the upper window (i.e., to make that window the 969current window, type @b{^XP} @i(previous-window) @index{previous-window}. 970Notice the cursor 971moves to the upper or @b<previous> window. Entering @b{^XO} 972@i(next-window) moves to the @b{next} window. Practice moving between 973windows. You will notice that you can also move into the Function Key 974menu by entering these commands. 975 976Now move to the upper window. Let's open a new file. On the EMACS disk 977is a tutorial file. Let's call it into the upper window by typing: 978 979@example<^X^F> 980 981and press return. 982 983Enter the filename @b<emacs.tut>. 984 985In a short time, the tutorial file will appear in the window. We now have 986two windows on the screen, each looking into different buffers. We have 987just used the @b(^X^F) @i(find-file) @index{find-file} 988command to find a file and bring 989it into our current window. 990 991You can scroll any window up and down with the cursor keys, or with the 992commands we've learned so far. However, because the area of visible 993text in each window is relatively small, you can scroll the current 994window a line at a time. 995 996Type @b{^X^N} @i(move-window-down)@index{move-window-down} 997 998The current window scrolls down by one line -- the top line of text 999scrolls out of view, and the bottom line moves towards the top of the 1000screen. You can imagine, if you like, the whole window slowly moving 1001down to the end of the buffer in increments of one line. The command 1002@b{^X^P} @i(move-window-up)@index{move-window-up} 1003scrolls the window in the opposite 1004direction. 1005 1006As we have seen, EMACS editing commands are executed in the current 1007window, but the program does support a useful feature that allows you 1008to scroll the @b<next> window. @b<M-^Z> @i(scroll-next-up) 1009@index{scroll-next-up} scrolls the next window up, @b{M-^V} 1010@i(scroll-next-down)@index{scroll-next-down} scrolls it downward. 1011From the tutorial window, practice scrolling the window with the 1012desktop publishing text in it up and down. 1013 1014When you're finished, exit EMACS without saving any changes in your 1015files. 1016 1017 1018Experiment with splitting the windows on your screen. Open windows 1019into different buffers and experiment with any other files you may 1020have. Try editing the text in each window, but don't forget to save 1021any changes you want to keep -- you still have to save each buffer 1022separately. 1023 1024@section(Deleting Windows)@index{Windows, Deleting} 1025Windows allow you to perform complex editing tasks with ease. However, 1026they become an inconvenience when your screen is cluttered with open 1027windows you have finished using. The simplest solution is to delete 1028unneeded windows. The command @b{^X0} @i{delete-window} 1029will delete the window you are currently working in and move you to the 1030next window. 1031 1032If you have a number of windows open, you can delete all but the current 1033window by entering @b{^X1} @i{delete-other-windows}. 1034 1035@section(Resizing Windows)@index{Windows, Resizing} 1036 1037During complex editing tasks, you will probably find it convenient to 1038have a number of windows on the screen simultaneously. However this 1039situation may present inconveniences because the more windows you have 1040on the screen the smaller they are; in some cases, a window may show 1041only a couple of lines of text. To increase the flexibility and utility 1042of the window environment, EMACS allows you to resize the window you are 1043working in (called, as you will recall, the @b<current> window) to a 1044convenient size for easier editing, and then shrink it when you no 1045longer need it to be so large. 1046 1047Let's try an example. Load in any EMACS text file and split the current 1048window into two. Now type @b{^X^(Shift-6)}, 1049@i{grow-window}@index{grow-window}. Your current window should be 1050the lower one on the screen. Notice that it increases in size upwards 1051by one line. If you are in the upper window, it increases in size in a 1052downward direction. The command @b{^X^Z}, 1053@i{shrink-window}@index{shrink-window} correspondingly decreases window 1054size by one line at a time. 1055 1056EMACS also allows you to resize a window more precisely by entering a 1057numeric argument specifying the size of the window in lines. To resize 1058the window this way, press the META key and enter a numeric argument 1059(remember to keep it smaller than the number of lines on your screen 1060display) then press @b{^XW} @i{resize-window}@index{resize-window}. 1061The current window will be enlarged or shrunk to the number of lines 1062specified in the numeric argument. For example entering: 1063 1064@example{@b[M-8 ^XW]}will resize the current window to 8 lines. 1065 1066@section(Repositioning within a Window) 1067 1068The cursor may be centered within a window by entering @b{M-! or M-^L} 1069@i{redraw-display} @index{redraw-display}. This command is especially 1070useful in allowing you to quickly locate the cursor if you are moving 1071frequently from window to window. You can also use this command to move 1072the line containing the cursor to any position within the current 1073window. This is done by using a numeric argument before the command. 1074Type @b(M-<n> M-^L) where <n> is the number of the line within the 1075window that you wish the current line to be displayed. 1076 1077The @b{^L} @i{clear-and-redraw} @index{clear-and-redraw} command is 1078useful for 'cleaning up' a 'messy' screen that can result of using EMACS 1079on a mainframe system and being interrupted by a system message. 1080@newpage 1081@heading(Chapter @value(chapter) summary) 1082 1083In Chapter @value(chapter) you learned how to manipulate windows and the 1084editing flexibility they offer. 1085 1086@begin(verbatim) 1087@u(Key Binding Keystroke Effect) 1088 1089open-window @b{^X2} Splits current window into two windows if 1090 space available 1091 1092close-windows @b{^X1} Closes all windows except current window 1093 1094next-window @b{^XO}[oh] Moves point into next (i.e. downward) window 1095 1096previous-window @b{^XP} Moves point to previous (i.e. upward) window 1097 1098move-window-down @b{^X^N} Scrolls current window down one line 1099 1100move-window-up @b{^X^P} Scrolls current window up one line 1101 1102redraw-display @b{M !} or Window is moved so line with point 1103 @b{M ^L} (with cursor) is at center of window 1104 1105grow-window @b{M-X ^} Current window is enlarged by one 1106 line and nearest window is shrunk by 1107 one line 1108 1109shrink-window @b{^X^Z} Current window is shrunk by one line 1110 and nearest window is enlarged by one line 1111 1112clear-and-redraw @b{^L} Screen is blanked and redrawn. Keeps 1113 screen updates in sync with your commands 1114 1115scroll-next-up @b{M-^Z} Scrolls next window up by one line 1116 1117scroll-next-down @b{M-^V} Scrolls next window down by one line 1118 1119delete-window @b{^X0} Deletes current window 1120 1121delete-other-windows @b{^X1} Deletes all but current window 1122 1123resize-window @b{^X^W} Resizes window to a given numeric argument 1124@end(verbatim) 1125@chapter(Using a Mouse) 1126 1127 On computers equipped with a mouse@index(mouse), the mouse can 1128usually be used to make editing easier. If your computer has a mouse, 1129let's try using it. Start MicroEMACS by typing: 1130 1131 emacs publish.txt 1132 1133 This brings EMACS up and allows it to edit the file from the 1134last chapter. If the function key window is visible on the screen, 1135press the F5 key to cause it to disappear. Now use the @b(^X2) 1136@i(split-current-window) command to split the screen into two windows. 1137Next use the @b(^X^F) @i(find-file) command to read in the @b(fang.txt) 1138file. Now your screen should have two windows looking into two 1139different files. 1140 1141 Grab the mouse and move it around. On the screen an arrow, or 1142block of color appears. This is called the mouse cursor @index(mouse 1143cursor) and can be positioned on any character on the screen. On some 1144computers, positioning the mouse cursor in the extreme upper right or 1145left corner may bring down menus which allow you to access that 1146computers utilities, sometimes called @b(Desk Accessories) @index(desk 1147accessories). 1148 1149@section(Moving around with the mouse) 1150 1151 Using the mouse button (or the left button if the mouse has more 1152than one), position the mouse over some character in the current window. 1153Click the mouse button once. The @b(point) will move to where the mouse 1154cursor is. If you place the mouse cursor past the end of a line, the 1155point will move to the end of that line. 1156 1157 Move the mouse cursor into the other window and click on one of 1158the characters there. MicroEMACS will automatically make this window 1159the current window (notice that the mode line changes) and position the 1160point to the mouse cursor. This makes it very easy to use the mouse to 1161switch to a different window quickly. 1162 1163@section(Dragging around) 1164 1165 Besides just using the mouse to move around on the screen, you 1166can use the same button to move text. Move the mouse cursor to a 1167character in one of the windows, and click down... but don't let the 1168button up yet! The point will move to where the mouse cursor is. Now 1169move the mouse cursor up or down on the screen, and release the button. 1170The point will again move to where the mouse cursor is, but this time 1171it will bring the text under it along for the ride. This is called 1172@b(dragging)@index(dragging), and is how you can make the text appear 1173just where you want it to. If you try to drag text out of the current 1174window, EMACS will ignore your attempt and leave the point where you 1175first clicked down. @index(vertical scrolling) 1176 1177 Now, click down on a word in one of the windows, and drag it 1178directly to the left. Release the button and watch as the entire 1179window slides, or @b(scrolls) @index(horizontal scrolling) to the left. 1180The missing text has not been deleted, it is simply not visible, off the 1181left hand side of the screen. Notice the mode line has changed and now 1182looks similar to this: 1183 1184@flushleft(==== MicroEMACS 4.0 [15:12] [<12] L:4 C:23 () == fang.txt == File: fang.txt ==============) 1185 1186 The number insided the brackets [] shows that the screen is now 1187scrolled 12 characters from the left margin. 1188 1189 Now grab the same text again, and drag it to the right, pulling 1190the rest of the text back into the current window. The [<] field will 1191disappear, meaning that the window is no longer scrolled to the left. 1192This feature is very useful for looking at wide charts and tables. 1193Remember, MicroEMACS will only scroll the text in the current window 1194sideways if you drag it straight to the side, otherwise it will drag 1195the text vertically. 1196 1197 Now, place the mouse cursor over a character on the upper mode 1198line, click down, move the mouse cursor up or down a few lines and let 1199go of the button. The mode line moves to where you dragged it, 1200changing the size of the windows above and below it. If you try to 1201make a window with less than one line, EMACS will not let you. Dragging 1202the mode lines can make it very fast and easy for you to rearrange the 1203windows as you would like. 1204 1205 If you have a number of different windows visible on the screen, 1206positioning the mouse over the mode line of one window and clicking the 1207right mouse button will cause that window to be deleted. 1208 1209@section(Cut and Paste) 1210 1211 If your mouse has two buttons, then you can use the right 1212button to do some other things as well. Earlier, we learned how to 1213define a @b(region)@index(region) by using the @b(M-<space>) 1214@i(set-mark) command. Now, position the mouse over at the beginning of 1215a region you would like to copy. Next click and hold down the right 1216mouse button. Notice that the point jumps to the mouse cursor and 1217EMACS reports "[Mark Set]". Holding the button down move the mouse to 1218the end of the text you wish to copy and release the mouse button. 1219Emacs reports "[Region Copied]" to let you know it has copied the 1220region into the KILL buffer. This has done the same job as the @b(M-W) 1221@i(copy-region) command. 1222 1223 If you now click the right mouse button, 1224without moving the mouse, the region you defined dissapear, being 1225@b(cut)@index(cut) from the current buffer. This works just like the 1226@b(^W) @i(kill-region) command. 1227 1228 If you move the mouse away from where you cut the text, and 1229click the right mouse button down and up without moving the mouse, the 1230text in the KILL buffer gets inserted, or pasted@index(paste) into the 1231current buffer at the point. 1232 1233@section(Screens) 1234 1235 MicroEMACS can use more than one screen@index(screen) at once. 1236Each screen is a collection of @i(windows) along with a mode line. These 1237screens usually fill the terminal or computer screen on text based 1238systems, but can also be held in different @b(windows) on graphically 1239based systems like MicroSoft Windows, OS/2, the Macintosh Finder and 1240X-Windows. Don't be confused by the two different uses of the term 1241"window". Inside EMACS style editors, a @i(window) lets you view part of 1242a buffer. Under graphical operating systems, a @b(window) holds a 1243"virtual terminal", allowing you to manipulate more than one job, 1244editing session or program at once. Within MicroEMACS, these operating 1245system @b(window)s are called screens. All these screens are displayed 1246on your current desktop@index(desktop). 1247 1248@section(Resizing a Screen) 1249 1250 You can change the size of a screen. Move the mouse to the last 1251position of the command line. Press the left mouse button down. Holding 1252it, move the mouse to the place you want the new lower right corner. 1253Release the mouse. The desktop redraws, with your newly resized screen. 1254MicroEMACS will ignore size changes that can not be done, like 1255attempting to pull the lower left corner above the upper right corner of 1256the current screen. 1257 1258@section(Moving a Screen) 1259 1260 To change where on the desktop a screen is placed, move the 1261mouse to the upper right corner of the screen, press the left mouse 1262button down, move the mouse and release it where you want the screen 1263displayed. Again, MicroEMACS will ignore placements that can not be 1264done. 1265 1266@section(Creating a Screen) 1267 1268 Creating a new screen is just like moving a screen, but using 1269the right button. Move to the upper right of an existing screen, press 1270the right mouse button down, and move the mouse, releasing the button 1271where the new screen should appear. A new screen will have a single 1272@b(window), containing the contents of the current window in the copied 1273screen, and will have that @b(window)'s colors. The new screen will have 1274the copied screen's size. 1275 1276@section(Switching to a Screen) 1277 1278 This is simple. Any mouse command can be done in any screen by 1279placing the mouse on a visible part of the screen and clicking. The last 1280screen the mouse is used on comes to front and is the current screen. 1281Also, the @b(A-C) @i(cycle-screens)@index(cycle-screens) command brings 1282the rearmost screen to front. 1283 1284@section(Deleting a Screen) 1285 1286 Place the mouse on the command line of the screen you want to 1287delete. Click the right mouse button, the screen will disapear. If you 1288delete the only remaining screen on the desktop, MicroEMACS will exit. 1289 1290@section(Mousing under WINDOWS 95) 1291 1292 The @ir(Windows 95) version of MicroEMACS loads a special macro 1293when it comes up which makes the mousing more similar to the CUA 1294standard. The left mouse button is used to outline regions which then 1295can be cut and pasted to and from the clipboard from the menus. Text 1296placed in the clipboard can be pasted to other documents. 1297 If you wish to disable this and use the standard EMACS mousing, 1298rename CUA.CMD in the installation directory to another name. 1299@newpage 1300@heading(Chapter @value(chapter) Summary) 1301 1302In Chapter @value(chapter), you learned how to use the mouse to move the 1303point, switch windows, drag text, and resize windows. You also learned 1304how to use the right mouse button in order to copy and delete regions 1305and yank them back at other places. And lastly, you learned how to 1306control multiple screens with the mouse. 1307 1308@begin{verbatim} 1309@begin(group) 1310@u(Action Mouse Directions) 1311 1312Move Cursor position mouse cursor over desired location 1313 click down and up with left button 1314 1315Drag Text position mouse cursor over desired text 1316 click left button down 1317 move to new screen location for text 1318 release mouse button 1319 1320Resize Windows position mouse cursor over mode line to move 1321 click left button down 1322 move to new location for mode line 1323 release mouse button 1324 1325Delete Window position mouse cursor over mode line of window to delete 1326 click right mouse button 1327 1328Activate Screen Move mouse over existing screen 1329 click left button down and up 1330 1331Resize Screen position mouse cursor over last character on message line 1332 click left button down 1333 move to new lower right corner of screen 1334 release mouse button 1335 1336Copy Region position mouse at beginning of region 1337 click right button down 1338 move to end of region 1339 release mouse button 1340 1341Cut Region position mouse at beginning of region 1342 click right button down 1343 move to end of region 1344 release mouse button 1345 click right button down and up 1346 1347Paste Region position mouse at place to paste 1348 click right button down and up 1349 1350Create Screen position mouse at upper left corner of existing screen 1351 click right button down 1352 move to position of new screen 1353 release mouse button 1354 1355Resize Screen position mouse at lower right corner of screen 1356 click left button down 1357 move to new lower left corner 1358 release mouse button 1359 1360Move Screen position mouse at upper right corner of screen 1361 click left button down 1362 move to new screen position 1363 release mouse button 1364 1365Delete Screen position to command line of existing screen 1366 click right button down 1367 release mouse button 1368@end(group) 1369@end(verbatim) 1370@chapter(Buffers) 1371 1372@index(buffer)We have already learned a number of things about buffers. 1373As you will recall, they are the major internal entities in EMACS -- 1374the place where editing commands are executed. They are characterized 1375by their @b<names>, their @b<modes>, and by the file with which they 1376are associated. Each buffer also "remembers" its @b(mark) and 1377@b(point). This convenient feature allows you to go to other buffers 1378and return to the original location in the "current" buffer. 1379 1380Advanced users of EMACS frequently have a number of buffers in the 1381computer's memory simultaneously. In the last chapter, for example, you 1382opened at least two buffers -- one into the text you were editing, and 1383the other into the EMACS on-line tutorial. If you deal with complex 1384text files -- say, sectioned chapters of a book, you may have five or 1385six buffers in the computer's memory. You could select different 1386buffers by simply calling up the file with @b{^X^F} @i(find-file) 1387@index(find-file), and let EMACS open or reopen the buffer. However, 1388EMACS offers fast and sophisticated buffering techniques that you will 1389find easy to master and much more convenient to use. 1390 1391Let's begin by opening three buffers. You can open any three you 1392choose, for example call the following files into memory: @b(fang.txt), 1393@b(publish.txt), and @b(emacs.tut) in the order listed here. When 1394you've finished this process, you'll be looking at a screen showing the 1395EMACS tutorial. Let's assume that you want to move to the fang.txt 1396buffer. Enter: 1397 1398@b{^XX} @i(next-buffer) @index(next-buffer) 1399 1400This command moves you to the @u<next> buffer. Because EMACS cycles 1401through the buffer list, which is alphabetized, you will now be in the 1402@b(fang.txt) buffer. Using @b(^XX) again places you in the 1403@b(publish.txt) buffer. @i(If you are on a machine that supports 1404function keys, using @b[^XX] again places you in the @b(Function Keys) 1405buffer). Using @b(^XX) one last time cycles you back to the beginning 1406of the list. 1407 1408If you have a large number of buffers to deal with, this cycling process 1409may be slow and inconvenient. The command @b{^XB} @i(select-buffer) 1410@index(select-buffer) allows you to specify the buffer you wish to be 1411switched to. When the command is entered, EMACS prompts, "Use buffer:". 1412Simply enter the buffer name (NOT the file name), and that buffer will 1413then become the current buffer. If you type in part of the file name 1414and press the space bar, EMACS will attempt to complete the name from 1415the list of current buffers. If it succeeds, it will print the rest of 1416the name and you can hit <NL> to switch to that buffer. If EMACS beeps 1417the bell, there is no such buffer, and you may continue editing the name 1418on the command line. 1419 1420Multiple buffer manipulation and editing is a complex activity, and you 1421will probably find it very inconvenient to re-save each buffer as you 1422modify it. The command @b{^X^B} @i(list-buffers) @index(list-buffers) 1423creates a new window that gives details about all the buffers currently 1424known to EMACS. Buffers that have been modified are identified by the 1425"buffer changed" indicator (an asterisk in the second column). You can 1426thus quickly and easily identify buffers that need to be saved to files 1427before you exit EMACS. The buffer window also provides other 1428information -- buffer specific modes, buffer size, and buffer name are 1429also listed. To close this window, simply type the close-windows 1430command, @b{^X1}. 1431 1432To delete any buffer, type @b{^XK} @i(delete-buffer) 1433@index(delete-buffer). EMACS prompts you "Kill buffer:". Enter the 1434buffer name you want to delete. As this is destructive command, EMACS 1435will ask for confirmation if the buffer was changed and not saved. 1436Answer Y(es) or N(o). As usual @b{^G} cancels the command. 1437 1438@newpage 1439@heading(Chapter @value(chapter) Summary) 1440 1441In Chapter @value(chapter) you learned how to manipulate buffers. 1442 1443@begin{verbatim} 1444@u(Key Binding Keystroke Effect) 1445next-buffer @b(^X^X) Switch to the next buffer in the 1446 buffer list 1447 1448select-buffer @b(^XB) Switch to a particular buffer 1449 1450list-buffers @b(^X^B) List all buffers 1451 1452delete-buffer @b(^XK) Delete a particular buffer if it 1453 is off-screen 1454@end(verbatim) 1455@chapter(Modes) 1456 1457 EMACS allows you to change the way it works in order to 1458customized it to the style of editing you are using. It does this by 1459providing a number of different @b(modes) @index(modes). These modes 1460can effect either a single buffer, or any new buffer that is created. 1461To add a mode to the current buffer, type @b(^XM) @i(add-mode) 1462@index(add-mode). EMACS will then prompt you for the name of a mode to 1463add. When you type in a legal mode name, and type a <NL>, EMACS will 1464add the mode name to the list of current mode names in the mode line of 1465the current buffer. 1466 1467 To remove an existing mode, typing the @b(^X^M) @i(delete-mode) 1468@index(delete-mode) will cause EMACS to prompt you for the name of a 1469mode to delete from the current buffer. This will remove that mode from 1470the mode list on the current mode line. 1471 1472 Global modes are the modes which are inherited by any new 1473buffers which are created. For example, if you wish to always do string 1474searching with character case being significant, you would want global 1475mode EXACT to be set so that any new files read in inherent the EXACT 1476mode. Global modes are set with the @b(M-M) @i(add-global-mode) 1477@index(add-global-mode) command, and unset with the @b(M-^M) 1478@i(delete-global-mode) @index(delete-global-mode) command. Also, the 1479current global modes are displayed in the first line of a 1480@b(^X^B) @i(list-buffers) @index(list-buffers) command. 1481 1482 On machines which are capable of displaying colors, 1483@index(color) the mode commands can also set the background and 1484foreground character colors. Using @i(add-mode) or @i(delete-mode) with 1485a lowercase color will set the background color in the current window. 1486An uppercase color will set the foreground color in the current window. 1487Colors that EMACS knows about are: white, cyan, magenta, yellow, blue, 1488red, green, and black. If the computer you are running on does not have 1489eight colors, EMACS will attempt to make some intelligent guess at what 1490color to use when you ask for one which is not there. 1491 1492@section(ABBREV mode)@index(ABBREV mode) 1493 1494 EMACS can save much tedious typing by automatically expanding 1495predefined abrreviations as you type. Placing EMACS into ABBREV mode 1496tells to to access its table of abbreviations, and look for these 1497abbreviations while you type. When EMACS sees that you have typed one of 1498these, it replaces it with the expanded definition. Information on 1499setting up abbreviation definitions is in chapter @ref(abbrevs). 1500 1501@section(ASAVE mode)@index(ASAVE mode) 1502 1503 Automatic Save mode tells EMACS to automatically write out the 1504current buffer to its associated file on a regular basis. Normally this 1505will be every 256 characters typed into the file. The environment 1506variable $ACOUNT counts down to the next auto-save, and $ASAVE is the 1507value used to reset $ACOUNT after a save occurs. 1508 1509@section(CMODE mode)@index(CMODE mode) 1510 1511 CMODE is useful to C programmers. When CMODE is active, EMACS 1512will try to assist the user in a number of ways. This mode is set 1513automatically with files that have a .c or .h extension. 1514 1515 The <NL> key will normally attempt to return the user to the 1516next line at the same level of indentation as the last non blank line, 1517unless the current line ends with a open brace ({) in which case the 1518new line will be further indented by one tab position. 1519 1520 A close brace (}) will search for the corresponding open brace 1521and line up with it. 1522 1523 A pound sign (#) with only leading white space will delete all 1524the white space preceding itself. This will always bring preprocessor 1525directives flush to the left margin. 1526 1527 Whenever any close fence is typed, IE )]>}, if the matching open 1528fence is on screen in the current window, the cursor will briefly flash 1529to it, and then back. This makes balancing expressions, and matching 1530blocks much easier. 1531 1532@section(CRYPT mode)@index(CRYPT mode) 1533 1534 When a buffer is in CRYPT mode, @index(encryption) it is 1535encrypted whenever it is written to a file, and decrypted when it is 1536read from the file. The encryption key can be specified on the command 1537line with the -k switch, or with the @b(M-E) @i(set-encryption-key) 1538@index(set-encryption-key) command. If you attempt to read or write a 1539buffer in crypt mode and now key has not been set, EMACS will execute 1540@i(set-encryption-key) automatically, prompting you for the needed key. 1541Whenever EMACS prompts you for a key, it will not echo the key to your 1542screen as you type it (IE make SURE you get it right when you set it 1543originally). 1544 1545 The encryption algorithm used changes all characters into normal 1546printing characters, thus the resulting file is suitable for sending via 1547electronic mail. All version of MicroEMACS should be able decrypt the 1548resulting file regardless of what machine encrypted it. Also available 1549with EMACS is the stand alone program, MicroCRYPT, which can en/decrypt 1550the files produced by CRYPT mode in EMACS. 1551 1552@section(EXACT mode)@index(EXACT mode) 1553 1554 When this mode is active, all string searches and replacements 1555will take upper/lower case into account. Normally the case of a string 1556during a search or replace is not taken into account. 1557 1558@section(MAGIC mode)@index(MAGIC mode) 1559 1560 In the MAGIC mode certain characters gain special meanings when 1561used in a search pattern. Collectively they are know as @index(regular 1562expressions) regular expressions, and a limited number of them are 1563supported in MicroEmacs. They grant greater flexibility when using the 1564search command. They have no affect on the incremental search 1565command. 1566 1567 The symbols that have special meaning in MAGIC mode are 1568^, $, ., &, ?, *, +, <, >, [ (and ], used with it), and \. 1569 1570 The characters ^ and $ fix the search pattern to the beginning and 1571end of line, respectively. The ^ character must appear at the beginning 1572of the search string, and the $ must appear at the end, otherwise they 1573lose their meaning and are treated just like any other character. For 1574example, in MAGIC mode, searching for the pattern "t$" would put the 1575cursor at the end of any line that ended with the letter 't'. Note that 1576this is different than searching for "t<NL>", that is, 't' followed by a 1577newline character. The character $ (and ^, for that matter) matches a 1578position, not a character, so the cursor remains at the end of the line. 1579But a newline is a character that must be matched like any other 1580character, which means that the cursor is placed just after it - on the 1581beginning of the next line. 1582 1583 The character . has a very simple meaning -- it matches any single 1584character, except the newline. Thus a search for "bad.er" could match 1585"badger", "badder" (slang), or up to the 'r' of "bad error". 1586 1587 The character [ indicates the beginning of a character class. It 1588is similar to the 'any' character ., but you get to choose which 1589characters you want to match. The character class is ended with the 1590character ]. So, while a search for "ba.e" will match "bane", "bade", 1591"bale", "bate", et cetera, you can limit it to matching "babe" and 1592"bake" by searching for "ba[bk]e". Only one of the characters inside 1593the [ and ] will match a character. If in fact you want to match any 1594character except those in the character class, you can put a ^ as the 1595first character. It must be the first character of the class, or else 1596it has no special meaning. So, a search for [^aeiou] will match any 1597character except a vowel, but a search for [aeiou^] will match any vowel 1598or a ^. 1599 1600 If you have many characters in order, that you want to put in the 1601character class, you may use a dash (-) as a range character. So, [a-z] 1602will match any letter (or any lower case letter if EXACT mode is on), 1603and [0-9a-f] will match any digit or any letter 'a' through 'f', which 1604happen to be the characters for hexadecimal numbers. If the dash is at 1605the beginning or end of a character class, it is taken to be just a 1606dash. 1607 1608 The ? character indicates that the preceding character is optional. 1609The character may or may not appear in the matched string. For example, 1610a search for "bea?st" would match both "beast" and "best". If there is 1611no preceding charcter for ? to modify, it is treated as a normal 1612question mark character. 1613 1614 The * character is known as closure, and means that zero or more 1615of the preceding character will match. If there is no preceding character, 1616 * has no special meaning and is treated as a normal asterisk. The 1617closure symbol will also have no special meaning if it is preceded by 1618the beginning of line symbol ^, since it represents a position, not a 1619character. 1620 1621 The notion of zero or more characters is important. If, for 1622example, your cursor was on the line 1623 1624@example(This line is missing two vowels.) 1625 1626and a search was made for "a*", the cursor would not move, because it is 1627guaranteed to match no letter 'a' , which satisfies the search 1628conditions. If you wanted to search for one or more of the letter 'a', 1629you could search for "aa*", which would match the letter a, then zero or 1630more of them. A better way, however, is to use the + character. 1631 1632 The + character behaves in every respect like the * character, with 1633the exception that its minimum match range is one, not zero. Thus the 1634pattern "a+" is identical to "aa*". 1635 1636 The < and > characters matches a position at the beginning and end 1637of a word respectively. Thus a pattern like \<wo only matches the string 1638"wo" if it is at the beginning of a word. 1639 1640 The \ is the escape character. With the exception of groups, which 1641are explained below, the \ is used at those times when you want to be in 1642MAGIC mode, but also want a regular expression character to be just a 1643character. It turns off the special meaning of the character. So a 1644search for "it\." will search for a line with "it.", and not "it" 1645followed by any other character. Or, a search for "TEST\*+" would match 1646the word TEST followed by one or more asterisks. The escape character 1647will also let you put ^, -, or ] inside a character class with no 1648special side effects. 1649 1650 The character pair \( represent the start of a group in a search 1651string. A group is ended by the character pair \). All characters 1652matched within the \( and \) are part of a numbered group, and may be 1653referenced with the &GROUP function, or with a \ followed by the group 1654number in the replacement string of @i(replace-string) 1655@index(replace-string) or the 1656@i(query-replace-string) @index(query-replace-string) commands. For 1657example, a search for "INDEX\([0-9]+\)", to be replaced by "getind(\1)" 1658would change 1659 1660@example(indptr := INDEX42) to @example(indptr := getind(42)). 1661 1662 There may be up to nine groups. Groups may be nested. 1663 1664 The character & (ampersand) is a replacement character, and 1665represents all the characters which were matched by the search string. 1666When used in the @b[M-R] @i(replace-string) @index(replace-string) or 1667the @b[M-^R] 1668@i(query-replace-string) @index(query-replace-string) commands, the & 1669will be substituted for the search string. 1670 1671@section(OVER mode)@index(OVER mode) 1672 1673 OVER mode stands for overwrite mode. When in this mode, when 1674characters are typed, instead of simply inserting them into the file, 1675EMACS will attempt to overwrite an existing character past the point. 1676This is very useful for adjusting tables and diagrams. 1677 1678@section(WRAP mode)@index(WRAP mode) 1679 1680 Wrap mode is used when typing in continuous text. Whenever the 1681cursor is past the currently set $fillcol @index($fillcol) (72 by 1682default) and the user types a space or a <NL>, the last word of the line 1683is brought down to the beginning of the next line. Using this, one just 1684types a continuous stream of words and EMACS automatically inserts <NL>s 1685at appropriate places. 1686 1687@center(NOTE to programmers:) 1688 1689@example{The EMACS variable $wraphook contains the name of the 1690function which executes when EMACS detects it is time to 1691wrap. This is set to the function @i(wrap-word) 1692@index(wrap-word) by default, but can be changed to 1693activate different functions and macroes at wrap time.} 1694 1695@section(VIEW mode)@index(VIEW mode) 1696 1697 VIEW mode disables all commands which can change the current 1698buffer. EMACS will display an error message and ring the bell every 1699time you attempt to change a buffer in VIEW mode. 1700@newpage 1701@heading(Chapter @value(chapter) Summary) 1702 1703In Chapter @value(chapter) you learned about modes and their effects. 1704 1705@begin{verbatim} 1706@u(Key Binding Keystroke Effect) 1707add-mode @b(^XM) Add a mode to the current buffer 1708 1709delete-mode @b(^X^M) Delete a mode from the current buffer 1710 1711add-global-mode @b(M-M) Add a global mode to the 1712 current buffer 1713 1714delete-global-mode @b(M-^M) Delete a global mode from the 1715 current buffer 1716@end(verbatim) 1717@chapter(Files) 1718 1719A file is simply a collection of related data. In EMACS we are dealing 1720with text files -- named collections of text residing on a disk (or some 1721other storage medium). You will recall that the major entities EMACS 1722deals with are buffers. Disk-based versions of files are only active in 1723EMACS when you are reading into or writing out of buffers. As we have 1724already seen, buffers and physical files are linked by associated 1725file names. For example, the buffer "ch7.txt" which is associated with 1726the physical disk file "ch7.txt." You will notice that the file is 1727usually specified by the drive name or (in the case of a hard drive) a 1728path. Thus you can specify full file names in EMACS, 1729 1730e.g. disk:\directories\filename.extension 1731 1732If you do not specify a disk and directories, the default disk and the 1733current directory is used. 1734 1735IMPORTANT -- If you do not explicitly save your buffer to a file, all your 1736edits will be lost when you leave EMACS (although EMACS will prompt you 1737when you are about to lose edits by exiting). In addition, EMACS does 1738not protect your disk-based files from overwriting when it saves files. 1739Thus when you instruct EMACS to save a file to disk, it will create a 1740file if the specified file doesn't exist, or it will overwrite the 1741previously saved version of the file thus replacing it. Your old 1742version is gone forever. 1743 1744If you are at all unsure about your edits, or if (for any reason) you 1745wish to keep previous versions of a file, you can change the name of 1746the associated file with the command @b{^XN} 1747@i(change-file-name)@index(change-file-name). When this file is saved 1748to disk, EMACS will create a new physical file under the new name. The 1749earlier disk file will be preserved. 1750 1751For example, let's load the file @b{fang.txt} into EMACS. Now, type 1752@b{^XN}. The EMACS command line prompts "Name:". Enter a new name 1753for the file -- say @b(new.txt) and press <NL>. The file will be 1754saved under the new filename, and your disk directory will show both 1755@b(fang.txt) and @b(new.txt). 1756 1757An alternative method is to write the file directly to disk under a new 1758filename. Let's pull our "publish.txt" file into EMACS. To write this 1759file under another filename, type @b{^X^W} 1760@i(write-file)@index(writefile). EMACS will prompt you "write file:". 1761Enter an alternate filename -- @b{desktop.txt}. Your file will be 1762saved as the physical file "desktop.txt". 1763 1764Note that in the examples above, although you have changed the names of 1765the related files, the buffer names remain the same. However, when you 1766pull the physical file back into EMACS, you will find that the buffer 1767name now relates to the filename. 1768 1769For example -- You are working with a buffer "fang.txt" with the related 1770file "fang.txt". You change the name of the file to "new.txt". EMACS 1771now shows you working with the buffer "fang.txt" and the related file 1772"new.txt". Now pull the file "new.txt" into EMACS. Notice that the 1773buffer name has now changed to "new.txt". 1774 1775If for any reason a conflict of buffer names occurs,(if you have files 1776of the same name on different drives for example) EMACS will prompt 1777you "use buffer:". Enter an alternative buffer name if you need to. 1778 1779For a list of file related commands (including some we`ve already 1780seen), see the summary page. 1781@newpage 1782@heading(Chapter @value(chapter) Summary) 1783 1784In Chapter @value(chapter) you learned some of the more advanced 1785concepts of file naming and manipulation. The relationship between 1786files and buffers was discussed in some detail. 1787 1788@begin(verbatim) 1789@u(Key Binding Keystroke Effect) 1790 1791save-file @b{^X^S} Saves contents of current buffer with 1792 associated filename on default disk/ 1793 directory (if not specified) 1794 1795write-file @b{^X^W} Current buffer contents will be 1796 saved under specified name 1797 1798change-file-name 1799 @b{^XN} The associated filename is changed 1800 (or associated if not previously 1801 specified) as specified 1802 1803find-file @b{^X^F} Reads specified file into buffer and 1804 switches you to that buffer, or switches 1805 to buffer in which the file has previously 1806 been read 1807 1808read-file @b{^X^R} Reads file into buffer thus overwriting 1809 buffer contents. If file has already 1810 been read into another buffer, you will 1811 be switched to it 1812 1813view-file @b{^X^V} The same as read-file except the buffer 1814 is automatically put into VIEW mode thus 1815 preventing any changes from being made 1816@end{verbatim} 1817@chapter(Screen Formatting) 1818 1819@section<Wrapping Text> 1820 1821As we learned in the introduction, EMACS is not a word processor, but an 1822editor. Some simple formatting options are available however, although 1823in most cases they will not affect the appearance of the finished text 1824@index(wrapping text) when it is run through the formatter. We have 1825already encountered WRAP mode which wraps lines longer than a certain 1826length (default is 75 characters). You will recall that WRAP is enabled 1827by entering @b{^XM} and responding to the command line prompt with 1828@b{wrap}. 1829 1830 You can also set your own wrap margin by changing the $fillcol 1831variable. Do this by typing ^XA $fillcol <NL> 20. Now the fill column is 1832set at column 20. Now try typing some text. You'll notice that EMACS 1833only allows you to input text in a 20 character wide column! 1834 1835 To reset the wrap column to 72 characters, type ^XA $fillcol 1836<NL> 72. Your text will again wrap at the margin you've been using up to 1837this point. 1838 1839@section<Reformatting Paragraphs> 1840 1841After an intensive editing session, you may find that you have 1842paragraphs containing lines of differing lengths. Although this 1843disparity will not affect the formatted text, aesthetic and technical 1844concerns may make it desirable to have consistent paragraph blocks on 1845the screen. If you are in WRAP mode, you can reformat a paragraph with 1846the command @b{M-Q} @i(fill-paragraph) @index(fill-paragraph). This 1847command 'fills' the current paragraph reformatting it so all the lines 1848are filled and wrap logically. 1849 1850@section<Changing Case> 1851 1852There may be occasions when you find it necessary to change the case of 1853the text you've entered. EMACS allows you to change the case of even 1854large amounts of text with ease. Let's try and convert a few of the 1855office traditionalists to the joy of word processing. Type in the 1856following text: 1857 1858@example{Throw away your typewriter and learn to use a word 1859processor. Word processing is relatively easy to learn 1860and will increase your productivity enormously. Enter 1861the Computer Age and find out just how much fun it can 1862be!!} 1863 1864Let's give it a little more impact by capitalizing the first four words. 1865The first step is to define the region of text just as you would if you 1866were doing an extensive deletion. Set the mark at the beginning of the 1867paragraph with @b{M-<space>} @i(set-mark) and move the cursor to the 1868space beyond "typewriter." Now enter @b{^X^U} @i(case-region-upper). 1869Your text should now look like this: 1870 1871@example{THROW AWAY YOUR TYPEWRITER and learn to use a word 1872processor. Word processing is relatively easy to learn 1873and will increase your productivity enormously. Enter 1874the Computer Age and find out just how much fun it can 1875be!!} 1876 1877If you want to change the text back to lower case, type @b{^X^L} 1878@i(case-region-lower) @index(case-region-lower). You can also 1879capitalize individual words. To capitalize the word "fun", position the 1880cursor in front of the word and type @b{M-U} @i(case-word-upper) 1881@index(case-word-upper). The word is now capitalized. To change it 1882ck to lower case, move the cursor back to the beginning of the word 1883and type @b{M-L} @i(case-word-lower) @index(case-word-lower). 1884 1885You may also capitalize individual letters in EMACS. The command 1886@b{M-C} @i(case-word-capitalize) @index(case-word-capitalize) 1887capitalizes the first letter after the point. This command would 1888normally be issued with the cursor positioned in front of the first 1889letter of the word you wish to capitalize. If you issue it in the 1890middle of a word, you can end up with some strAnge looking text. 1891 1892@section<Tabs> 1893 1894Unless your formatter is instructed to take screen text literally (as 1895MicroSCRIBE does in the 'verbatim' environment for example), tabs in 1896EMACS generally affect screen formatting only. 1897 1898When EMACS is first started, it sets the default tab to every eighth 1899column. As long as you stay with default, every time you press the tab 1900key a tab character, @b(^I) is inserted. This character, like other 1901control characters, is invisible -- but it makes a subtle and 1902significant difference to your file and editing. 1903 1904For example, in default mode, press the tab key and then type the word 1905@b{Test}. "Test" appears at the eighth column. Move your cursor to the 1906beginning of the word and delete the backward character. The word 1907doesn't move back just one character, but flushes to the left margin. 1908The reason for this behavior is easily explained. In tab default, EMACS 1909inserts a 'real' tab character when you press the tab key. This 1910character is inserted at the default position, but NO SPACES are 1911inserted between the tab character and the margin (or previous tab 1912character). As you will recall, EMACS only recognizes characters (such 1913as spaces or letters) and thus when the tab character is removed, the 1914text beyond the tab is flushed back to the margin or previous tab mark. 1915 1916This situation changes if you alter the default configuration. The 1917default value may be changed by entering a numeric argument before 1918pressing the tab key. As we saw earlier, pressing the @b{META} key and 1919entering a number allows you to specify how EMACS performs a given 1920action. In this case, let's specify an argument of 10 and hit the tab 1921key. 1922 1923Now hit the tab key again and type @b{Test}. Notice the word now 1924appears at the tenth column. Now move to the beginning of the word and 1925delete the backward character. "Test" moves back by one character. 1926 1927EMACS behaves differently in these circumstances because the @b(^I) 1928@index(tab handling) @i(handle-tab) @index(handle-tab) function deals 1929with tabbing in two distinct ways. In default conditions, or if the 1930numeric argument of zero is used, @i(handle-tab) inserts a true tab 1931character. If, however, a non-zero numeric argument is specified, 1932@i(handle-tab) inserts the correct number of spaces needed to position 1933the cursor at the next specified tab position. It does NOT insert the 1934single tab character and hence any editing functions should take account 1935of the number of spaces between tabbed columns. 1936 1937The distance which a true tab character moves the cursor can be 1938modified by changing the value of the $hardtab environment variable. 1939Initially set to 8, this will determine how far each tab stop is placed 1940from the previous one. (Use the ^XA @i(set)@index(set) command to set 1941the value of an environment variable). 1942 1943Many times you would like to take text which has been created using 1944the tab character and change it to use just spaces. The command 1945@b(^X^D) @i(detab-region) @index(detab-region) changes any tabs 1946in the currently selected region into the right number of spaces so 1947the text does not change. This is very useful for times when the file 1948must be printed or transferred to a machine which does not understand 1949tabs. 1950 1951Also, the inverse command, @b(^X^E) @i(entab-region) 1952@index(entab-region) changes multiple spaces to tabs where possible. 1953This is a good way to shrink the size of large documents, especially 1954with data tables. Both of these commands can take a numeric argument 1955which will be interpreted as the number of lines to en/detab. 1956 1957Another function, related to those above is provided for by the @b(^X^T) 1958@i(trim-region)@index(trim-region) when invoked will delete any trailing 1959white space in the selected region. A preceding numeric argument will do 1960this for that number of lines. 1961@newpage 1962@heading(Chapter @value(chapter) Summary) 1963 1964In Chapter @value(chapter) introduced some of the formatting features of 1965EMACS. Text-wrap, paragraph reformatting, and tabs were discussed in 1966some detail. The commands in the following table were covered in the 1967chapter. 1968 1969@begin{verbatim} 1970 1971@u(Key Binding Keystroke Effect) 1972add-mode/WRAP @b{^XM}[WRAP] Add wrap mode to current buffer 1973 1974delete-mode/WRAP @b{^X^M}[WRAP] Remove wrap mode from current buffer 1975 1976fill-paragraph @b{M-Q} Logically reformats the current 1977 paragraph 1978 1979case-word-upper @b{M-U} Text from point to end of the 1980 current word is changed to uppercase 1981 1982case-word-lower @b{M-L} Text from point to end of the 1983 current word is changed to lowercase 1984 1985case-word-capitalize @b{M-C} First word (or letter) after the 1986 point is capitalized 1987 1988case-region-upper @b{^X^U} The current region is uppercased 1989 1990case-region-lower @b{^X^L} The current region is lowercased 1991 1992handle-tab @b{^I} Tab interval is set to the given 1993 numeric argument 1994 1995entab-region @b(^X^E) Changes multiple spaces to tabs 1996 characters where possible 1997 1998detab-region @b(^X^D) Changes tab characters to the 1999 appropriate number of spaces 2000 2001trim-region @b(^X^T) Trims white space from the end 2002 of the lines in the current region 2003@end{verbatim} 2004@chapter(Undoing the Damage) 2005 2006Often, while editing, we make mistakes. It would be hard not to do so. 2007But when you are in EMACS, most commands can be undone. Each buffer in 2008EMACS stores a list of the changes made to that buffer since the last 2009time it was read from the disk. This list holds every character typed 2010in, every character deleted, and where these occured. If you make a 2011mistake while editing, typing the @b(^_) @ir(undo) command undoes the 2012last command you typed. If you precede this with a numeric argument, it 2013undoes that many commands. For example: 2014 2015@b(<META>12^_) 2016 2017undoes the last 12 commands. 2018 2019You can actually look at the list of commands stored to be undone by 2020typing the @b(^XU) @ir(list-undos) command. It will place a list of 2021positions, repeat counts, actions and text arguments in a pop-up buffer. 2022This was mostly useful for the authors to debug the undo code, but is 2023interesting to examine. You can see how EMACS records actions, as basic 2024insertions and deletions, seperated by command bounderies. 2025 2026When undo information is collected by EMACS, it does occupy memory. On 2027most machines this presents no difficulty, but on some machines without 2028virtual memory, and in smaller memory models, @i(Like real mode under 2029MSDOS), EMACS will discard the oldest actions in the most ancient 2030visited buffer as it needs more memory. 2031 2032You can cause EMACS to discard its list of actions to be undone on the 2033current buffer by using the @b(M-^U) @ir(delete-undos) command. This can 2034be helpfull in speeding up the operation of a few of the very memory 2035intensive commands. Normally you should not need to use this command, 2036but its use is recommended in macros that manupulate large amounts 2037of text to reclaim the memory used by the undo stack of temporary 2038buffers. 2039 2040Two environment variables control the actions of the undo mechanism. 2041$undoflag, which defaults to TRUE, can be set to FALSE to disable the 2042undo mechanism altogether. $dispundo directs EMACS to display an 2043additional number on the current modeline which contains the number of 2044primitive actions currently stored in its list of actions for the 2045current buffer. 2046@newpage 2047@heading(Chapter @value(chapter) Summary) 2048 2049In Chapter @value(chapter) We learned how to undo recent editing 2050changes. The commands in the following table were covered in this 2051chapter. 2052 2053@begin{verbatim} 2054 2055@u(Key Binding Keystroke Effect) 2056delete-undos @b{M-^U} Clear out all undo information 2057 2058list-undos @b{^XU} Pop up a list of all undo 2059 information for the current buffer 2060 2061undo @b(^_) Undo the last editing operation 2062@end{verbatim} 2063@chapter(Access to the Outside World) 2064 2065 EMACS has the ability to interface to other programs and the 2066environment of the computer outside of itself. It does this through a 2067series of commands that allow it to talk to the computer's @b(command 2068processor) @index(command processor) or @b(shell) @index(shell). Just 2069what this is varies between different computers. Under MSDOS or PCDOS 2070this is the @b(command.com) @index(command.com) command processor. 2071Under UNIX it is the @b(csh) @index(cshell) shell. On the Atari ST is 2072can be the Mark Williams @b(MSH) or the Beckmeyer shell. In each case, 2073it is the part of the computer's operating system that is responsible 2074for determining what programs are executed, and when. 2075 2076 The @b(^X!) @i(shell-command) @index(shell-command) command 2077prompts the user for a command line to send out to the shell to execute. 2078This can be very useful for doing file listings and changing the 2079current directory or folder. EMACS gives control to the shell, which 2080executed the command, and then types @b([END]) and waits for the user to 2081type a character before redrawing the screen and resuming editing. If 2082the @i(shell-command) command is used from within the macro language, 2083there is no pause. 2084 2085 @b(^X@@) @i(pipe-command) @index(pipe-command) command allows 2086EMACS to execute a shell command, and if the particular computer allows 2087it, send the results into a buffer which is automatically displayed on 2088the screen. The resulting buffer, called "command" can be manipulated 2089just like any other editing buffer. Text can be copied out of it or 2090rearranged as needed. This buffer is originally created in @b(VIEW) mode, 2091so remember to @b(^X^Mview<NL>) in order to change it. 2092 2093 Many computers provide tools which will allow you to @b(filter) 2094@index(filter) text, making some modifications to it along the way. A 2095very common tool is the @b(SORT) program which accepts a file, sorts 2096it, and prints the result out. The EMACS command, @b(^X#) 2097@i(filter-buffer)@index(filter-buffer) sends the current buffer through 2098such a filter. Therefore, if you wished to sort the current buffer on 2099a system which supplied a sort filter, you would type @b(^X#sort<NL>). 2100You can also create your own filters by writing programs and utilities 2101which read text from the keyboard and display the results. EMACS will 2102use any of these which would normally be available from the current 2103shell. 2104 2105 If you would like to execute another program directly, without 2106the overhead of an intervening shell, you can use the @b(^X$) 2107@i(execute-program) @index(execute-program) command. It will prompt you 2108for an external program and its arguments and attempt to execute it. 2109Like when EMACS looks for command files, EMACS will look first in the 2110HOME directory, then down the execute PATH, and finally in the current 2111directory for the named program. On some systems, it will automatically 2112tack the proper extension on the file name to indicate it is a program. 2113On some systems that don't support this function, @b(^X$) will be 2114equivalent to @b(^X!) @i(shell-command). 2115 2116 Sometimes, you would like to get back to the shell and execute 2117other commands, without losing the current contents of EMACS. The 2118@b(^XC) @i(i-shell) @index(i-shell) command shells out of EMACS, 2119leaving EMACS in the computer and executing another command shell. Most 2120systems would allow you to return to EMACS with the "exit" command. 2121 2122 @i(On some systems, mainly advanced versions of UNIX, you can 2123direct EMACS to "go into the background" with the @b(^XD) suspend-emacs 2124@index(suspend-emacs) command. This places EMACS in the background 2125returning you to the original command shell. EMACS can then be returned 2126to at any time with the "fg" foreground command.) 2127@newpage 2128@heading(Chapter @value(chapter) Summary) 2129 2130In Chapter @value(chapter) introduced different ways to access the 2131computers shell or command processor from within EMACS. The commands 2132in the following table were covered in the chapter. 2133 2134@begin{verbatim} 2135 2136@u(Key Binding Keystroke Effect) 2137execute-program @b(^X$) Execute an external program 2138 directly 2139 2140filter-command @b(^X#) Send the current buffer through 2141 a shell filter 2142 2143i-shell @b(^XC) Escape to a new shell 2144 2145pipe-command @b(^X@@) Send the results of an external 2146 shell command to a buffer 2147 2148shell-command @b(^X!) Execute one shell command 2149 2150suspend-emacs @b(^XD) Place EMACS in the background 2151 (some UNIX systems only) 2152@end{verbatim} 2153@chapter(Keyboard Macroes) 2154 2155 In many applications, you may need to repeat a series of 2156characters or commands frequently. For example, a paper may require the 2157frequent repetition of a complex formula or a long name. You may also 2158have a series of EMACS commands that you invoke frequently. Keyboard 2159macroes offer a convenient method of recording and repeating these 2160commands. 2161 2162 Imagine, for example, you are writing a scholarly paper on 2163@i{Asplenium platyneuron}, the spleenwort fern. Even the dedicated 2164botanist would probably find it a task bordering on the agonizing to 2165type @i{Asplenium platyneuron} frequently throughout the paper. An 2166alternative method is 'record' the name in a keyboard macro. Try it 2167yourself. 2168 2169 The command @b{^X(} @i(begin-macro) @index(begin-macro) starts 2170recording the all the keystrokes and commands you input. After you've 2171typed it, enter @b{Asplenium platyneuron}. To stop recording, type 2172@b{^X)} @i(end-macro) @index(end-macro). EMACS has stored all the 2173keystrokes between the two commands. To repeat the name you've stored, 2174just enter @b{^XE} @i(execute-macro) @index(execute-macro), and the 2175name "Asplenium platyneuron" appears. You can repeat this action as 2176often as you want, and of course as with any EMACS command, you may 2177precede it with a numerical argument to repeat it many times. 2178 2179 Because EMACS records keystrokes, you may freely intermix 2180commands and text. Unfortunately, you can only store one macro at a 2181time. Thus, if you begin to record another macro, the previously defined 2182macro is lost. Be careful to ensure that you've finished with one macro 2183before defining another. If you have a series of commands that you would 2184like to 'record' for future use, use the procedure facilities detailed 2185in chapter @ref(macroes). 2186@newpage 2187@heading(Chapter @value(chapter) Summary) 2188 2189Chapter @value(chapter) covered keyboard macroes. You learned how to 2190record keystrokes and how to repeat the stored sequence. 2191 2192@begin{verbatim} 2193@u(Key Binding Keystroke Effect) 2194 2195start-macro @b{^X(} Starts recording all keyboard input 2196 2197end-macro @b{^X)} Stops recording keystrokes for macro 2198 2199execute-macro @b{^XE} Entire sequence of recorded 2200 keystrokes is replayed 2201@end{verbatim} 2202@chapter(MicroEMACS Procedures) 2203@tag(macroes) 2204 Procedures, or macroes, are programs that are used to customize 2205the editor and to perform complicated editing tasks. They may be stored 2206in files or buffers and may be executed using an appropriate command, or 2207bound to a particular keystroke. Portions of the standard start-up file 2208are implemented via procedures, as well as the built in help system. The 2209@b(M-^E) @i(run) @index(run) command causes named procedures to be executed. 2210The @i(execute-file) @index(execute-file) command allows you to execute 2211a procedure stored in a disk file, and the @i(execute-buffer) 2212@index(execute-buffer) command allows you to execute a procedure stored 2213in a buffer. Procedures are stored for easy execution by executing files 2214that contain the store-procedure command. 2215 2216 In a command file, the @i(store-procedure) 2217@index(store-procedure) command takes a string argument which is the 2218name of a procedure to store. These procedures than can be executed with 2219the @b(M-^E) @i(run) @index(run) command. Also, giving the name of a 2220stored procedure within another procedure will executed that named 2221procedure as if it had been called up with the @i(run) command. 2222 2223 Some fairly length examples of MicroEMACS procedures can be seen 2224by examining the standard files that come with EMACS. The @b(emacs.rc) 2225@index(emacs.rc) file (called @b[.emacsrc]@index[.emacsrc]) under UNIX) 2226is the MicroEMACS command file which is executed when EMACS is normally 2227run. It contains a number of different stored procedures along with the 2228lines to setup and display the Function key window @index(function key 2229window) and to call up other procedures and command files using function 2230keys. 2231 2232 There are many different aspects to the language within 2233MicroEMACS. Editor commands are the various commands that manipulate 2234text, buffers, windows, et cetera, within the editor. Directives are 2235commands which control what lines get executed within a macro. Also 2236there are various types of variables. Environmental variables both 2237control and report on different aspects of the editor. User variables 2238hold string values which may be changed and inspected. Buffer variables 2239allow text to be placed into variables. Interactive variable allow the 2240program to prompt the user for information. Functions can be used to 2241manipulate all these variables. 2242 2243@section(Constants) 2244 2245 All constants and variable contents in EMACS are stored as 2246strings of characters. Numbers are stored digit by digit as characters. 2247This allows EMACS to be "typeless", not having different variables types 2248be legal in different contexts. This has the disadvantage of forcing the 2249user to be more careful about the context of the statements variables 2250are placed in, but in turn gives them more flexibility in where they 2251can place variables. Needless to say, this also allows EMACS's expression 2252evaluator to be both concise and quick. 2253 2254 Wherever statements need to have arguments, it is legal to place 2255constants. A constant is a double quote character, followed by a string 2256of characters, and terminated by another double quote character. To 2257represent various special characters within a constant, the tilde (~) 2258@index(tilde, special use) character is used. The character following the 2259tilde is interpreted according to the following table: 2260 2261@begin(verbatim) 2262@u(Sequence Result) 2263~n EMACS newline character (breaks lines) 2264~r ^M carriage return 2265~l ^J linefeed 2266~~ ~ tilde 2267~b ^H backspace 2268~e ^[ escape 2269~f ^L formfeed 2270~t ^I tab 2271~" " quote 2272@end(verbatim) 2273 2274 Any character not in the table which follows a tilde will be 2275passed unmodified. This action is similar to the @b(^Q) 2276@i(quote-character) command available from the keyboard. 2277 2278 EMACS may use different characters for line terminators on 2279different computers. The ~n combination will always get the proper line 2280terminating sequence for the current system. 2281 2282 The double quotes around constants are not needed if the 2283constant contains no internal white space and it also does not happen to 2284meet the rules for any other EMACS commands, directives, variables, or 2285functions. This is reasonable useful for numeric constants. 2286 2287@section(Variables) 2288 2289 Variables in MicroEMACS procedures can be used to return values 2290within expressions, as repeat counts to editing commands, or as text to 2291be inserted into buffers and messages. The value of these variables is 2292set using the set @b(^XA) command. For example, to set the current fill 2293column to 64 characters, the following macro line would be used: 2294 2295 set $fillcol 64 2296 2297 or to have the contents of @b(%name) inserted at the point in the 2298current buffer, the command to use would be: 2299 2300 insert-string %name 2301 2302@subsection(Environmental Variables) 2303 2304 "What good is a quote if you can't change it?" 2305 2306 These variables are used to change different aspects of the way 2307the editor works. Also they will return the current settings if used as 2308part of an expression. All environmental variable names begin with a 2309dollar sign ($) and are in lower case. 2310 2311@begin(description) 2312@index($abbell) 2313$abbell@\Ring the bell on an expansion of an abbreviation. 2314 2315@index($abcap) 2316$abcap@\Match capitols typed in abbreviation while expanding. 2317 2318@index($abquick) 2319$abquick@\Expand abbreviations whenever any character is typed, instead 2320of just when whitespace is typed. 2321 2322@index($acount) 2323$acount@\The countdown of inserted characters until the next save-file. 2324 2325@index($asave) 2326$asave@\The number of inserted characters between automatic file-saves 2327in ASAVE mode. 2328 2329@index($bufhook) 2330$bufhook@\The function named in this variable is run when a buffer is 2331entered. It can be used to implement modes which are specific to a 2332paricular file or file type. 2333 2334@index($cbflags) 2335$cbflags@\Current buffer attribute flags (See appendix G for details). 2336 2337@index($cbufname) 2338$cbufname@\Name of the current buffer. 2339 2340@index($cfname) 2341$cfname@\File name of the current buffer. 2342 2343@index($cmdhook) 2344$cmdhook@\Name of function to run before accepting a command. This is 2345by default set to @i(nop). 2346 2347@index($cmode) 2348$cmode@\Integer containing the mode of the current buffer. (See Appendix F 2349for values). 2350 2351@index($curchar) 2352$curchar@\Ascii value of the character currently at the point. 2353 2354@index($curcol) 2355$curcol@\Current column of point in current buffer. 2356 2357@index($curline) 2358$curline@\Current line of point in current buffer. 2359 2360@index($curwidth) 2361$curwidth@\Number of columns used currently. 2362 2363@index($curwind) 2364$curwind@\Current window number. 2365 2366@index($cwline) 2367$cwline@\Current display line in current window. 2368 2369@index($debug) 2370$debug@\Flag to trigger macro debugging. 2371 2372@index($deskcolor) 2373$deskcolor@\Color to use for current desktop, default to BLACK. 2374 2375@index($diagflag) 2376$diagflag@\If set to TRUE, diagonal dragging of text and mode lines is 2377enabled. If FALSE, text and modelines can only be dragged horizontally 2378or vertically at one time. 2379 2380@index($discmd) 2381$discmd@\Controls the echoing of command prompts. Default is TRUE. 2382 2383@index($disinp) 2384$disinp@\Controls the echoing of input at the command prompts. Default 2385is TRUE. 2386 2387@index($disphigh) 2388$disphigh@\If set to TRUE, high-bit characters (single byte characters 2389that are greater than 127 in value) will be displayed in a 2390pseudo-control format. The characters "^!" will lead off the sequence, 2391followed by the character stripped of its high bit. Default is FALSE. 2392 2393@index($dispundo) 2394$dispundo@\If TRUE, EMACS displays the current depth of the undo stack 2395on the current modeline. 2396 2397@index($exbhook) 2398$exbhook@\This variable holds the name of a function or macro which is 2399run whenever you are switching out of a buffer. 2400 2401@index($exithook) 2402$exithook@\The procedure named in this variable is run when MicroEMACS is 2403about to exit. Setting $gflags bit 4 during the execution of this 2404procedure prevents the exit from occuring. 2405 2406@index($fcol) 2407$fcol@\The current line position being displayed in the first column of 2408the current window. 2409 2410@index($fillcol) 2411$fillcol@\Current fill column. 2412 2413@index($flicker) 2414$flicker@\Flicker Flag set to TRUE if IBM CGA set to FALSE for most 2415others. 2416 2417@index($fmtlead) 2418$fmtlead@\lists all formatter command leadin characters. Lines beginning 2419with these characters will be considered the beginning of paragraphs. 2420 2421@index($gflags) 2422$gflags@\Global flags controlling some EMACS internal functions (See 2423appendix G for details). 2424 2425@index($gmode) 2426$gmode@\Global mode flags. (See Appendix F for values). 2427 2428@index($hardtab) 2429$hardtab@\Number of spaces between hard tab stops. Normally 8, this can 2430be used to change indentation only within the editor.@index(tabs) 2431 2432@index($hjump) 2433$hjump@\The number in here tells EMACS how many columns to scroll the 2434screen horizontally when a horizontal scroll is required. 2435 2436@index($hscroll) 2437$hscroll@\This flag determines if EMACS will scroll the entire current 2438window horizontally, or just the current line. The default value, TRUE, 2439results in the entire current window being shifted left and right when 2440the cursor goes off the edge of the screen. 2441 2442@index($kill) 2443$kill@\This contains the first 127 characters currently in the kill 2444buffer and can be used to set the contents of the kill buffer. 2445 2446@index($language) 2447$language@\[READ ONLY]Contains the name of the language which the 2448current EMACS's message will display. (Currently EMACS is available in 2449English, French, Spanish, Latin, Portuguese, Dutch, German, Japanese, 2450and Pig Latin). 2451 2452@index($lastkey) 2453$lastkey@\[READ ONLY]Last keyboard character typed. 2454 2455@index($lastmesg) 2456$lastmesg@\[READ ONLY]Contains the text of the last message which 2457emacs wrote on the command line. 2458 2459@index($line) 2460$line@\The current line in the current buffer can be retrieved and 2461set with this environment variable. 2462 2463@index($lterm) 2464$lterm@\Character(s) to write as a line terminator when writing a file 2465to disk. Default is null, which causes a '\n' character to be written. 2466Not all operating systems support this. 2467 2468@index($lwidth) 2469$lwidth@\[READ ONLY]Returns the number of characters in the current line. 2470 2471@index($match) 2472$match@\[READ ONLY]Last string matched in a search. 2473 2474@index($modeflag) 2475$modeflag@\Determines if mode lines are currently displayed. 2476 2477@index($msflag) 2478$msflag@\If TRUE, the mouse (if present) is active. If FALSE, no mouse 2479cursor is displayed, and no mouse actions are taken.@index(mouse) 2480 2481@index($newscreen) 2482$newscreen@\Create a new screen for every newly created buffer. This 2483variable is most usefull when using a windowing system. 2484 2485@index($numwind) 2486$numwind@\The number of windows displayed. 2487 2488@index($orgrow) 2489$orgrow@\The desktop row position of current screen. 2490 2491@index($orgcol) 2492$orgcol@\The desktop column position of current screen. 2493 2494@index($pagelen) 2495$pagelen@\The number of screen lines used currently. 2496 2497@index($palette) 2498$palette@\A string used to control the palette register settings on 2499graphics versions. The usual form consists of groups of three octal 2500digits setting the red, green, and blue levels.@index(color pallette) 2501 2502@index($paralead) 2503$paralead@\A string containing all paragraph start characters. 2504 2505@index($pending) 2506$pending@\[READ ONLY]A flag used to determine if there are user keystrokes 2507waiting to be processed. 2508 2509@index($popflag) 2510$popflag@\Use pop-up windows. Default is TRUE. 2511 2512@index($popwait) 2513$popwait@\When TRUE, popup windows prompt the user to 2514type a key before they disappear. When FALSE, they do 2515not stick around to be seen. Usefull when a pop-up 2516buffer conatins info needed from a macro. Default is 2517TRUE. 2518 2519@index($posflag) 2520$posflag@\Display the line and column position on the modeline. Default 2521is FALSE. 2522 2523@index($progname) 2524$progname@\[READ ONLY]Always contains the string "MicroEMACS" for 2525standard MicroEMACS. Could be something else if EMACS is incorporated 2526as part of someone else's program. 2527 2528@index($ram) 2529$ram@\The amount of remaining memory if MicroEMACS was compiled with 2530RAMSIZE set. A debugging tool. 2531 2532@index($readhook) 2533$readhook@\This variable holds the name of a function to execute 2534whenever a file is read into EMACS. Normally, using the standard 2535@b(emacs.rc) file, this is bound to a function which places EMACS into 2536CMODE if the extension of the file read is .c or .h. 2537 2538@index($region) 2539$region@\Contains the string of the current region. It will truncate at 2540the stringsize limit, 255. 2541 2542@index($replace) 2543$replace@\The current replace pattern used in replace commands. 2544 2545@index($rval) 2546$rval@\This contains the return value from the last subprocess which was 2547invoked from EMACS. 2548 2549@index($scrname) 2550$scrname@\The current screen name. 2551 2552@index($search) 2553$search@\The current search pattern used in search and replace commands. 2554 2555@index($searchpnt) 2556$searchpnt@\Set the placement of the of the cursor on a successful 2557search match. $searchpnt = 0 (the default), causes the cursor to be 2558placed at the end of the matched text on forward searches, and at the 2559beginning of the text on reverse searches. $searchpnt = 1 causes the 2560cursor to be placed at the the beginning of the matched text regardless 2561of the search direction, while $searchpnt = 2 causes the cursor to be 2562placed at the end. 2563 2564@index($seed) 2565$seed@\Integer seed of the random number generator. 2566 2567@index($softtab) 2568$softtab@\Number of spaces inserted by EMACS when the handle-tab command 2569(which is normally bound to the TAB key) is invoked.@index(tabs) 2570 2571@index($sres) 2572$sres@\Current screen resolution (CGA, MONO, EGA or VGA on the IBM-PC 2573driver. LOW, MEDIUM, HIGH or DENSE on the Atari ST1040, NORMAL on most 2574others).@index(screen resolution) 2575 2576@index($ssave) 2577$ssave@\A variable which flags EMACS's method of saving files. If set to 2578TRUE, EMACS will write all files out to a temporary file, delete the 2579original, then rename the temporary to the old file name. The default 2580value of this is TRUE. 2581 2582@index($sscroll) 2583$sscroll@\When set to TRUE, EMACS will smoothly scroll windows one line 2584at a time when cursoring off the ends of the current window. Default is 2585FALSE. 2586 2587@index($status) 2588$status@\[READ ONLY]Status of the success of the last command (TRUE or 2589FALSE). This is usually used with !force to check on the success of a 2590search, or a file operation. 2591 2592@index($sterm) 2593$sterm@\This is the character used to terminate search string inputs. 2594The default for this is the last key bound to @i(meta-prefix). 2595 2596@index($target) 2597$target@\Current target for line moves (setting this fools EMACS into 2598believing the last command was a line move). 2599 2600@index($time) 2601$time@\[READ ONLY]Contains a string corresponding to the current date 2602and time. Usually this is in a form similar to "Mon May 09 10:10:58 1988". 2603Not all operating systems will support this. 2604 2605@index($timeflag) 2606$timeflag@\Flag to determine if the time of day is displayed on the 2607modeline. Default is FALSE. The time is updated only after a keystroke. 2608 2609@index($tpause) 2610$tpause@\Controls the length of the pause to display a matched fence 2611when the current buffer is in CMODE and a close fence has been typed. 2612 2613@index($undoflag) 2614$undoflag@\Enable collection of undo information and undo commands. 2615 2616@index($version) 2617$version@\[READ ONLY]Contains the current MicroEMACS version number. 2618 2619@index($wchars) 2620$wchars@\When set, MicroEMACS uses the characters listed in it to 2621determine if it is in a word or not. If it is not set (the default), 2622the characters it uses are the upper and lower case letters, and the 2623underscore. 2624 2625@index($wline) 2626$wline@\Number of display lines in current window. 2627 2628@index($wraphook) 2629$wraphook@\This variable contains the name of an EMACS function which is 2630executed when a buffer is in WRAP mode and it is time to wrap. By 2631default this is bound to @i(wrap-word). 2632 2633@index($writehook) 2634$writehook@\This variable contains the name of an EMACS function or 2635macro which is invoked whenever EMACS attempts to write a file out to 2636disk. This is executed before the file is written, allowing you to 2637process a file on the way out. 2638 2639@index($xpos) 2640$xpos@\The column the mouse was at the last mouse button press. 2641 2642@index($yankflag) 2643$yankflag@\Controls the placement of the cursor after a yank command or 2644an insert. When $yankflag is FALSE (the default), the cursor is placed 2645at the end of the yanked or inserted text. When it is TRUE, the cursor 2646remains at the start of the text. 2647 2648@index($ypos) 2649$ypos@\The line which the mouse was on during the last mouse button press. 2650@end(description) 2651 2652@subsection(User variables) 2653 2654 User variables allow you to store strings and manipulate them. 2655These strings can be pieces of text, numbers (in text form), or the 2656logical values @b(TRUE) and @b(FALSE). These variables can be combined, 2657tested, inserted into buffers, and otherwise used to control the way 2658your macroes execute. At the moment, up to 512 user variables may be in 2659use in one editing session. All users variable names must begin with a 2660percent sign (%) and may contain any printing characters. Only the first 266116 characters are significant (IE differences beyond the sixteenth 2662character are ignored). Most operators will truncate strings to a length 2663of 128 characters. 2664 2665@subsection(Buffer Variables) 2666 2667 Buffer variables are special in that they can only be queried 2668and cannot be set. What buffer variables are is a way to take text from 2669a buffer and place it in a variable. For example, if I have a buffer by 2670the name of RIGEL2, and it contains the text: 2671 2672@begin(verbatim) 2673@begin(group) 2674 Richmond 2675 Lafayette 2676 <*>Bloomington (where <*> is the current point) 2677 Indianapolis 2678 Gary 2679 =* MicroEMACS 4.0 (WRAP) == rigel2 == File: /data/rigel2.txt ===== 2680@end(group) 2681@end(verbatim) 2682 2683 and within a command I reference #rigel2, like: 2684 2685 insert-string #rigel2 2686 2687 MicroEMACS would start at the current point in the RIGEL2 2688buffer and grab all the text up to the end of that line and pass that 2689back. Then it would advance the point to the beginning of the next line. 2690Thus, after our last command executes, the string "Bloomington" gets 2691inserted into the current buffer, and the buffer RIGEL2 now looks like 2692this: 2693 2694@begin(verbatim) 2695@begin(group) 2696 Richmond 2697 Lafayette 2698 Bloomington 2699 <*>Indianapolis (where <*> is the current point) 2700 Gary 2701 =* MicroEMACS 4.0 (WRAP) == rigel2 == File: /data/rigel2.txt ===== 2702@end(group) 2703@end(verbatim) 2704 2705 as you have probably noticed, a buffer variable consists of the 2706buffer name, preceded by a pound sign (#). 2707 2708@subsection(Interactive variables) 2709 2710 Interactive variables are actually a method to prompt the user 2711for a string. This is done by using an at sign (@@) followed either with 2712a quoted string, or a variable containing a string. The string is the 2713placed on the bottom line, and the editor waits for the user to type in 2714a string. Then the string typed in by the users is returned as the 2715value of the interactive variable. For example: 2716 2717@begin(verbatim) 2718 set %quest "What file? " 2719 find-file @@%quest 2720@end(verbatim) 2721 2722 will ask the user for a file name, and then attempt to find it. 2723Note also that complex expressions can be built up with these 2724operators, such as: 2725 2726@verbatim(set %default "file1" 2727@@&cat &cat "File to decode[" %default "]: ") 2728 2729 which prompts the user with the string: 2730 2731 File to decode[file1]: 2732 2733@section(Functions) 2734 2735 Functions can be used to act on variables in various ways. 2736Functions can have one, two, or three arguments. These arguments will 2737always be placed after the function on the current command line. For 2738example, if we wanted to increase the current fill column by two, using 2739emacs's set (^XA) command, we would write: 2740 2741@begin(group) 2742@begin(verbatim)@begin(example) 2743 set $fillcol &add $fillcol 2 2744 \ \ \ \ \____second operand 2745 \ \ \ \_________first operand 2746 \ \ \_______________function to execute 2747 \ \_____________________variable to set 2748 \___________________________set (^XA) command 2749@end(example)@end(verbatim) 2750@end(group) 2751 2752 Function names always begin with the ampersand (&) character, 2753and are only significant to the first three characters after the 2754ampersand. Functions will normal expect one of three types of 2755arguments, and will automatically convert types when needed. Different 2756argument types include: 2757 2758@begin(description) 2759<num>@\an ascii string of digits which is interpreted as a numeric value. 2760Any string which does not start with a digit or a minus sign (-) will be 2761considered zero. 2762 2763<str>@\An arbitrary string of characters. At the moment, strings are 2764limited to 128 characters in length. 2765 2766<log>@\A logical value consisting of the string "TRUE" or "FALSE". 2767Numeric strings will also evaluate to "FALSE" if they are equal to zero, 2768and "TRUE" if they are non-zero. Arbitrary text strings will have the 2769value of "FALSE". 2770@end(description) 2771 2772 A list of the currently available functions follows. Functions 2773are always used in lower case, the uppercase letters in the function 2774table are the short form of the function (IE &div for ÷). 2775 2776@begin(verbatim) 2777Numeric Functions: (returns <num>) 2778 2779&ADD <num> <num> Add two numbers 2780&SUB <num> <num> Subtract the second number from the first 2781&TIMes <num> <num> Multiply two numbers 2782&DIVide <num> <num> Divide the first number by the second 2783 giving an integer result 2784&MOD <num> <num> Return the reminder of dividing the 2785 first number by the second 2786&NEGate <neg> Multiply the arg by -1 2787&LENgth <str> Returns length of string 2788&SINdex <str1> <str2> Finds the position of <str2> within 2789 <str1>. Returns zero if not found. 2790&ASCii <str> Return the ascii code of the first 2791 character in <str> 2792&RND <num> Returns a random integer between 1 and <num> 2793&ABS <num> Returns the absolute value of <num> 2794&BANd <num> <num> Bitwise AND function 2795&BOR <num> <num> Bitwise OR function 2796&BXOr <num> <num> Bitwise XOR function 2797&BNOt <num> Bitwise NOT function 2798 2799String manipulation functions: (returns <str>) 2800 2801&ABBREV <str> return the expansion of <str> 2802&CAT <str> <str> Concatenate the two strings to form one 2803&LEFt <str> <num> return the <num> leftmost characters 2804 from <str> 2805&RIGht <str> <num> return the <num> rightmost characters 2806 from <str> 2807&MID <str> <num1> <num2> 2808 Starting from <num1> position in <str>, 2809 return <num2> characters. 2810&REVerse <str> return a string with reversed-ordered 2811 characters 2812&UPPer <str> Uppercase <str> 2813&LOWer <str> Lowercase <str> 2814&CHR <num> return a string with the character 2815 represented by ascii code <num> 2816>C returns a string of characters 2817 containing a EMACS command input from 2818 the user 2819>K return a string containing a single 2820 keystroke from the user 2821&ENV <str> If the operating system is capable, this 2822 returns the environment string associated 2823 with <str> 2824&BIND <str> return the function name bound to the 2825 keystroke <str> 2826&XLATE <str1> <str2> <str3> 2827&FINd <str> Find the named file <str> along the 2828 path and return its full file specification 2829 or an empty string if none exists 2830&TRIM <str> Trim the trailing whitespace from a string 2831 2832Logical Testing functions: (returns <log>) 2833 2834&NOT <log> Return the opposite logical value 2835&AND <log1> <log2> Returns TRUE if BOTH logical arguments 2836 are TRUE 2837&OR <log1> <log2> Returns TRUE if either argument 2838 is TRUE 2839&EQUal <num> <num> If <num> and <num> are numerically 2840 equal, return TRUE 2841&LESs <num1> <num2> If <num1> is less than <num2>, return 2842 TRUE. 2843&GREater <num1> <num2> If <num1> is greater than <num2>, return 2844 TRUE. 2845&SEQual <str1> <str2> If the two strings are the same, return 2846 TRUE. 2847&SLEss <str1> <str2> If <str1> is less alphabetically than 2848 <str2>, return TRUE. 2849&SGReater <str1> <str2> If <str1> is alphabetically greater than 2850 or equal to <str2>, return TRUE. 2851&EXIst <str> Does the named file <str> exist? 2852 2853&ISNum <num> Is the given argument a legitimate number? 2854 2855Special Functions: 2856 2857&GROup <num> Return group <num> as set by a MAGIC 2858 mode search. 2859 2860&SUPper <str1> <str2> Translate the first char in <str1> to 2861 the first char in <str2> when uppercasing. 2862 2863&SLOwer <str1> <str2> Translate the first char in <str1> to 2864 the first char in <str2> when lowercasing. 2865 2866&INDirect <str> Evaluate <str> as a variable. 2867@end(verbatim) 2868 2869 This last function deserves more explanation. The &IND function 2870evaluates its argument, takes the resulting string, and then uses it as 2871a variable name. For example, given the following code sequence: 2872 2873@begin(verbatim) 2874 ; set up reference table 2875 2876 set %one "elephant" 2877 set %two "giraffe" 2878 set %three "donkey" 2879 2880 set %index "%two" 2881 insert-string &ind %index 2882@end(verbatim) 2883 2884 the string "giraffe" would have been inserted at the point in 2885the current buffer. This indirection can be safely nested up to about 288610 levels. 2887 2888@section(Directives) 2889 2890 Directives are commands which only operate within an executing 2891procedure, IE they do not make sense as a single command. As such, they 2892cannot be called up singly or bound to keystroke. Used within command 2893files, they control what lines are executed and in what order. 2894 2895 Directives always start with the exclamation mark (!) character 2896and must be the first non-white space placed on a line. Directives 2897executed interactively (via the execute-command-line command) will be 2898ignored. 2899 2900@subsection(!ENDM Directive) 2901 2902 This directive is used to terminate a procedure or macro being 2903stored. For example, if a file is being executed contains the text: 2904 2905@begin(verbatim) 2906 ; Read in a file in view mode, and make the window red 2907 2908 store-procedure get-red-viewed-file 2909 find-file @@"File to view: " 2910 add-mode "view" 2911 add-mode "red" 2912 !endm 2913 2914 print "[Consult procedure has been loaded]" 2915@end(verbatim) 2916 2917 only the lines between the store-macro command and the !ENDM 2918directive are stored in procedure get-red-viewd-file. Both named 2919procedures and numbered macroes (via the @i(store-macro) command) should 2920be terminated with this directive. 2921 2922@subsection(!FORCE Directive) 2923 2924 When MicroEMACS executes a procedure, if any command fails, the 2925procedure is terminated at that point. If a line is preceded by a !FORCE 2926directive, execution continues whether the command succeeds or not. For 2927example: 2928 2929@begin(verbatim) 2930 ; Merge the top two windows 2931 2932 save-window ;remember what window we are at 2933 1 next-window ;go to the top window 2934 delete-window ;merge it with the second window 2935 !force restore-window ;This will continue regardless 2936 add-mode "red" 2937@end(verbatim) 2938 Often this is used together with the $status environment 2939variable to test if a command succeeded. For example: 2940@begin(verbatim) 2941 set %seekstring @"String to Find: " 2942 !force search-forward %seekstring 2943 !if &seq $status TRUE 2944 print "Your string is Found" 2945 !else 2946 print "No such STRING!" 2947 !endif 2948@end(verbatim) 2949 2950@subsection(!IF, !ELSE, and !ENDIF Directives) 2951 2952 This directive allows statements only to be executed if a 2953condition specified in the directive is met. Every line following the 2954!IF directive, until the first !ELSE or !ENDIF directive, is only 2955executed if the expression following the !IF directive evaluates to a 2956TRUE value. For example, the following commands creates the portion of a 2957text file automatically. (yes believe me, this will be easier to 2958understand then that last explanation....) 2959 2960@begin(verbatim) 2961 !if &sequal %curplace "timespace vortex" 2962 insert-string "First, rematerialize~n" 2963 !endif 2964 !if &sequal %planet "earth" ;If we have landed on earth... 2965 !if &sequal %time "late 20th century" ;and we are then 2966 write-message "Contact U.N.I.T." 2967 !else 2968 insert-string "Investigate the situation....~n" 2969 insert-string "(SAY 'stay here Sara')~n" 2970 !endif 2971 !else 2972 set %conditions @@"Atmosphere conditions outside? " 2973 !if &sequal %conditions "safe" 2974 insert-string &cat "Go outside......" "~n" 2975 insert-string "lock the door~n" 2976 !else 2977 insert-string "Dematerialize..try somewhen else" 2978 newline 2979 !endif 2980 !endif 2981@end(verbatim) 2982 2983@subsection(!GOTO Directive) 2984 2985 Flow can be controlled within a MicroEMACS procedure using the 2986!GOTO directive. It takes as an argument a label. A label consists of a 2987line starting with an asterisk (*) and then an alphanumeric label. Only 2988labels in the currently executing procedure can be jumped to, and trying 2989to jump to a non-existing label terminates execution of a procedure. For 2990example: 2991 2992@begin(verbatim) 2993 ;Create a block of DATA statements for a BASIC program 2994 2995 insert-string "1000 DATA " 2996 set %linenum 1000 2997 2998 *nxtin 2999 update-screen ;make sure we see the changes 3000 set %data @@"Next number: " 3001 !if &equal %data 0 3002 !goto finish 3003 !endif 3004 3005 !if &greater $curcol 60 3006 2 delete-previous-character 3007 newline 3008 set %linenum &add %linenum 10 3009 insert-string &cat %linenum " DATA " 3010 !endif 3011 3012 insert-string &cat %data ", " 3013 !goto nxtin 3014 3015 *finish 3016 3017 2 delete-previous-character 3018 newline 3019@end(verbatim) 3020 3021@subsection(!WHILE and !ENDWHILE Directives) 3022 3023 This directive allows you to set up repetitive tasks easily and 3024efficiently. If a group of statements need to be executed while a 3025certain condition is true, enclose them with a while loop. For example, 3026 3027@begin(verbatim) 3028 !while &less $curcol 70 3029 insert-string &cat &cat "[" #stuff "]" 3030 !endwhile 3031@end(verbatim) 3032 3033 places items from buffer "item" in the current line until the 3034cursor is at or past column 70. While loops may be nested and can 3035contain and be the targets of !GOTOs with no ill effects. Using a while 3036loop to enclose a repeated task will run much faster than the 3037corresponding construct using !IFs. 3038 3039@subsection(!BREAK Directive) 3040 3041 This lets you abort out of the most executing currently inner 3042while loop, regardless of the condition. It is often used to abort 3043processing for error conditions. For example: 3044 3045@begin(verbatim) 3046; Read in files and substitute "begining" with "beginning" 3047 3048 set %filename #list 3049 !while ¬ &seq %filename "<end>" 3050!force find-file %filename 3051 !if &seq $status FALSE 3052 write-message "[File read error]" 3053 !break 3054 !endif 3055 beginning-of-file 3056 replace-string "begining" "beginning" 3057 save-file 3058 set %filename #list 3059 !endwhile 3060@end(verbatim) 3061 3062 This while loop will process files until the list is exhausted 3063or there is an error while reading a file. 3064 3065@subsection(!RETURN Directive) 3066 3067 The !RETURN Directive causes the current procedure to exit, 3068either returning to the caller (if any) or to interactive mode. For 3069example: 3070 3071@begin(verbatim) 3072 ; Check the monitor type and set %mtyp 3073 3074 !if &sres "CGA" 3075 set %mtyp 1 3076 !return 3077 !else 3078 set %mtyp 2 3079 !endif 3080 3081 insert-string "You are on a MONOCHROME machine!~n" 3082@end(verbatim) 3083 3084 This directive can also allow the currently executing procedure 3085to return a value which is automatically placed in the $rval environment 3086value and passed back as the procedure's value if the procedure is 3087called by the &call function. For example: 3088 3089@begin(verbatim) 3090store-procedure squared %arg 3091 3092 !return × %arg %arg 3093!endm 3094 3095 set %a &call squared 6 3096@end(verbatim) 3097 3098 This code sets the value of user variable %a to 36, the square 3099of 6. The expresion after the !RETURN directive is evaluated as the 3100value returned by the procedure when used as an argument to the &call 3101function. 3102 3103@section(Local and Global Variables) 3104 3105 Most user variables are considered @ir(global). That means that 3106once they are defined, they can be referenced and changed from any 3107procedure or interactively. If you wish a variable to be defined only 3108within the currently executing procedure, you can declare it as 3109@ir(local). Local variables only can be seen and changed within the 3110procedure where they have been defined. To declare a local variable, use 3111the @b(local) keyword. 3112 3113 local %tempvar 3114 3115 This declares %tempvar as a local user variable within the 3116procedure that the statement executes. Local declarations happen when 3117the statement executes, not automatically when the procedure is entered, 3118so make sure to put the local statement before any line that references 3119that user variable. If the name of a user variable matches an already 3120declared variable, the local variable overides the global variable while 3121still in the function where it is declared. 3122 3123 There is a @ir(global) keyword which can be used to declare a 3124user variable to be global, and to initialize its value to an empty 3125string. Since user variables are created on the fly when they are first 3126referenced, this statement is not strictly needed, but is provided for 3127documentation purposes. 3128 3129@section(Parameters to Procedures) 3130 3131 When you store a procedure, you can follow the procedure name 3132with a list of parameters. These parameters are treated as local 3133variables to the procedure, and their initial values are taken from the 3134list of expresions following the call to that procedure. For example: 3135 3136 store-procedure to-the-power %base %exp 3137 3138 local %result 3139 3140 set %result %base 3141 !while &gre %exp 1 3142 set %result × %result %base 3143 set %exp &sub %exp 1 3144 !endwhile 3145 !return %result 3146 !endm 3147 insert-string to-the-power 2 8 3148 3149 When this example is executed, the number 256 (which is 2^8) is 3150inserted into the current position of the current buffer. The function 3151perameters are treated just like local variables in scope. 3152 3153@chapter(Debugging MicroEMACS Procedures) 3154 3155 @index(debugging)@index($debug)When developing new procedures, 3156it is very convenient to be able to trace their execution to discover 3157errors. The $debug environment variable enables procedure debugging. 3158While this variable is TRUE, emacs will stop at each line it intends to 3159execute and allow you to view it, and issue a number of different 3160commands to help determine how the procedure is executing. 3161 3162 For example, we will step through the procedure which toggles 3163the function key window off. The first thing to do, is to set $debug, 3164using the @b(^XA) @i(set) command. Type ^XA and emacs will prompt you on 3165the command line with "Variable to set: ". Type in "$debug" and press 3166the enter key. Emacs will then ask "Value: ". Type in "TRUE" (in capital 3167letters) and press the enter key. 3168 3169 While macro debugging is enabled (as it is now) emacs will 3170report each time a variable is assigned a value, by displaying the 3171variable and its value on the command line. Right now, 3172 3173@flushleft{((($debug <- TRUE)))} 3174 3175 appears on the command line to tell you that $debug now has been 3176assigned the value of TRUE. Press the space bar to continue. 3177 3178 Now, lets try to debug a macro. Press function key 5 which 3179normally toggles the function key window. The first thing that appears 3180is: 3181 3182@flushleft{<<<[toggle-fkeys]:!if %rcfkeys>>>} 3183 3184 At this point, emacs is waiting for a command. It is prepared 3185to see if the user variable %rcfkeys is TRUE, and execute some lines if 3186they are. Suppose we want to see the value of this variable, type the 3187letter "e" to evaluate an expression. Emacs will prompt with "EXP: ". 3188Type "%rcfkeys" followed by the enter key. Emacs should then respond 3189with "TRUE" to indicate that the function key window is currently on 3190screen. 3191 3192 Press the space bar to allow the !if directive to execute. 3193Emacs will decide that it is TRUE, and then display the next command to 3194execute. 3195 3196@flushleft{<<<[toggle-fkeys]:!goto rcfoff>>>} 3197 3198 Notice emacs tells us what procedure we are currently executing 3199(in this case, the macro bound to toggle-fkeys). Press the space bar 3200again to execute the !goto directive. 3201 3202@flushleft{<<<[toggle-fkeys]:save-window>>>} 3203 3204 Emacs is saving the position of the current window so that it 3205can attempt to return to it after it has brought up the function key 3206window. Press the space bar to continue. Now emacs displays: 3207 3208@flushleft(<<<[toggle-fkeys]:1 next-window>>>) 3209 3210 The @i(next-window) command moves the current point to the next 3211window down, or when it has an argument like now, to that window from 3212the top. This puts the point in the top window, the one with the 3213function key window in it. 3214 3215 Sometimes when debugging we will want to keep track of the value 3216of a variable or expresion. To do this, type a 't' character to 3217@b(t)rack an expression. For now, type n $numwind and hit the return. 3218The display on the command line changes to: 3219 3220@flushleft(<<<[=2][toggle-fkeys]:1 next-window>>>) 3221 3222 The expresion we typed, in this case the environment variable 3223$numwind, is currently evaluated as 2. Press space to execute the 3224@i(next-window) command. Now the command line shows: 3225 3226@flushleft(<<<[=2][toggle-fkeys]:!if &sequal "Function Keys" $cbufname>>>) 3227 3228 This macro is now checking to see if the current buffer is 3229really named "Function Keys". If it is not, then it does not want to 3230delete that window. But since the function window is displayed at the 3231moment, and is at the top of the screen, this statement is true. So we 3232press the space to go on. 3233 3234@flushleft(<<<[=2][toggle-fkeys]:delete-window>>>) 3235 3236 We press the space again and let emacs delete the function key 3237window. Notice the value of $numwind changes to 1 with one less window 3238beying displayed. 3239 3240@flushleft(<<<[=1][toggle-fkeys]:!endif>>>) 3241 3242 We are at the end of the conditional code. Press space again to 3243see: 3244 3245@flushleft(<<<[=1][toggle-fkeys]:!force restore-window>>>) 3246 3247 This restores the point to the window we started in. This 3248command could have failed if the cursor started in the function key 3249window, and that would have normally stopped the macro in its tracks. 3250But the !force directive tells it to ignore any failures. Press the 3251space again: 3252 3253@flushleft(<<<[=1][toggle-fkeys]:write-message "[Function key window OFF]">>>) 3254 3255 Well, this lets the user know what we have done, and that we are 3256done. Press the space again. 3257 3258@flushleft(<<<[=1][toggle-fkeys]:set %rcfkeys FALSE>>>) 3259 3260 Lastly, we set the user variable that the macro uses to tell if 3261it should be turning the function key window on or off to FALSE, letting 3262it know that it is off. When we press the space bar for the last time, 3263the command line shows that variable being set to FALSE. 3264 3265 Anytime while we were debuging, we can hit ? to list the 3266different keystrokes that are legal when debugging. The ^G key will stop 3267a macro immediatly. 3268 3269 If a macro is executing and hits an error (without the !force 3270directive overriding the error), it stops and prints a list of all the 3271macroes it is in the middle of executing, and the lines that those 3272macroes are executing at. You can then go back and examine the offending 3273statement and correct it. 3274 3275 While you are debugging, the 'c' key lets you execute any emacs 3276command interactively. Be carefull with this, you can easily confuse 3277emacs as to where it is or what it is doing by changing things in the 3278middle of a macro. But this is very usefull for testing out changes in 3279variables or the position of the cursor, or any number of environment 3280variables controlling emacs while your macro is running. 3281 3282 Lastly, hitting the current META key while debugging sets $debug 3283to FALSE and finishes running your macro with no more debugging. 3284 3285@chapter(Key Bindings, What they are and why) 3286 3287 One of the features which makes MicroEMACS very adaptable is its 3288ability to use different keystrokes to execute different commands. The 3289process of changing the particular command a key invokes is called 3290@i(rebinding)@index(rebinding). This allows us to make the editor 3291look like other popular editors and programs. 3292 3293 Each command in MicroEMACS has a name which is used for binding 3294purposes. For example, the command to move the cursor down one page is 3295called @i(next-line) and is normally bound to the ^N key. If you 3296decided that you also wanted to use the ^D key to move the cursor down 3297one line, you would use the M-K @i(bind-to-key)@index(bind-to-key) 3298command. EMACS would respond with ": bind-to-key " on the command line 3299and allow you to type in a command name. Then type in the name of the 3300command you want to change, in this case @i(next-line), 3301followed by the <NL> key. EMACS will then wait for you to type in the 3302keys you want to activate the named function. Type a single ^D. From 3303now on, typing ^D will cause EMACS to move down one line, rather than 3304its original function of deleting characters. 3305 3306 To find out the name of a command, consult the list of 3307valid EMACS commands in Appendix B. Also, you can use the ^X? 3308@i(describe-key)@index(describe-key) command to look up the name of a 3309command. Type ^X? and then the key to use that command, and EMACS will 3310show you the name of the command. 3311 3312 After you have experimented with changing your key bindings, you 3313may decide that you want to change some bindings permanently. To have 3314EMACS rebind keys to your pleasure each time you start EMACS, you can 3315add statements to the end of your startup file (@b(emacs.rc) or 3316@b(.emacsrc) depending on the system). For example, 3317 3318bind-to-key next-line ^D 3319 3320 Notice, that control D character in the startup file is 3321represented visibly as an uparrow key followed by a capital D. To know 3322how to represent any keys you want to bind, use the @i(describe-key) 3323command on the key, and use the sequence that is displayed. 3324 3325bind-to-key split-current-window FN1 3326 3327 This example would make function key 1 activate the command 3328that splits the current window in two. 3329 3330 3331 You can also bind your own macroes to keys. You do this by using 3332the ^X^K @ir(macro-to-key) command. This works just like the 3333@i(bind-to-key) command, but binds that key to your own macro, 3334 3335@begin(example) 3336store-procedure insert-stuff 3337 insert-string "<Page Header> page <nn>~n" 3338!endm 3339macro-to-key insert-stuff A-P 3340@end(example) 3341 This example when run causes emacs to insert a page header at 3342the current point whenever the ALT-E combination is typed. 3343 3344 EMACS will let you define a large number of keys, but will report 3345"Binding table FULL!" when it runs out of space to bind keys. Normally 3346EMACS will allow up to 512 key bindings (including approx. 300 originally 3347bound keys). 3348 3349 If you want to get a current listing of all the commands and 3350the keys bound to them, use the @i(describe-bindings) 3351@index(describe-bindings) command. Notice, that this command is not 3352bound to any keys! 3353 3354 There are some @index(key bindings, declined) key bindings 3355that cannot be made without special precautions. Alternative bindings 3356for ^X, META, ^G, and ^U (which bind respectively to ctlx-prefix, 3357meta-prefix, abort-command, and universal-argument) must be made before 3358re-binding ^X, META, ^G, or ^U. The reason is to protect the innocent 3359user from losing the prefix and other commands inadvertantly. 3360@newpage 3361@heading(Chapter @value(chapter) Summary) 3362 3363 In chapter @value(chapter), you learned how change what commands 3364and macroes are executed when a particular key is typed. 3365 3366@begin{verbatim} 3367@u(Key Binding Keystroke Effect) 3368 3369bind-to-key M-K Associate a particular keystroke 3370 with an emacs built in command. 3371macro-to-key ^X^K Associate a particular keystroke 3372 with a user written macro. 3373@end(verbatim) 3374@chapter(Abbreviations and Their Definitions) 3375@tag(abbrevs) 3376 If you have a lot of repetitive typing of large terms, names or 3377strings of any kind, EMACS can make this simpler by looking for simple 3378words or abbreviations that expand to these larger strings. To use this 3379feature, you need to place the buffer you are typing in into @b(ABBREV) 3380mode, and you need to define a table of the abbreviations to expand. 3381 3382 The @i(add-abbrev)@index(add-abbrev) command lets you add an 3383abbreviation EMACS's current table of abbreviations. This command is 3384usually used as part of a procedure, and can be conviniently placed at 3385the end of your emacs.rc startup file. Here is an example abbreviation 3386definition: 3387 3388 add-abbrev "um" "MicroEMACS" 3389 3390 When you type @i(um) into a buffer, it is instantly replaced 3391with the word @i(MicroEMACS). Another way to define a large number of 3392abbreviations at one time is to place them in a buffer, one to a line, 3393with the first space or tab seperating the abbreviation from its 3394definition. Then use the @i(define-abbrevs)@index(define-abbreves) 3395command, giving it the name of that buffer, and it will memorize all the 3396definitions in that buffer. 3397 3398 You can always look at the list of currently defined 3399abbreviations by using the @b(describe-abbrevs) command. If you wish to 3400create a buffer to be used to define abbreviations, the 3401@i(insert-abbrevs)@index(insert-abbrevs) command inserts a table of them 3402into the current buffer at the point. And since these abbreviations take 3403up memory, you can dispose of the lot by issuing the 3404@i(kill-abbrevs)@index(kill-abbreves) command. 3405 3406 If you want EMACS to beep at you when it expands an 3407abbreviation, set the $abbell@index($abbell) environment variable to 3408TRUE. If you wish EMACS to match the definition to your capitalization 3409of the typed in abbreviation, set $abcap to TRUE.@index(abcap) 3410 3411 Normally EMACS will only attempt an abbreviation when it thinks 3412that you have finished typing a word. This means these only happen when 3413you type white space, or the return key. If you want it to be more 3414agressive and attempt completions when the last letter of the 3415abbreviation are typed, set $abquick to TRUE.@index(abquick) 3416 3417 Inside your own preocedures, the &abbrev function will return 3418the definition of any abbreviation given it as an argument. 3419@newpage 3420@heading(Chapter @value(chapter) Summary) 3421 3422 In chapter @value(chapter), you learned how to set up 3423abbreviations and their definitions, and how to control their use. Here 3424is a table of the commands covered in this chapter and their 3425corresponding key bindings: 3426 3427@begin{verbatim} 3428@u(Key Binding Keystroke Effect) 3429 3430add-abbrev (none) Add an abbreviation to the 3431 global table of abbreviations 3432delete-abbrev (none) Delete an abbreviation 3433kill-abbrevs (none) Kill all abbreviations 3434define-abbrevs (none) Add abbreviations in <buffer> 3435 to the global abbreviation table 3436insert-abbrevs (none) Insert the current global 3437 abbreviation table at the point 3438describe-abbevs (none) Pop-up a list of defined abbreviations 3439@end(verbatim) 3440@newpage 3441@appendix(MicroEMACS Command Line Switches and Startup Files) 3442 3443@index(startup files) 3444 When EMACS first executes, it always searches for a file, 3445called @b(.emacsrc) @i(under most UNIX systems) or @b(emacs.rc) @i(on 3446most other systems) @index(emacs.rc) @index(.emacsrc) which it will 3447execute as EMACS macroes before it reads in the named source files. This 3448file normally contains EMACS macroes to bind the function keys to 3449useful functions and load various useful macroes. The contents of this 3450file will probably vary from system to system and can be modified by the 3451user as desired. 3452 3453 When searching for this file, EMACS looks for it in this order. 3454First, it attempts to find a definition for "@b(HOME)" in the 3455environment. It will look in that directory first. Then it searches 3456all the directories listed in the "@b(PATH)" environment variable. Then 3457it looks through a list of predefined standard directories which vary 3458from system to system. Finally, failing all of these, it looks in the 3459current directory. This is also the same method EMACS uses to look up 3460any files to execute, and to find it's help file @b(EMACS.HLP). 3461@index(PATH environment variable) @index(HOME environment variable) 3462@index(Help File) 3463 3464@index(command line) 3465@index(switches) 3466 On computers that call up EMACS via a command line process, such 3467as MSDOS and UNIX, there are different things that can be added to the 3468command line to control the way EMACS operates. These can be switches, 3469which are a dash ('-') followed by a letter, and possible other 3470parameters, or a startup file specifier, which is an at sign '@@' 3471followed by a file name. 3472 3473@begin(description) 3474@@<file>@\This causes the named file to be executed instead of the 3475standard emacs.rc file before emacs reads in any other files. More than 3476one of these can be placed on the command line, and they will be 3477executed in the order that they appear. 3478 3479-C@\The following source files on the command line can be changed (as 3480opposed to being in VIEW mode). This is mainly used to cancel the 3481effects of the -v switch used previously in the same command line. 3482 3483-E@\This flag causes emacs to automatically run the startup file 3484"error.cmd" instead of emacs.rc. This is used by various C compilers for 3485error processing (for example, Mark Williams C). @index(error parsing) 3486 3487-G<num>@\Upon entering EMACS, position the cursor at the <num> line of 3488the first file. 3489 3490-I<var> <value>@\Initialize an EMACS variable with <value>. This can be 3491useful to force EMACS to start in a particular mode. (For example, 3492invoke EMACS with "emacs -i$sres VGA foo.bar" to edit file foo.bar 3493in VGA 50 line mode on an IBM-PC). 3494 3495-K<key>@\This key tells emacs to place the source files in CRYPT 3496@index(CRYPT mode) mode and read it in using <key> as the encryption 3497key. If no key is listed immediately after the -K switch, EMACS will 3498prompt for a key, and not echo it as it is typed. 3499 3500-R@\This places EMACS in "restricted mode"@index(restricted mode) 3501@index(BBS) where any commands allowing the user to read or write any 3502files other than the ones listed on the command line are disabled. Also 3503all commands allowing the user access to the operating system are 3504disabled. This makes EMACS very useful as a "safe" environment for use 3505within other applications and especially used as a remote editor for a 3506BBS or electronic bulletin board system. 3507 3508-S<string>@\After EMACS is started, it automatically searches for 3509<string> in the first source file. 3510 3511-V@\This tells EMACS that all the following sources files on the command 3512line should be in VIEW mode to prevent any changes being made to them. 3513@end(description) 3514@appendix(Command Completion) 3515 3516 Some versions of MicroEMACS will allow you to abbrieviate buffer 3517names, command names and file names as you enter them. To use this, 3518type in the first few characters of the name you wish, and then hit 3519either the space bar, the META key or the TAB key. MicroEMACS will then 3520attempt to look at the list of all the availible names and if there is 3521only one which will fit, it will choose that name. If there are several 3522names that quailify, as many characters as are common to ALL of them 3523will be entered. If there are no possible matches, the bell will ring 3524to indicate MicroEMACS can not complete the command. 3525 3526 For example, if you have several files in your current directory 3527with the following names: 3528 3529@begin(verbatim) 3530 prog1.c 3531 prog1.obj 3532 prog1.exe 3533 prog1.doc 3534 program.one 3535 project.one 3536 test.c 3537 tes 3538@end(verbatim) 3539 3540 and you enter the @b(^X^F) @i(find-file) command, if you type 3541'p' and then hit the space bar, EMACS will respond by typing the 'r' 3542that is common to all the above file names begining with 'p'. If you 3543then type 'ogr' and hit the tab key, EMACS will respond with 'am.one' 3544and automatically hit the enter key for you. 3545 3546 If you were to instead type an 'a' and hit the space bar, EMACS 3547will beep, informing you that there is no possible match. 3548 3549 If you type a 'te' and hit the space bar, EMACS will then type 3550the following 's', but it will not automatically enter it because it is 3551possible you mean to get to the test.c file. 3552 3553 Buffer name, and command name completion is available in all 3554versions of MicroEMACS. File name completion is available on UNIX 3555BSD4.3, the Atari ST, the AMIGA and under MSDOS. 3556@appendix(MicroEMACS Commands) 3557 3558 Below is a complete list of the commands in EMACS, the keys 3559normally used to do the command, and what the command does. Remember, 3560on some computers there may also be additional ways of using a command 3561(cursor keys and special function keys for example). 3562 3563@begin(verbatim) 3564@u(Command Binding Meaning) 3565abort-command ^G This allows the user to abort out of any 3566 command that is waiting for input 3567 3568add-mode ^XM Add a mode to the current buffer 3569 3570add-global-mode M-M Add a global mode for all new buffers 3571 3572append-file ^X^A Write a buffer to the end of a file 3573 3574apropos M-A List out commands whose name contains 3575 the string specified 3576 3577backward-character ^B Move one character to the left 3578 3579begin-macro ^X( Begin recording a keyboard macro 3580 3581beginning-of-file M-< Move to the beginning of the file in 3582 the current buffer 3583 3584beginning-of-line ^A Move to the beginning of the current line 3585 3586bind-to-key M-K Bind a key to a function 3587 3588buffer-position ^X= List the position of the cursor in the 3589 current window on the command line 3590 3591case-region-lower ^X^L Make a marked region all lower case 3592 3593case-region-upper ^X^U Make a marked region all upper case 3594 3595case-word-capitalize M-C Capitalize the following word 3596 3597case-word-lower M-L Lower case the following word 3598 3599case-word-upper M-U Upper case the following word 3600 3601change-file-name ^XN Change the name of the file in the 3602 current buffer 3603 3604change-screen-size (none) Change the number of lines of the screen 3605 currently being used 3606 3607change-screen-width (none) Change the number of columns of the 3608 screen currently being used 3609 3610clear-and-redraw ^L Clear the physical screen and redraw it 3611 3612clear-message-line (none) Clear the command line 3613 3614copy-region M-W Copy the currently marked region into 3615 the kill buffer 3616 3617count-words M-^C Count how many words, lines and 3618 characters are in the current marked region 3619 3620ctlx-prefix ^X Change the key used as the ^X prefix 3621 3622cycle-screens A-C Bring the rearmost screen to front 3623 3624delete-blank-lines ^X^O Delete all blank lines around the cursor 3625 3626delete-buffer ^XK Delete a buffer which is not being 3627 currently displayed in a window 3628 3629delete-mode ^X^M Turn off a mode in the current buffer 3630 3631delete-global-mode M-^M Turn off a global mode 3632 3633delete-next-character ^D Delete the character following the cursor 3634 3635delete-next-word M-D Delete the word following the cursor 3636 3637delete-other-windows ^X1 Make the current window cover the entire 3638 screen 3639 3640delete-previous-character^H Delete the character to the left of the 3641 cursor 3642 3643delete-previous-word M-^H Delete the word to the left of the cursor 3644 3645delete-screen A-D Delete a screen 3646 3647delete-undos M-^U Delete all undo information 3648 3649delete-window ^X0 Remove the current window from the screen 3650 3651describe-bindings (none) Make a list of all legal commands 3652 3653describe-functions (none) Make a list of all legal functions 3654 3655describe-variables (none) Make a list of all environment 3656 and user variables 3657 3658describe-key ^X? Describe what command is bound to a 3659 keystroke sequence 3660 3661detab-region ^X^D Change all tabs in a region to the 3662 equivalent spaces 3663 3664display ^XG Prompts the user for a variable and 3665 displays its current value 3666 3667dump-variables none Places into a buffer the current values 3668 of all environment and user variables 3669 3670end-macro ^X) stop recording a keyboard macro 3671 3672end-of-file M-> Move cursor to the end of the current buffer 3673 3674end-of-line ^E Move to the end of the current line 3675 3676end-of-word (none) Move the point just past the end of 3677 the current word 3678 3679entab-region ^X^E Change multiple spaces to tabs where 3680 possible 3681 3682exchange-point-and-mark ^X^X Move cursor to the last marked spot, 3683 make the original position be marked 3684 3685execute-buffer (none) Execute a buffer as a macro 3686 3687execute-command-line (none) Execute a line typed on the command 3688 line as a macro command 3689 3690execute-file (none) Execute a file as a macro 3691 3692execute-macro ^XE Execute the keyboard macro (play back 3693 the recorded keystrokes) 3694 3695execute-named-command M-X Execute a command by name 3696 3697execute-procedure M-^E Execute a procedure by name 3698 3699execute-program ^X$ Execute a program directly (not through 3700 an intervening shell) 3701 3702exit-emacs ^X^C Exit EMACS. If there are unwritten, 3703 changed buffers EMACS will ask to confirm 3704 3705fill-paragraph M-Q Fill the current paragraph 3706 3707filter-buffer ^X# Filter the current buffer through an 3708 external filter 3709 3710find-file ^X^F Find a file to edit in the current window 3711 3712find-screen A-F Bring the named screen to front, 3713 creating it if needed 3714 3715forward-character ^F Move cursor one character to the right 3716 3717goto-line M-G Goto a numbered line 3718 3719goto-mark M-^G Goto a numbered mark 3720 3721goto-matching-fence M-^F Goto the matching fence 3722 3723grow-window ^X^ Make the current window larger 3724 3725handle-tab ^I Insert a tab or set tab stops 3726 3727hunt-forward A-S Hunt for the next match of the last 3728 search string 3729 3730hunt-backward A-R Hunt for the last match of the last 3731 search string 3732 3733help M-? Read EMACS.HLP into a buffer and display it 3734 3735i-shell ^XC Shell up to a new command processor 3736 3737incremental-search ^XS Search for a string, incrementally 3738 3739indent-region M-( Indent the current region one tab 3740 3741insert-file ^X^I insert a file at the cursor in the 3742 current file 3743 3744insert-space ^C Insert a space to the right of the cursor 3745 3746insert-string (none) Insert a string at the cursor 3747 3748kill-paragraph M-^W Delete the current paragraph 3749 3750kill-region ^W Delete the current marked region, moving 3751 it to the kill buffer 3752 3753kill-to-end-of-line ^K Delete the rest of the current line 3754 3755label-function-key (none) Set the text on a function key label 3756 (HP150 only) 3757 3758list-buffers ^X^B List all existing buffers 3759 3760list-screens A-B List all existing screens 3761 3762list-undos ^XU List current buffer's undo information 3763 3764macro-to-key ^X^K Bind a key to a macro 3765 3766meta-prefix <ESC> Key used to precede all META commands 3767 3768mouse-move-down MSa 3769 3770mouse-move-up MSb 3771 3772mouse-resize-screen MS1 3773 3774mouse-region-down MSe 3775 3776mouse-region-up MSf 3777 3778move-window-down ^X^N Move all the lines in the current window down 3779 3780move-window-up ^X^P Move all the lines in the current window up 3781 3782name-buffer M-^N Change the name of the current buffer 3783 3784narrow-to-region ^X< hides all text not in the current region 3785 3786newline ^M Insert a <NL> at the cursor 3787 3788newline-and-indent ^J Insert a <NL> at the cursor and indent 3789 the new line the same as the preceding line 3790 3791next-buffer ^XX Bring the next buffer in the list into 3792 the current window 3793 3794next-line ^N Move the cursor down one line 3795 3796next-page ^V Move the cursor down one page 3797 3798next-paragraph M-N Move cursor to the next paragraph 3799 3800next-window ^XO Move cursor to the next window 3801 3802next-word M-F Move cursor to the beginning of the 3803 next word 3804 3805nop (none) Does nothing 3806 3807open-line ^O Open a line at the cursor 3808 3809overwrite-string (none) Overwrite a string at the cursor 3810 3811pipe-command ^X@@ Execute an external command and place 3812 its output in a buffer 3813 3814pop-buffer (none) Display a buffer temporarily, paging 3815 3816previous-line ^P Move cursor up one line 3817 3818previous-page ^Z Move cursor up one page 3819 3820previous-paragraph M-P Move back one paragraph 3821 3822previous-window ^XP Move the cursor to the last window 3823 3824previous-word M-B Move the cursor to the beginning of the 3825 word to the left of the cursor 3826 3827print (none) Display a string on the command line 3828 (a synonim to write-message) 3829 3830query-replace-string M-^R Replace all of one string with another 3831 string, interactively querying the user 3832 3833quick-exit M-Z Exit EMACS, writing out all changed buffers 3834 3835quote-character ^Q Insert the next character literally 3836 3837read-file ^X^R Read a file into the current buffer 3838 3839redraw-display M-^L Redraw the display, centering the 3840 current line 3841 3842remove-mark (none) Remove a numbered mark 3843 3844resize-window ^XW Change the number of lines in the 3845 current window 3846 3847restore-window (none) Move cursor to the last saved window 3848 3849replace-string M-R Replace all occurrences of one string 3850 with another string from the cursor 3851 to the end of the buffer 3852 3853reverse-incremental-search ^XR Search backwards, incrementally 3854 3855run M-^E Execute a named procedure 3856 3857save-file ^X^S Save the current buffer if it is changed 3858 3859save-window (none) Remember current window (to restore later) 3860 3861scroll-next-up M-^Z Scroll the next window up 3862 3863scroll-next-down M-^V Scroll the next window down 3864 3865search-forward ^S Search for a string 3866 3867search-reverse ^R Search backwards for a string 3868 3869select-buffer ^XB Select a buffer to display in the 3870 current window 3871 3872set ^XA Set a variable to a value 3873 3874set-encryption-key M-E Set the encryption key of the current buffer 3875 3876set-mark Set the mark 3877 3878shell-command ^X! Causes an external shell to execute 3879 a command 3880 3881show-files (none) Pop up a list of files from the 3882 specified directory 3883 3884shrink-window ^X^Z Make the current window smaller 3885 3886source (none) Execute a file as a macro 3887 3888split-current-window ^X2 Split the current window in two 3889 3890store-macro (none) Store the following macro lines to a 3891 numbered macro 3892 3893store-procedure (none) Store the following macro lines to a 3894 named procedure 3895 3896transpose-characters ^T Transpose the character at the cursor 3897 with the character to the left 3898 3899trim-region ^X^T Trim any trailing white space from a region 3900 3901unbind-key M-^K Unbind a key from a function 3902 3903undent-region M-) Remove a leading indent from a region 3904 3905undo ^_ Undo the last editing operation 3906 3907universal-argument ^U Execute the following command 4 times 3908 3909unmark-buffer M-~ Unmark the current buffer (so it is 3910 no longer changed) 3911 3912update-screen (none) Force a screen update during macro execution 3913 3914view-file ^X^V Find a file,and put it in view mode 3915 3916widen-from-region ^X> restores hidden text (see narrow-to-region) 3917 3918wrap-word (none) Wrap the current word, this is an 3919 internal function 3920 3921write-file ^X^W Write the current buffer under a new 3922 file name 3923 3924write-message (none) Display a string on the command line 3925 3926yank ^Y yank the kill buffer into the current 3927 buffer at the cursor 3928@end(verbatim) 3929@appendix(MicroEMACS Bindings) 3930 3931 Below is a complete list of the key bindings used in MicroEMACS. 3932This can be used as a wall chart reference for MicroEMACS commands. 3933 3934@begin(verbatim) 3935@center(@b[Default Key Bindings for MicroEmacs 4.0]) 3936 3937 ^A Move to start of line ESC A Apropos (list some commands) 3938 ^B Move backward by characters ESC B Backup by words 3939 ^C Insert space ESC C Initial capitalize word 3940 ^D Forward delete ESC D Delete forward word 3941 ^E Goto end of line ESC E Reset Encryption Key 3942 ^F Move forward by characters ESC F Advance by words 3943 ^G Abort out of things ESC G Go to a line 3944 ^H Backward delete 3945 ^I Insert tab/Set tab stops 3946 ^J Insert <NL>, then indent 3947 ^K Kill forward ESC K Bind Function to a key 3948 ^L Refresh the screen ESC L Lower case word 3949 ^M Insert <NL> ESC M Add global mode 3950 ^N Move forward by lines ESC N Goto End paragraph 3951 ^O Open up a blank line 3952 ^P Move backward by lines ESC P Goto Begining of paragraph 3953 ^Q Insert literal ESC Q Fill current paragraph 3954 ^R Search backwards ESC R Search and replace 3955 ^S Search forward ESC S Suspend (BSD only) 3956 ^T Transpose characters 3957 ^U Repeat command four times ESC U Upper case word 3958 ^V Move forward by pages ESC V Move backward by pages 3959 ^W Kill region ESC W Copy region to kill buffer 3960 ^Y Yank back from killbuffer ESC X Execute named command 3961 ^Z Move backward by pages ESC Z Save all buffers and exit 3962 ^_ Undo last editing operation 3963 3964 ESC ^C Count words in region ESC ~ Unmark current buffer 3965 ESC ^E Execute named procedure 3966 ESC ^F Goto matching fence ESC ! Reposition window 3967 ESC ^H Delete backward word ESC < Move to start of buffer 3968 ESC ^K Unbind Key from function ESC > Move to end of buffer 3969 ESC ^L Reposition window ESC . Set mark 3970 ESC ^M Delete global mode ESC space Set mark 3971 ESC ^N Rename current buffer ESC rubout Delete backward word 3972 ESC ^R Search & replace w/query rubout Backward delete 3973 ESC ^S Source command file 3974 ESC ^U Delete undo information 3975 ESC ^V Scroll next window down 3976 ESC ^W Delete Paragraph 3977 ESC ^X Execute command line 3978 ESC ^Z Scroll next window up 3979 3980 ^X < Narrow-to-region ^X ? Describe a key 3981 ^X > Widen-from-region ^X ! Run 1 command in a shell 3982 ^X = Show the cursor position ^X @@ Pipe shell command to buffer 3983 ^X ^ Enlarge display window ^X # Filter buffer thru shell filter 3984 ^X 0 Delete current window ^X $ Execute an external program 3985 ^X 1 Delete other windows ^X ( Begin macro 3986 ^X 2 Split current window ^X ) End macro 3987 ^X A Set variable value 3988 ^X ^B Display buffer list ^X B Switch a window to a buffer 3989 ^X ^C Exit MicroEMACS ^X C Start a new command processor 3990 ^X ^D Detab line ^X D Suspend MicroEMACS (UNIX only) 3991 ^X ^E Entab line ^X E Execute macro 3992 ^X ^F Find file 3993 ^X ^I Insert file 3994 ^X ^K Bind Macro to a key ^X K Delete buffer 3995 ^X ^L Lower case region 3996 ^X ^M Delete Mode ^X M Add a mode 3997 ^X ^N Move window down ^X N Rename current filename 3998 ^X ^O Delete blank lines ^X O Move to the next window 3999 ^X ^P Move window up ^X P Move to the previous window 4000 ^X ^R Get a file from disk ^X R Incremental reverse search 4001 ^X ^S Save current file ^X S Incremental forward search 4002 ^X ^T Trim line 4003 ^X ^U Upper case region ^X U List undo information 4004 ^X ^V View file 4005 ^X ^W Write a file to disk ^X W resize Window 4006 ^X ^X Swap "." and mark ^X X Use next buffer 4007 ^X ^Z Shrink window ^X Z Enlarge display window 4008 4009@u(Usable Modes) 4010ABBREV Enable abbreviation expantions 4011ASAVE Save the file every 256 inserted characters 4012CMODE Change behavior of some commands to work better with C 4013CRYPT Current buffer will be encrypted on write, decrypted on read 4014EXACT Exact case matching on search strings 4015MAGIC Use regular expression matching in searches 4016OVER Overwrite typed characters instead of inserting them 4017REP Similar to OVER, handles double-byte characters and tabs differently 4018SPELL Invoke MicroSPELL to check for spelling errors 4019VIEW Read-Only mode where no modifications are allowed 4020WRAP Lines going past right margin "wrap" to a new line 4021 4022WHITE/CYAN/MAGENTA/YELLOW/BLUE/RED/GREEN/BLACK/GREY/GRAY/LRED/LGREEN/LYELLO/LBLUE/LMAGENTA/LCYAN Sets foreground color 4023white/cyan/magenta/yellow/blue/red/green/black/grey/gray/lred/lgreen/lyello/lblue/lmagenta/lcyan Sets background color 4024@end(verbatim) 4025@newpage 4026@appendix(Numeric Arguments to Commands) 4027@index(numeric arguments) 4028 4029 In general, preceding a MicroEMACS command with a numeric argument 4030@b(n) causes the command to be executed @b(n) times. However, there 4031are a great many commands for which this has no effect, simply because 4032it would make no sense for the command to be executed more than once. 4033There are also commands that take advantage of the numeric arguments to 4034alter their behavior subtly or unsubtly. The following is a list of 4035these commands. Commands that are not affected at all by numeric 4036arguments are listed afterwards. 4037 4038@begin(description) 4039@index(backward-character) 4040backward-character@\A negative argument invokes @i(forward-character). 4041 4042@index(change-screen-size) 4043change-screen-size@\With no arguments, the number of rows defaults to 4044the largest. Otherwise, set the screen size to @b(n). 4045 4046@index(change-screen-width) 4047change-screen-width@\With no arguments, the number of columns defaults to 4048the largest. Otherwise, set the screen width to @b(n). 4049 4050@index(clear-and-redraw) 4051clear-and-redraw@\With an argument, centers the window around the 4052current cursor position. 4053 4054@index(delete-next-character) 4055delete-next-character@\A negative argument invokes 4056@i(delete-previous-character). 4057 4058@index(delete-next-word) 4059delete-next-word@\With an argument of 0, will not delete the whitespace 4060trailing the deleted word. A negative argument will cause nothing to 4061happen. 4062 4063@index(delete-previous-character) 4064delete-previous-character@\A negative argument invokes 4065@i(delete-next-character). 4066 4067@index(delete-previous-word) 4068delete-previous-word@\An negative or zero argument will cause nothing to 4069happen. 4070 4071@index(detab-region) 4072detab-region@\Without an argument, @i(detab-region) changes hard tabs to 4073spaces in the lines between the mark and the cursor. With an argument 4074@b(n), the commands detab @b(n) lines - forward if @b(n) is positive, 4075backwards if not. 4076 4077@index(end-of-word) 4078end-of-word@\A negative argument invokes @i(next-word). 4079 4080@index(entab-region) 4081entab-region@\Without an argument, @i(entab-region) changes spaces to 4082hard tabs in the lines between the mark and the cursor. With an 4083argument @b(n), the commands entab @b(n) lines - forward if @b(n) is 4084positive, backwards if not. 4085 4086@index(exchange-point-and-mark) 4087exchange-point-and-mark@\Swap the current cursor position and mark 4088number @b(n). Without an argument, @b(n) defaults to 0. 4089 4090@index(exit-emacs) 4091exit-emacs@\Providing a numeric argument @b(n) causes two things to 4092happen. First, no checking for modified buffers will occur. Second, 4093MicroEMACS exits with a status of @b(n). 4094 4095@index(forward-character) 4096forward-character@\A negative argument invokes @i(backward-character). 4097 4098@index(goto-line) 4099goto-line@\An argument @b(n) will be taken as the line number to go to. 4100Without an argument, you will be asked for a line number. In either 4101case, the line number must be 1 or greater. 4102 4103@index(goto-mark) 4104goto-mark@\Go to mark number @b(n). Without an argument, @b(n) 4105defaults to 0. 4106 4107@index(grow-window) 4108grow-window@\A negative argument invokes @i(shrink-window). An argument 4109of 0 causes no action. 4110 4111@index(handle-tab) 4112handle-tab@\Without an argument, @i(handle-tab) deals with the tab 4113character, whether it should be a single "hard" tab, or expanded as 4114spaces. With an argument @b(n), $softtab is set to @b(n). 4115 4116@index(hunt-backward) 4117hunt-backward@\The command will hunt @b(n) times. The command will 4118report failure if it cannot find its pattern the @b(nth) time, even if 4119has found an occurrence of the pattern before number @b(n). A negative 4120argument invokes @i(hunt-forward). 4121 4122@index(hunt-forward) 4123hunt-forward@\The command will hunt @b(n) times. The command will 4124report failure if it cannot find its pattern the @b(nth) time, even if 4125has found an occurrence of the pattern before number @b(n). A negative 4126argument invokes @i(hunt-backward). 4127 4128@index(kill-to-end-of-line) 4129kill-to-end-of-line@\With no argument @b(n), the command deletes all 4130characters to the end of the line. If it is already at the end of the 4131line, it will delete the newline. With a positive @b(n) as an 4132argument, the command will delete @b(n) complete lines, newline 4133character and all, starting from the cursor. With @b(n) equal to zero, 4134the command deletes all text from the cursor to the beginning of the 4135line, but will not delete past the newline character. A negative @b(n) 4136is illegal. 4137 4138@index(list-buffers) 4139list-buffers@\With a numeric argument, INVISIBLE buffers are also 4140listed. 4141 4142@index(move-window-down) 4143move-window-down@\With a negative argument, invokes @i(move-window-up). 4144 4145@index(move-window-up) 4146move-window-up@\With a negative argument, invokes @i(move-window-down). 4147 4148@index(next-buffer) 4149next-buffer@\With an argument @b(n), the @b(nth) buffer after the 4150current one is selected, and read in if necessary. Any buffers in 4151between the current buffer and the target buffer that have not yet been 4152read in are read. 4153 4154@index(next-line) 4155next-line@\A negative argument invokes @i(previous-line). 4156 4157@index(next-page) 4158next-page@\Without an argument, the window is scrolled forward by a 4159full page. With an argument @b(n), the window is scrolled forwards by 4160@b(n) lines. The cursor is placed on the upper left hand corner. 4161Negative arguments invoke @i(previous-page). 4162 4163@index(next-paragraph) 4164next-paragraph@\A negative argument invokes @i(previous-paragraph). 4165 4166@index(next-window) 4167next-window@\With a positive argument @b(n), the @b(nth) window from 4168the top becomes the working window. With a negative argument, the 4169@b(nth) window from the bottom becomes the working window. 4170 4171@index(next-word) 4172next-word@\A negative argument invokes @i(previous-word). 4173 4174@index(pop-buffer) 4175pop-buffer@\Without an argument, the buffer is simply displayed in its 4176pop-up screen. With an argument, the buffer is not only displayed, but 4177also given the attribute INVISIBLE. 4178 4179@index(previous-line) 4180previous-line@\A negative argument invokes @i(next-line). 4181 4182@index(previous-page) 4183previous-page@\Without an argument, the window is scrolled backward by a 4184full page. With an argument @b(n), the window is scrolled backwards by 4185@b(n) lines. The cursor is placed on the upper left hand corner. 4186Negative arguments invoke @i(next-page). 4187 4188@index(previous-paragraph) 4189previous-paragraph@\A negative argument invokes @i(next-paragraph). 4190 4191@index(previous-window) 4192previous-window@\With a positive argument @b(n), the @b(nth) window from 4193the bottom becomes the working window. With a negative argument, the 4194@b(nth) window from the top becomes the working window. 4195 4196@index(previous-word) 4197previous-word@\A negative argument invokes @i(next-word). 4198 4199@index(query-replace-string) 4200query-replace-string@\With a numeric argument, @b(n) occurrences of the 4201search string may be replaced, depending upon the user's response. The 4202count is based on the number of occurrences found, not the number of 4203positive responses from the user. 4204 4205@index(quick-exit) 4206quick-exit@\Saves all modifed buffers, and exits with a status of @b(n). 4207 4208@index(redraw-display) 4209redraw-display@\With no argument, or when @b(n) is 0, the window 4210is adjusted so that the cursor is in the center. When @b(n) is 4211positive, the window is adjusted so that the cursor is on the @b(nth) 4212line of the screen. When @b(n) is negative, the window is adjusted so 4213that the cursor is on the last line of the window, regardless of the 4214magnitude of @b(n). 4215 4216@index(remove-mark) 4217remove-mark@\Remove mark number @b(n). Without an argument, @b(n) 4218defaults to 0. 4219 4220@index(replace-string) 4221replace-string@\Will replace @b(n) occurrences of the search string with 4222the replacement string. Otherwise, with no argument, all occurrences 4223from the cursor position to the end of file are replaced. 4224 4225@index(resize-window) 4226resize-window@\Requires an argument which must be positive. 4227 4228@index(scroll-next-down) 4229scroll-next-down@\A negative argument invokes @i(scroll-next-up). 4230 4231@index(scroll-next-up) 4232scroll-next-up@\A negative argument invokes @i(scroll-next-down). 4233 4234@index(search-forward) 4235search-forward@\The command will search @b(n) times. The command will 4236report failure if it cannot find its pattern the @b(nth) time, even if it 4237has found an occurrence of the pattern before number @b(n). A negative 4238argument invokes @i(search-reverse). 4239 4240@index(search-reverse) 4241search-reverse@\The command will search @b(n) times. The command will 4242report failure if it cannot find its pattern the @b(nth) time, even if 4243has found an occurrence of the pattern before number @b(n). A negative 4244argument invokes @i(search-forward). 4245 4246@index(select-buffer) 4247select-buffer@\Without an argument, the buffer is simply displayed in 4248the window. With an argument, the buffer is not only displayed, but 4249also given the attribute INVISIBLE. 4250 4251@index(set) 4252set@\If using the @i(set) command interactively, preceding the command with 4253a numeric argument then makes it unecessary for the command to ask for 4254the variable's value (it will still ask for the variable's name). If 4255used in a command line, then the command 4256 4257@begin(verbatim) 4258 set <variable name> <number> 4259@end(verbatim) 4260 4261is identical to 4262 4263@begin(verbatim) 4264 <number> set <variable name> 4265@end(verbatim) 4266 4267@index(set-mark) 4268set-mark@\Set mark number @b(n). Without an argument, @b(n) defaults to 42690. 4270 4271@index(shrink-window) 4272shrink-window@\A negative argument invokes @i(grow-window). An argument 4273of 0 causes no action. 4274 4275@index(split-current-window) 4276split-current-window@\With @b(n) = 1, the new upper window becomes the 4277current window. Any other numeric argument makes the new lower 4278window the current window. With no argument, the current window becomes 4279the new upper or lower window depending upon whether the cursor was in 4280the upper or lower half of the old window. 4281 4282@index(store-macro) 4283store-macro@\Since macroes are numbered, a numeric argument must be 4284provided. These numbered macroes are being phased out in preference for 4285named macroes. 4286 4287@index(store-procedure) 4288store-procedure@\If the command is provided a numeric argument, it will 4289assume that @i(store-macro) is actually being called. 4290 4291@index(trim-region) 4292trim-region@\Without an argument, @i(trim-region) removes spaces and 4293tabs from the end of the lines between the mark and the cursor. With an 4294argument @b(n), the commands trim @b(n) lines - forward if @b(n) is 4295positive, backwards if not. 4296@end(description) 4297@appendixsection(Commands unaffected by numeric arguments.) 4298@begin(col3) 4299abort-command 4300add-global-mode 4301add-mode 4302append-file 4303apropos 4304back-from-tag-word 4305begin-macro 4306beginning-of-file 4307beginning-of-line 4308bind-to-key 4309buffer-position 4310case-region-lower 4311case-region-upper 4312change-file-name 4313clear-message-line 4314copy-region 4315count-words 4316cycle-screens 4317delete-blank-lines 4318delete-buffer 4319delete-global-mode 4320delete-mode 4321delete-other-windows 4322delete-screen 4323delete-undos 4324delete-window 4325describe-bindings 4326describe-functions 4327describe-key 4328describe-variables 4329display 4330end-macro 4331end-of-file 4332end-of-line 4333execute-command-line 4334execute-program 4335fill-paragraph 4336filter-buffer 4337find-file 4338find-screen 4339goto-matching-fence 4340help 4341i-shell 4342incremental-search 4343insert-file 4344kill-region 4345list-undos 4346macro-to-key 4347mouse-move-down 4348mouse-move-up 4349mouse-region-down 4350mouse-region-up 4351mouse-resize-screen 4352name-buffer 4353narrow-to-region 4354nop 4355pipe-command 4356print 4357re-tag-word 4358read-file 4359restore-window 4360reverse-incremental-search 4361save-file 4362save-window 4363set-encryption-key 4364shell-command 4365suspend-emacs 4366tag-word 4367transpose-characters 4368unbind-key 4369unmark-buffer 4370update-screen 4371view-file 4372widen-from-region 4373wrap-word 4374write-file 4375write-message 4376@end(col3) 4377@newpage 4378@appendix(Supported machines) 4379 4380 The following table lists all the hardware/compilers for which I 4381currently support MicroEMACS. This is not exclusive of all machines 4382which MicroEMACS will run on, but I have either run it myself, or had a 4383first hand report of it running. 4384 4385@begin(verbatim) 4386@u(Hardware OS Compiler Comments) 4387VAX 780 UNIX V5 native 4388 BSD 4.2 native job control supported 4389 VMS native SMG & ANSI support 4390 4391SUN SUNOS 3 & 4 native 4392 gcc 4393 4394NCR Tower UNIX V5 native 4395 4396IBM-RT PC BSD 4.3 native 4397 AIX native 4398 4399HP9000 UNIX V5 native 4400 4401IBM-PC MSDOS 3.2 LATTICE 3 Large CODE/Large DATA 4402 and above AZTEC 3.4e Large CODE/Large DATA 4403 TURBO C 2.0 LARGE memory model 4404 MSC 6.0 4405 *MWC 86 4406 SCO XENIX native 4407 FREEBSD 2.1 GCC 4408 Windows 3.1 MSC 6.0 4409 WINDOWS 95 Visual C++ 4.1 4410 WINDOWS NT Visual C++ 4.1 4411 4412HP150 MSDOS Lattice 2.15 Function key labels 4413 Turbo C 2.0 for the touch screen 4414 4415HP110 MSDOS Lattice 2.15 4416 Aztec 3.4e 4417 Turbo C 2.0 4418 4419*Data General 10 4420 MSDOS Lattice 2.1 Texas Instruments Professional 4421 MSDOS Lattice 2.15 4422 4423Amiga Intuition Lattice 3.03 4424 Aztec 3.6 4425 4426ST520 TOS Mark Williams C Spawns under MSH 4427 Lattice 3.1 (no shell commands) 4428 4429Fujitsu FMR MSDOS MSC 6.0 4430 series 4431 4432NEC 9800 MSDOS Turbo 2.0 Function key support 4433 series MSC 6.0 4434 4435HP3000 series MPE native 4436 4437@u[Systems to be supported (IE some code is already written:)] 4438Macintosh System 7 Lightspeed C 4439 4440*means that I do not own or have access to the listed compiler and/or 4441 machine and must rely upon others to help support it. 4442@end(verbatim) 4443@newpage 4444@appendix(Function Keys) 4445 4446 All environments now support a set of machine independant 4447bindings for function keys. Below is a list of these bindings (not all 4448of these are supported on all systems). 4449 4450@begin(verbatim) 4451 Function keys in MicroEmacs 4452 4453 function Function ^function Alt-function 4454 f1) FN1 S-FN1 FN^1 A-FN1 4455 f2) FN2 S-FN2 FN^2 A-FN2 4456 f3) FN3 S-FN3 FN^3 A-FN3 4457 f4) FN4 S-FN4 FN^4 A-FN4 4458 f5) FN5 S-FN5 FN^5 A-FN5 4459 f6) FN6 S-FN6 FN^6 A-FN6 4460 f7) FN7 S-FN7 FN^7 A-FN7 4461 f8) FN8 S-FN8 FN^8 A-FN8 4462 f9) FN9 S-FN9 FN^9 A-FN9 4463f10) FN0 S-FN0 FN^0 A-FN0 4464 4465home) FN< FN^< 4466CsUp) FNP FN^P 4467PgUp) FNZ FN^Z 4468CsLf) FNB FN^B 4469 5 ) 4470CsRt) FNF FN^F 4471 End) FN> FN^> 4472CsDn) FNN FN^N 4473PgDn) FNV FN^V 4474 Ins) FNC FN^C 4475 Del) FND FN^D 4476@end(verbatim) 4477@newpage 4478@appendix(Machine Dependent Notes) 4479 4480 This appendix lists some notes specific to individual 4481implementations of MicroEMACS. Every attempt has been made to allow 4482EMACS to be identical on all machines, but we have also tried to take 4483advantage of function keys, cursor keys, mice, and special screen modes 4484where possible. 4485 4486@appendixsection(IBM-PC/XT/AT and its clones) 4487 4488 The IBM-PC family of computers is supported with a variety of 4489different display adapters. EMACS will attempt to discover what adapter 4490is connected and use the proper driver for it. Below is a list of the 4491currently supported video adapters: 4492 4493@begin(verbatim) 4494@u(Adapter $sres Original mode used) 4495Monochrome Graphics Adapter MONO MONO 4496Color Graphics Adapter CGA CGA 4497 CGA40 CGA40 4498Enhanced Graphics Adapter EGA CGA 4499Video Graphics Adapter VGA CGA 4500 VGA12 4501@end(verbatim) 4502 4503 If a driver for a Microsoft compatable mouse is installed on the 4504system, EMACS will use the mouse in text mode and allow the user all the 4505standard mouse functions. The mouse cursor will appear to be a block of 4506color in the color opposite of it's background. 4507 4508 EMACS also takes advantage of various function keys and the keys 4509on the keypad on an IBM-PC. The function keys are initially not bound 4510to any particular functions (except by the emacs.rc startup file), but 4511the keypad keys do default to the following: 4512 4513@begin(verbatim) 4514@u(Keypad key Function) 4515Home beginning-of-file 4516CSRS UP previous-line 4517Pg Up previous-page 4518CSRS LEFT backward-character 4519CSRS RIGHT forward-character 4520End end-of-file 4521CSRS DOWN next-line 4522Pg Dn Next-page 4523@end(verbatim) 4524 4525 All these special keys are indicated in EMACS macroes by use of 4526the @b(FN) prefix. Below is a list of many of the keys and the codes 4527used to specify them. Also the codes may be gotten by using the 4528describe-key (^X ?) command on the suspect key. 4529 4530@flushleft(@b[Compiling under TURBO C]) 4531 4532 To compile MicroEMACS under TURBO C, set the TURBO integrated 4533environment with the following options: 4534 4535 Memory model LARGE 4536 Floating point NONE 4537 Default char type UNSIGNED 4538 Data alignment BYTE 4539 Merge duplicate strings ON 4540 Standard stack frame off 4541 Test stack overflow off 4542 4543 Optimize for SIZE 4544 Use register optimization ON 4545 Register optimization ON 4546 Jump optimization ON 4547 4548 Initialize segments OFF 4549 Stack warnings OFF 4550 4551 Names: Code names 4552 Segment name * 4553@newpage 4554@appendixsection(Windows 3.1, OS/2, Windows 95 and Windows NT) 4555 4556 On the IBM-PC there is a very nice window oriented version of 4557MicroEMACS prepared by Pierre Perot. It has all the functionality of the 4558character oriented version, but in addition has drop down menus, and 4559mouse functionality more in line with how the mouse is used in these 4560environments. 4561 4562 There is an extensive on-line help facility for the windows 4563version, which can be accessed from the HELP menu when MicroEMACS is 4564running. Much of the CUA style of mousing and editing is provided by an 4565extra startup file, @ir(CUA.CMD), which is run when MicroEMACS for 4566Windows is started. If you prefer the original style of mousing (if, for 4567instance, you work on many platforms) rename the CUA.CMD file to 4568something else. 4569 4570 The windows version has been tested under Windows 3.1, Windows 457195, Windows NT v3.5 and under OS/2 in the windows emulation box. 4572 4573 In addition, there is also a WINDOWS NT console mode version 4574which runs under Windows NT and WIndows 95. This version is recommended 4575for those environments, as its performance (as a 32 BIT application) is 4576much better than the DOS version running in a DOS box on these machines. 4577 4578@appendixsection(HP 150) 4579 4580 This machine from Hewlett Packard is very unusual for an MSDOS 4581machine. It has a touch screen and is very function key oriented. An 4582additional command, @i(label-function-key)@index(label-function-key) 4583allows you to place labels on the on screen function key labels. A 4584numeric argument indicates which function key to label (one through 4585eight) and then the program prompts for a 16 character label, which will 4586be used as two lines of eight characters. To label function key three 4587with "save file" from a macro, you would use: 4588 4589@verbatim(3 label-function-key "save file") 4590 4591 Notice the 4 spaces after "save". This forces "file" to begin on 4592the second line of the label. 4593@newpage 4594@appendixsection(Atari 520/1040ST) 4595 4596 The ATARI ST family of computers have a dual personality. They 4597may use either a monochrome or a color screen. EMACS supports two 4598screen resolutions on each monitor. 4599 4600@center(@b[NOTE]) 4601 4602@i(When you set MicroEMACS up on your system, please remember to 4603install it on the desktop as a GEM application. If you have EMACS set 4604as a TOS application, the mouse will not function properly, and EMACS 4605will alert you to this problem by beeping the bell.) 4606 4607@begin(verbatim) 4608@u(Monitor $sres size #color $palette format) 4609Color LOW 40x25 16 000111222333444555666777 4610 MEDIUM 80x25 4 000111222333 4611Mono HIGH 80x25 2 000 4612 DENSE 80x50 2 000 4613@end(verbatim) 4614 4615 The $palette environment variable can be used to change what 4616color is associated with each color name. With a color monitor, each 4617group of three digits indicates an octal number specifying the RED, 4618GREEN and BLUE levels of that color. Each color digit can vary from 0 4619to 7. For example, the initial setting of $palette in LOW resolution is: 4620 4621@begin(verbatim) 4622 000700070770007707077777 4623 4624 which broken up is: 4625 4626 000 700 070 770 007 707 077 777 4627 4628 which means: 4629 4630 000 Black 4631 700 Red 4632 070 Green 4633 770 Yellow 4634 007 Blue 4635 707 Magenta 4636 077 Cyan 4637 777 White 4638@end(verbatim) 4639 4640 Also the mouse buttons are bound to mouse functions as 4641described in the chapter about mice. The cursor keys and the function 4642keys are bound similarly to IBM-PC. 4643 4644 Files generated by EMACS on the ATARI ST have a single return 4645character at the end of each line, unlike the desktop files which want 4646to have two returns. This makes it display files strangely from GEM's 4647[SHOW] option, but makes the files port to other computers much nicer. 4648When compiling MicroEMACS, the ADDCR symbol in @b(estruct.h) will cause 4649emacs to generate line ending sequences compatible with GEM. 4650 4651 Currently, when operating under the Mark Williams MSH program, 4652EMACS can shell out and perform external commands. This capability will 4653be added later for the Beckmeyer shell and under GEMDOS. 4654@newpage 4655@appendixsection(Amiga 1000) 4656 4657 The Commodore AMIGA 1000 version of MicroEMACS does fully 4658support the mouse, window resizing and the close gadget. It runs in 4659medium resolution, using the colors defined for the workbench. 4660 4661@center(Note about Compiling MicroEMACS) 4662 4663@begin(quotation) 4664 If you are compiling the sources on the AMIGA to produce an 4665executable image, and you are using the Lattice compiler, be sure to 4666give the CLI command 'STACK 40000' before compiling to make sure the 4667compiler has sufficient stack space to successfully complete 4668compilation. 4669@end(quotation) 4670@newpage 4671@appendixsection(UNIX V5, FREEBSD and BSD4.[23]) 4672 4673 MicroEMACS under UNIX utilizes the @b(TERMCAP) @index(termcap) 4674library to provide machine independent screen functions. Make sure that 4675termcap is available and properly set on your account before attempting 4676to use MicroEMACS. 4677 4678 Under systems which support job control, you can use the 4679@b(^XD) @i(suspend-emacs) @index(suspend-emacs) command to place EMACS 4680into the background. This carries a much smaller overhead than bringing 4681up a new shell under EMACS. EMACS will properly redraw the screen when 4682you bring it back to the foreground. 4683 4684 If the symbol VT100 has been set to 1 in the @i(estruct.h) 4685options file, EMACS will recognize the key sequence <ESC>[ as the lead 4686in sequence for the FN function key prefix. 4687 4688 With the addition of some very machine/operating system specific 4689code, EMACS can prevent two or more people from modifying the same file 4690at the same time. @index(file locking) The upper level of a set of 4691functions to provide file locking exist in the source file @b(LOCK.C). 4692It requires two machine specific functions written and linked into EMACS 4693for it to operate properly. 4694 4695@begin(verbatim) 4696 char *dolock(fname) 4697 4698 char *fname; 4699 4700 dolock() locks a file, preventing others from modifying it. If 4701 it succeeds, it returns NULL, otherwise it returns a pointer to 4702 a string in the form "LOCK ERROR: explanation". 4703 4704 char *undolock(fname) 4705 4706 char *fname; 4707 4708 undolock() unlocks a file, allowing others to modifying it. If 4709 it succeeds, it returns NULL, otherwise it returns a pointer to 4710 a string in the form "LOCK ERROR: explanation". 4711@end(verbatim) 4712@newpage 4713@appendixsection(DEC VMS operating system) 4714 4715@flushleft(@b[TERMINALS]) 4716 4717 Depending upon the options set in ESTRUCT.H, MicroEMACS uses 4718either the capabilities of VMS SMG, working with any terminal that is 4719defined in SMGTERMS.TXT or TERMTABLE.TXT (see your SMG manual for more 4720information), or the ANSI escape sequences. Full keyboard support, 4721including function keys, is provided for VT100 and VT200 series 4722compatible terminals. Mouse support is provided under the ANSI version 4723only at this time. Mouse support is provided for the VSII workstation's 4724VT220 terminal emulator, and other terminal emulators that use the same 4725escape sequences for mouse control. (There is some partial support for 4726the BBN BitGraph mouse sequences in the sources, but this is not yet 4727complete). Terminals may have up to 100 lines and 160 columns. 4728 4729 The maximum terminal size is 256 columns and 72 rows. If you 4730run MicroEMACS on a terminal that is larger than this, MicroEMACS will 4731reduce it to these limits while you are editing. 4732 4733@flushleft(@b[Flow control]) 4734 Some terminals will require the use of XON/XOFF flow control 4735when used with MicroEMACS. When XON/XOFF flow control is used, you 4736will not be able to use functions bound to ^S or ^Q, and should use 4737bind-to-key to put these functions on other keys. MicroEMACS does not 4738change the flow control characteristics of your terminal line while it 4739is running. If your terminal requires flow control, you should: 4740 4741 $ SET TERM/HOSTSYNC/TTSYNC 4742 4743 before entering MicroEMACS. If you are on a VSII emulated 4744workstation terminal, are using the SSU multi-session protocol (VT330 4745and VT340 with SSU enabled), or are certain that your terminal does not 4746require XON/XOFF flow control, you should 4747 4748 $ SET TERM /HOSTSYNC/NOTTSYNC 4749 4750 This will allow you to use ^S and ^Q for MicroEMACS commands. 4751Note that if you are using a VSII with VWS V3.2 or later, you must 4752leave the /HOSTSYNC enabled in order for the cross/session cut and 4753paste capability to work properly. 4754 4755 4756@flushleft(@b[KEYBOARD]) 4757 4758 The VMS version understands the LK201 functions of VT200 4759series, vt300 series, and compatible terminals and terminal emulators, 4760and allows you to bind to them as function keys. In addition, the 4761VT100 numeric keypad, in application mode, is available as function 4762keys. MicroEMACS will only put the keypad into application mode for 4763you if the KEYPAD option is set in ESTRUCT.H. In this situation, 4764MicroEmacs will detect your kepad's state, and restore it to that state 4765upon exiting. If MicroEMACS has not been compiled with this option, 4766you may still put the keypad into application mode by issuing the 4767command "SET TERM /APPLICATION" before entering MicroEMACS. 4768 4769@begin(verbatim) 4770@u(VT200 keys) 4771 4772Note that F1 through F5 are local function keys on DEC terminals. 4773 4774F6 = FN6 FIND = FNS 4775FN7 = FN7 INSERT = FNC 4776F8 = FN8 REMOVE = FND 4777F9 = FN9 SELECT = FN@@ 4778F10 = FN0 PREV = FNZ 4779F11 = S-FN1 NEXT = FNV 4780F12 = S-FN2 Arrow Up = FNP 4781F13 = S-FN3 Arrow Down = FNN 4782F14 = S-FN4 Arrow Right = FNF 4783HELP (F15) = S-FN5 Arrow Left = FNB 4784DO (F16) = S-FN6 4785F17 = S-FN7 4786F18 = S-FN8 4787F19 = S-FN9 4788F20 = S-FN0 4789 4790@u(VT100 and VT200 numeric keypad in application mode) 4791 4792PF1 = FN^1 PF2 = FN^2 PF3 = FN^3 PF4 = FN^4 47937 = A-7 8 = A-8 9 = A-9 - = A-- 47944 = A-4 5 = A-5 6 = A-6 , = A-, 47951 = A-1 2 = A-2 3 = A-3 ENTER = A-E 47960 = A-0 . = A-. 4797@end(verbatim) 4798 4799@center(@b[WARNING]) 4800 4801@begin(quotation) 4802 The VMS version contains code for interpreting function keys 4803that are sent as Ansi sequences that begin with the ESC character. 4804Because of this, MicroEMACS cannot process an incoming ESC until it 4805knows what character follows it. This can cause problems with 4806terminating search and replace strings. If you use ESC as the 4807meta-prefix character (which is the default) you must type one 4808additional keystroke following ESC before emacs will recognize that you 4809have edited the search command prompt, and are continuing. (The 4810additional character is processed normally be MicroEMACS, it is NOT 4811discarded.) 4812 4813 MicroEMACS must wait long enough for the network delay 4814that might be involved between seeing the ESC and seeing the 4815characters that follow it. If holding down one of the arrow keys causes 4816characters to drop into your file, then you may want to alter the delay 4817yourself. The logical variable MICROEMACS$SHORTWAIT may be set to vary 4818that delay. The default delay is 400ms (4 tenths of a second). The 4819equivalent value in MICROEMACS$SHORTWAIT is 4000000. 4820@end(quotation) 4821 4822@flushleft(@b[Special case for BBN BItGraph]) 4823 4824 If you are using the BBN BitGraph, execute the following commands 4825before entering MicroEMACS, and you will get mouse support: 4826 4827@begin(verbatim) 4828 $ esc[0,8] = 27 4829 $ microemacs$mouse_enable == esc+":5;6;L"+esc+":0;63;;;;;;;;;9;16;c" 4830 $ microemacs$mouse_disable == esc+":5;1;L"+esc+":0;0c" 4831 $ exit 4832@end(verbatim) 4833 4834 Do NOT do this for any other terminals. 4835 4836@flushleft(@b[Search List for EMACS.RC]) 4837 4838 VMS MicroEMACS will first search logical name MICROEMACS$LIB:, 4839then SYS$LOGIN:, then finally the current directory when looking for 4840startup files or help files. 4841 4842 If desired, MICROEMACS$LIB may be defined to be a VMS search 4843list that first searches a user directory, and then a system directory. 4844 4845 Generally, you should create a private directory where you keep 4846all your .CMD files, and in your LOGIN.COM $DEFINE a logical name to 4847point to this area. 4848 4849 In addition to whatever commands you have in your EMACS.RC file, 4850one command you should certainly include is "set $ssave FALSE". 4851@index($ssave) The "safe save" mechanism, which writes a buffer to a 4852temporary file, deletes the old version of a file, and then moves the 4853temporary file to its permanent name, works wonderfully on most systems, 4854but makes no sense on VMS, which maintains older versions of a file. 4855 4856@flushleft(@b[Using MicroEMACS as a subprocess]) 4857 MicroEmacs can now be kept in a subprocess. You can arrange to 4858start emacs only once in a job, and to re-attach to it each time you 4859want to use it. This is optional. To use this feature, install 4860MicroEMACS in the following way: 4861 4862@begin(verbatim) 48631. MicroEMACS contains two images. ME.EXE is a small program for 4864 starting and stopping the Emacs subprocess. The source for ME. 4865 is in ME.C, and should not be linked into MESHR.EXE. MESHR.EXE 4866 is the actual MicroEMACS image. The name "MESHR" is required for 4867 MAIL/NOTES support, see next section for details. 4868 48692. Make sure that the SYS$SHARE search list includes MESHR.EXE. If you 4870 don't have the privilages to move MESHR.EXE into SYS$SHARE, you 4871 can $ DEFINE the MESHR logical name to be the full name and location of 4872 the MESHR.EXE program. For example, you could store all of these 4873 programs in the MICROEMACS$LIB: search list, and say: 4874 4875 $ DEFINE MESHR microemacs$lib:meshr.exe 4876 48773. Put ME.EXE in MICROEMACS$LIB and the following line in your LOGIN.COM: 4878 4879 $ me :== $microemacs$lib:me 4880 48814. Put a line in your EMACS.RC that will 4882 4883 bind-to-key suspend-emacs ^C ; use your usual exit-emacs key 4884@end(verbatim) 4885 4886 Now, use the "$ ME" command to invoke microemacs. Subseqeuent 4887invocations in the same job will re-use the existing subprocess. You 4888can use the full capabilty of the microemacs command line in the first 4889and in all subsequent invocations of ME. 4890 4891 WARNING: 4892 4893 MicroEMACS will ALWAYS read in new copies of any files you 4894specify on the command line, even if you are already editing it. If 4895you edit a file a second time with the same MicroEMACS, you will get a 4896NEW buffer with ANOTHER copy of the file. The old buffer is still 4897there also. It is easy, in this situation, to accidently edit in a 4898WRONG BUFFER, and if you write out an obsolete buffer, you will lose 4899earlier edits! 4900 4901 This is considered a bug and may be fixed in a later version of 4902MicroEMACS. To avoid this situation, do not specify a file on the 4903command line if MicroEMACS already has that file in a buffer. Use the 4904"find-file" MicroEMACS command instead. 4905 4906 4907 @b(Using MICROEMACS with MAIL and NOTES:) 4908 4909 With VMS V5 and later versions, the MAIL interface to 4910Microemacs is much simplified. With VMS V5, the MESHR.EXE image does 4911NOT have to be installed as a known image to be used as a callable 4912editor from MAIL. Therefore, to use MicroEMACS as your VMS MAIL 4913editor, simply add the following lines to your LOGIN.COM: 4914 4915@begin(verbatim) 4916 $ DEFINE MAIL$EDIT CALLABLE_ME 4917 $ MAIL :== MAIL/EDIT 4918@end(verbatim) 4919 4920 and make sure that the SYS$SHARE search list includes 4921MESHR.EXE. If you don't have privs or permission to move MESHR.EXE 4922into SYS$SHARE, you can $ DEFINE the MESHR logical name to be the full 4923name and location of the MESHR.EXE program. For example, you could 4924store all of these programs in the MICROEMACS$LIB: search list, and 4925say: 4926 4927 $ DEFINE MESHR microemacs$lib:meshr.exe 4928 4929 Note that this is the same location as is required for using kept 4930MicroEMACS. 4931 4932 To abort sending a message, exit MicroEMACS without writing out 4933the mail message file. 4934 4935 To use MicroEMACS as your VAX NOTES editor, issue the following 4936command to VAX NOTES: 4937 4938 NOTES> SET PROFILE/EDIT=(ME,CALL) 4939 4940 Note, if you are still in the dark ages of VMS V4, you will 4941have to either install MESHR as a known image, or following the 4942original "Second way" instructions given in the existing appendix F.6 4943of the older MicroEMACS manual (previous to version 3.10). 4944 4945@flushleft(@b[Second way, as described in older versions]) 4946 4947 In the event that you cannot get your system manager to INSTALL 4948MicroEMACS as known image, you can use the following technique: 4949 4950@begin(verbatim) 49511. In MICROEMACS$LIB:MEMAIL.COM, put the following command file: 4952 4953$! Use on VAX/VMS as MAIL$EDIT for using MicroEMACS as mail editor. 4954$ if "''P1'" .NES. "_NL:" then if "''P1'" .NES. "" then copy 'P1' 'P2' 4955$ define/user sys$input sys$output 4956$ me 'P2' 4957$ exit 4958 4959This file may have come with your MicroEMACS kit. 4960 49612. In your LOGIN.COM, put the following lines: 4962 4963$ me :== $MICROEMACS$LIB:MESHR.EXE ! Assumes meshr.exe is there 4964$ define mail$edit microemacs$lib:me_edit.com 4965 49663. In NOTES, give the command 4967 4968NOTES> SET PROFILE/EDIT=(@@MicroEMACS$lib:me_edit.com,SPAWN) 4969 4970@flushleft(@b[System messages and EMACS]) 4971MicroEMACS will intercept system broadcast messages and display them 4972on the message line after any input from the user. These message are 4973stored in an INVISIBLE buffer named [-messages-]. To view these at your 4974convenience, use the following procedure: 4975 4976@begin(verbatim) 4977; 4978; Show any system messages MicroEMACS may have intercepted. 4979; The numeric prefix of pop-buffer ensures its invisibility. 4980; 4981store-procedure "Show_messages" 4982 1 pop-buffer "[-messages-]" 4983!endm 4984@end(verbatim) 4985 4986@flushleft(@b[Building MicroEMACS for VMS]) 4987 4988The configuration options are set in file estruct.h: 4989 4990- Under the category of "Machine/OS definitions", set VMS to "1" and all 4991others to "0". 4992 4993- Under "Compiler definitions", set all selections to "0". Selecting 4994VMS implies that you are using VAXC. 4995 4996- Under "Special keyboard definitions", be sure "VT100" is set to "0". 4997This option is not required for the VMS version, it is for other 4998systems using ANSI terminal support. VMS in combination with SMG or 4999ANSI already handles the special characteristics of Ansi keyboards. 5000 5001- Under "Terminal Output definitions", set either ANSI or SMG to "1" 5002and all others to "0". As stated previously, only ANSI supports the 5003mouse at this time. 5004 5005- Under "Configuration options", you may select as you wish, with the 5006following notes: 5007 5008 - COLOR support does not exist for VMS, even when using 5009 color workstations. 5010 - MOUSE support should be enabled if you have any VSII 5011 workstations. Only supported under the ANSI driver. 5012 - KEYPAD support recognises whether your keypad is already 5013 in application mode or not, and puts your keypad 5014 in its correct state on exit. 5015 - XNONOFF automatically allows you to use control-S or 5016 control-Q in MicroEMACS, by disabling the TTSYNC 5017 characteristic. This option should not be set if 5018 MicroEMACS might be used on DecStations or VT100s. 5019 It also should not be used with slow terminals or 5020 terminal emulators connected to fast terminal lines. 5021 - RMSIO support should absolutely be used. This option 5022 allows the writing and reading of files in VMS's 5023 variable-length format, as opposed to STREAM-LF, 5024 and cuts down on file writing and reading time by 5025 approximately two thirds. 5026 - OPTMEM support may be used on VMS versions 5.0 and higher. 5027 It substitutes the C library's memory allocation 5028 calls for the native VAX calls, and gives a speed 5029 improvement. 5030@end(verbatim) 5031 5032 If you have MMS, you can use the supplied DESCRIP.MMS to build 5033MicroEMACS. Otherwise, the command file MEMAKE.COM has been provided. 5034These files assume that you are using SMG as your terminal driver. If 5035you are using ANSI, then you must replace SMG with ANSI in the command 5036and opt files. If you do not have MMS or are missing MEMAKE.COM, 5037simply compile each module with "CC", and link with the command: 5038 5039 $ LINK MESHR/OPTION/SHARE 5040 5041 Note that the executable filename must end in "SHR" in order 5042for MicroEMACS to be used as a callable editor from MAIL or NOTES. 5043(Method 1 above.) 5044 5045 If you edit any of the Emacs sources, note that any global or 5046external data must be declared as "noshare" in order for the VMS 5047callable editor support to work properly. This applies to all global 5048data used in the VMS version, but not to routines or to "static "data. 5049The "noshare" declaration is #define'd away on non-VMS systems. If you 5050fail to do this, VMS will not allow you to INSTALL MicroEMACS as a 5051sharable library. 5052@newpage 5053@appendix(Mode Flags) 5054 5055 The two environment variables, $cmode and $gmode, contain a 5056number the corresponds to the modes set for the current buffer and 5057the editor as a whole. These are encoded as the sum of the following 5058numbers for each of the possible modes: 5059 5060@begin(verbatim) 5061WRAP 1 Word wrap 5062CMODE 2 C indentation and fence match 5063SPELL 4 Interactive spell checking (Not Implemented Yet) 5064EXACT 8 Exact matching for searches 5065VIEW 16 Read-only buffer 5066OVER 32 Overwrite mode 5067MAGIC 64 Regular expressions in search 5068CRYPT 128 Encryption mode active 5069ASAVE 256 Auto-save mode 5070REP 512 Character replace mode 5071ABBREV 1024 Abbreviation expantion mode 5072@end(verbatim) 5073 5074 So, if you wished to set the current buffer to have CMODE, 5075EXACT, and MAGIC on, and all the others off, you would add up the values 5076for those three, CMODE 2 + EXACT 8 + MAGIC 64 = 74, and use a 5077statement like: 5078 5079set $cmode 74 5080 5081 or, use the binary or operator to combine the different modes: 5082 5083set $cmode &bor &bor 2 8 64 5084 5085@flushleft(@big[Internal Flags]) 5086 5087 Some of the ways EMACS controls its internal functions can be 5088modified by the value in the $gflags@index($gflags) environment 5089variable. Each bit in this variable will be used to control a 5090different function. 5091 5092@begin(verbatim) 5093GFFLAG 1 If this bit is set to zero, EMACS will not 5094 automatically switch to the buffer of the 5095 first file after executing the startup macroes. 5096GFSDRAW 2 If this bit is set to one, supress redraw events. 5097GFEXIT 4 This bit is set to one while executing the 5098 $exithook. If reset to zero, the exit is canceled. 5099@end(verbatim) 5100 5101@flushleft(@big[Current buffer flags]) 5102 5103 The $cbflags@index($cbflags) environment variable allows the 5104user to modify some of the characteristics of the current buffer. The 5105various characteristics are encoded as the sum of the following 5106numbers: 5107 5108@begin(verbatim) 5109BFINVS 1 Internal invisible buffer 5110BFCHG 2 Changed since last write 5111BFTRUNC 4 buffer was truncated when read 5112BFNAROW 8 buffer has been narrowed 5113@end(verbatim) 5114 5115 Only the invisible and changed flags can be modified by setting 5116the $cbflags variable. The truncated file and narrowed flags are read 5117only. 5118