CS/CE 218 units -*-Outline-*- * Emacs editor advert: powerful display editor, compared to other editors is much easier to: extension and customization (since designed that way) make environments for working with programs many features for programming already built in operations on large features vs. WordPerfect et al, not based around function keys (better for experts) vs. vi, flatter command structure (default is insertion) Q: how do some of the "advanced" features of emacs compare with other editors you may have used? ** how to learn it ------------------- To learn about emacs, best way is to use the tutorial: emacs C-h t (control-h, then t) At any time, can get help by C-h. Exit by C-x C-c. ------------------- For vi users: read the info about "vip" the vi emulation mode allows you to type vi but still use advanced emacs features ** How to describe a computer system a computer system is an abstract data type (ADT) *** Abstract data type state (perhaps several parts or objects) + commands (operations) **** example: rational numbers (rat) ------------- create: int, int -> rat +, -, *, /: rat, rat -> rat =: rat, rat -> bool num, denom: rat -> int -------------- here the state doesn't change **** example: current working directory in Unix each program (process) has a "current working directory" ------------ pwd: void -> pathname observe current working directory cd: pathname -> void change current working directory ------------ here the state only changed as a whole (read, write) **** example: Unix directory ------------ mkdir: pathname -> void create directory rmdir: pathname -> void destroy directory ls: pathname* -> (name -> info) observe directory cp, mv, rm: pathname* -> void change directory ------------ *** Formalization of design **** syntax (external interface, signature of each command) e.g., C-x C-c kills emacs **** semantics (what commands do) what does it *mean* to exit emacs? e.g., Are files saved? Is the user prompted? **** pragmatics (how the system should be used, efficiency issues) Is it better to use regular expression search or normal search? ** State of an editor Q: What should the state of an editor be? What state does emacs show? (distinguish files, buffers, windows) File contents (find-file, save-buffer, save-some-buffers) Buffers default directory (pwd, cwd) name (list-buffers, rename-buffer) buffer contents (scroll-up, scroll-down, etc.) file name (set-visited-file-name, write-file) mode [major, minor] (displayed in mode line, mode commands) clean/written flag [shows as ** when written] (not-modified) point, mark (what-cursor-position, exchange-point-and-mark,...) Window buffer (switch-to-buffer) screen location (split-window-vertically, kill-window, ...) mode line display of clean/written flag display of buffer name display of mode position indication point [location of cursor, before a given character] (...) Global state Echo area (minibuffer window) text for messages/prompts Command History [undo, redo] (repeat-complex-command, undo) Kill Ring (yank, yank-pop, deletion commands) (Mark ring) (Registers) (Buffer selection history) (Key bindings) (Variable values) draw a picture of a window with it's mode line, show what the screen would look like with 2 windows show what happens to the mode line when you make changes, and when you write them out, %% for read-only buffers show the cursor, and where the point is. ** Characters, Keys, and Commands *** characters C-a means press control and (holding it down) then a. M-x means to press "escape" and then x. This is the prefix for invoking a command by its (long) name. Some terminals have a meta key (e.g., "left" on a Sun) so you press that key and at the same time a. e.g., M-x display-time makes the mode line display the time, and if you have mail. C-M-a means to type escape and then C-a. other commands are bound to specific keys, e.g., typing C-v is same as M-x scroll-up which goes up one line. Q: Why do you think it's useful to have commands known by a key and also a long name? (omit) *** Key sequences sequence of characters that specifes a command (key for short) a prefix of a complete key sequence is called a "prefix" e.g., C-x is a prefix of C-x C-f (finds a file) C-x 4 is another prefix (of C-x 4 f) *** key bindings a key is bound to (associated with) a function If C-x C-f is bound to the function find-file, when you type C-x C-f, it runs the function find-file. Q: can the meaning of a key (sequence) be changed easily? (omit) ** running and exiting emacs Q: How do you invoke emacs to start editing an existing file? Q: How do you get out of emacs temporarily, so you can pick up where you left off? How do you get out of emacs (without emacs hanging around)? to really learn it, now you must run the tutorial (omit) ** emacs philosophy Richard Stallman believes software should be free Q: Will free software put programmers out of jobs?