scEmacs Commands
This (long) section displays all scEmacs commands in tabular form. These commands will, for the most part, emulate those in real Emacs. But if you are unfamiliar with Emacs, learn a few basic commands initially and lean more on the mouse for cursor manipulations. There are very many good tutorials for real Emacs, and most of what you learn there will directly apply to scEmacs.
While using scEmacs, Control-h is your friend. It will list all implemented
scEmacs commands in its own little pane! And unlike this tutorial, it will always keep up
with the latest implementation and changes.
| Operations: |
These commands are essential to the operation of scEmacs. The most commonly used being M‑x to execute a named operation. Many, but not all, scEmacs commands will accept a numerical arg. These can even be negative numbers and some commands will change polarity or direction based on these. | |
|---|---|---|
| abort | C-g | Stop current task/mode, get back to normal operations. |
| quit-and-exit | C-x C-c | End scEmacs session, will require confirmation if buffers are modified. |
| exec-from-list | C-M-x | Show command pop-up window. |
| exec-named-cmd | C-x | Prompts (in echo line) for command name to execute. |
| help | C-h | Generates and displays *Info* buffer. Will display the definitive guide to all implemented commands! |
| Numerical Arg | C-u or M-digits |
Enter a number for the next command. Not a named command, just syntax! |
| debug | DEBUG only | Jump into active debugger. Debugger can set breakpoints then resume execution. |
| test-loc-pos | DEBUG only | Test low level positioning routines. Will take too long if buffer has more than 10-15K bytes. Results are written to debugger window (stdout). |
| Cursor & Display: |
scEmacs is fundamentally a cursor-based editor as real Emacs predated mice and
graphics. All editing operations, whether adding or deleting text, generally occur at
the cursor. While it can be re-positioned with the mouse, scEmacs provides many
commands for efficiently moving the cursor using just the keyboard. Horizontal units of movement are: (forward/back or end/beginning)
| |
|---|---|---|
| forward-char | <right>, C-f | Move cursor forward one character. |
| backward-char | <left>, C-b | Move cursor backward one character. |
| forward-word | M-f | Move cursor forward one word. |
| backward-word | M-b | Move cursor backward one word. |
| forward-sentence | M-e | Move cursor to end of sentence. |
| backward-sentence | M-a | Move cursor to beginning of sentence. |
| forward-sexp | C-M-f | Move cursor forward one SExp. This cmd will stall and beep if it cannot balance the parens. Just like RealEmacs, it will not differentiate among different paren types. Unlike RealEmacs, it does not process quotes or skip comments. |
| backward-sexp | C-M-b | Move cursor backward one SExp. |
| go-up | <up>, C-p | Move cursor up one row. A line starts at the beginning of a buffer or after a Linefeed character and continues to the end of the buffer or another Linefeed. A long line displayed on a narrow Pane may wrap around to form multiple rows. Each row is a single horizontal sequence of characters, beginning and ending at the pane margin. |
| go-scroll-up | C-<up> | Move cursor up one row, scroll the pane down 1 row. |
| go-down | <down>, C-n | Move cursor down one row. |
| go-scroll-down | C-<down> | Move cursor down one row, scroll the pane up 1 row. |
| go-line-end | <end>, C-e | Move cursor to the end of the line. |
| go-line-beg | <home>, C-a | Move cursor to the beginning of the line. |
| go-end | C-<end>, M-> | Move cursor to the end of the buffer. |
| go-beg | C-<home>, M-< | Move cursor to the beginning of the buffer. |
| goto-char | M-g c | Move cursor to the numbered (1-based) character and set a mark. If no count arg, prompts for a number on echo line. If cursor is on (or just after) a number, will show it as the default. |
| goto-line | M-g g, M-g l, M-g M-g |
Move cursor to the numbered (1-based) line and set a mark. If no count, prompts for a number on echo line. If cursor is on (or just after) a number, will grab it as the default. |
| next-page | <PageDown>, C-v | Move cursor to the next page. With number N, scrolls the pane N rows. |
| prev-page | <PageUp>, M-v | Move cursor to the previous page. With number N, scrolls the pane N rows. |
| center-page | C-l | Repositions displayed page. First application will scroll the display vertically to center cursor on the pane. If repeated, will scroll to place cursor at the top. The third iteration will scroll to place cursor at the bottom. Subsequent applications will repeat this cycle. Positive N arg will scroll to place cursor N rows below top and negative will scroll to place it N rows above bottom. |
| cursor-info | C-x = | Display cursor information in echo line. Will specify the char under the cursor as well as its buffer Pos and visible pane Col,Row. |
| Mark & Selection: |
Many operations will operate on a selection range, a highlighted region of text between
a mark and the cursor. The traditional practice is to use C-space to set a mark,
then move the cursor ahead or behind it, selecting a region. But it is also common to
select by dragging the mouse. (C‑g (abort) will immediately cancel the selection and
remove the highlighting.) Once selected, the entire region can be deleted, instantly replaced with typed chars, or killed and placed in the killring. (Undo is always available to remedy accidental deletion.) | |
|---|---|---|
| set-mark | C-@, C-space | Place a mark at the cursor potion. scEmacs enters selection mini-mode, so subsequent cursor movements will select the intervening text region. |
| mark-from-list | C-M-z | Displays pop-up showing all current marks. Select one to move cursor to. |
| exchange-point-mark | C-x C-x | Swap position of cursor with last mark. |
| select-all | C-x h | Select entire contents of buffer. Will mark the beginning and position cursor at end. |
| select-word | double-click | Selects word (also whitespace) under mouse. Positions mark at the beginning and cursor at the end. |
| select-line | triple-click | Selects entire line under mouse. Positions mark at the beginning and cursor at the end. |
| Editing: |
The most common ways to change a buffer is to type text in, delete text, or kill
some text and perhaps yank it out in a new location (instead of the more modern
cut/paste). The unique killring mechanism acts as a circular stack of killed text fragments, ready for pasting. C-y (yank) will paste the latest text fragment at the cursor, but immediately subsequent M‑y (yank-pop) commands will swap it for preceding ones from the killring. scEmacs has only a single global killring, shared between all buffers. So it is trivial to kill or copy in one buffer and yank it into another. Unlike kill, delete commands do not store in the killring, so cannot be used to yank text. But Undo will happily replace text removed by either, albeit in its original position and without altering the killring. There are also options to change word case (upper, lower, capitalize) and transpose characters. | |
|---|---|---|
| delete-forward | <delete>, C-d | Delete character under cursor. |
| delete-backward | <backspace> | Delete character before cursor. |
| delete-word-forward | C-Delete>, M-d | Delete from cursor to end of word. |
| delete-word-backward | C-<backspace>, M-<backspace>, M-<delete> | Delete from cursor back to beginning of the word. |
| kill-region | C-w | Remove selected region and place in killring. (Cut!) |
| Copy-region | M-w | Copy selected text to killring, does not alter buffer. (Copy!) |
| kill-line | C-k | Kill from cursor to end of line and place in killring.
|
| Kill-sentence | M-k | Kill from cursor to end of sentence, and place in killring. |
| kill-sexp | C-M-k | Kill from cursor to end of SExp, and place in killring. |
| yank | C-y | Place the top killring entry in the buffer at the cursor. (Paste!) |
| yank-pop | M-y | Replace yanked item with preceding one in killring. M-y can only be issued, and repeated, immediately after C-y. |
| yank-from-list | C-M-y | Displays pop-up of all killring entries. Select an entry to place in buffer at cursor. |
| capitalize-word | M-c | Capitalize word starting at cursor. (Knows Latin accented chars.) |
| upcase-word | M-u | Uppercase word starting at cursor. (Knows Latin accented chars.) |
| downcase-word | M-l | Lowercase word starting at cursor. (Knows Latin accented chars.) |
| transpose-char | C-t | Swap the character under the cursor with the one before it. Will swap the previous 2 characters if cursor is at end of line. Arg of N will move previous char (and cursor) N places forward. (Negative sign of N is ignored.) |
| expand-ligatures | None | Expands ligatures (such as Æ) in entire buffer or just selected text. |
| stuff-tabs | DEBUG only | Stuff multiple lines of Tabs into Buffer. |
| stuff-text | DEBUG only | Stuff multiple lines of generated text into Buffer. |
| Formatting: |
scEmacs provides a number of commands for adding or deleting whitespace, consisting of
space, tab, or linefeed (LF) characters. In Text mode, an insert-tab command
simply adds a tab character, displayed as 1-8 blanks, advancing the column to a tabstop
multiple of 8. Tabs are smarter in Script mode as they conform to programming indentation where tabstops are multiples of 4. Such an insert-tab command will first add enough spaces to advance to a multiple of 4. Then will go back to tabify the preceding spaces, turning as many spaces into tab characters as possible. If an insert-tab is entered in the leading whitespace of a line, it will add enough space to align the first text column with the preceding line (going up N lines to find a non-empty one if necessary) then tabify those spaces. Similarly, the insert-return command will add a linefeed to create a new line in Text mode. But in Script mode, it will also perform an insert-tab to align the new line with its preceding (perhaps N lines up if previous lines are blank). The indent-rigidly command performs en masse indentation of multiple lines. It is commonly used to re-indent selected sections of code that are being nested further in or out. Left and right arrows will move each line in the selected region one space, or one tabstop (multiples of 4 in Script and 8 in Text mode) if the the shift key is held down. Beyond individual lines, formatting text paragraphs is also important. scEmacs can flow or justify paragraphs to the desired fill column. This mechanism is even smart enough to allow for non-alphanumeric line leads, such as comment markers or other decorations. | |
|---|---|---|
| insert-tab | Tab | Inserts a Tab character at cursor. Given arg N, will place N spaces (not Tabs), ignores negative sign. Script mode: will match general programming indentation and will convert spaces in white area to Tab characters (Tabify).
|
| insert-return | <enter> <return> |
Inserts a linefeed character at cursor. Given arg N, will place N linefeeds, ignores negative sign. Script mode: last linefeed will also get Tabs/Spaces to match prev line. |
| open-new-line | C-o | Given arg N, will insert N Ret chars at cursor, ignores neg sign. Cursor position will not change. |
| join-lines | M-^ | Merges lines by deleting whitespace (Space, Tab, Ret) around cursor. Ignores numerical arg. |
| delete-horiz-space | M-\ | Deletes Spaces and Tabs around cursor. If given a numerical arg, only deletes before the cursor. |
| indent-rigidly | C-x Tab | Indents every line in selected region, will Tabify as possible. If called with arg N, will move them N spaces (pos or neg) and exit. Otherwise, will enter mini-mode (like query-replace):
|
| set-fill-column | C-x f | Sets internal FillColumn for fill-paragraph command. Will prompt for value if no numerical arg given. |
| fill-paragraph | M-q | Flows paragraph to FillColumn limit. Will fully justify text if given a numeric arg. Ignores selected region. Allows for whitespace and non-alphanumeric line leader in format. |
| test-justify | DEBUG only | Writes elaborate test of full justification to debug window (stdout). |
| Searching: | scEmacs provides mini-modes for incremental search and query replace. | |
|---|---|---|
| search-forward | C-s | Gets into forward incremental-search mini-mode, from cursor location:
|
| search-backward | C-r | Gets into reverse incremental-search mini-mode, from cursor location. Same as C-s, only going backwards. |
| query-replace | M-% | Prompts user for query-replace mini-mode. (Can only go forward). Provides default pattern and replacement from last use. Finds the next match and prompts user for action:
|
Note: Search, and by extension query-replace, is case insensitive unless one or more uppercase characters are included in the template string. So MyName will only match MyName, but myname will happily match MyName, mYnAmE, etc. In addition to base ASCII, scScript also understands Basic Latin, Latin-1 Supplement, Latin Extended-A, Latin Extended-B, and Latin Extended Additional characters in the Unicode definition (0x0000 to 0x024F and 0x1E00 to 0x1EFF code points). scEmacs therefore understands that É is the uppercase form of é and acts accordingly.
Similarly, search (and query replace) will happily match base ASCII root characters against their accented brethren. So entree will match against entree or entrée. But if given the accented version as template, search (and query replace) will only find identically accented text in the buffer. In that sense, search is normally accent insensitive, unless one or more accented characters are included in the template string.
scEmacs has an expand-ligatures command, but search and query replace are currently not smart enough to match a ligature against its expansion, or vice versa. For example, matching a+e against Æ or ß against ss will fail.
| Undo: |
Every scEmacs buffer stores the sequence of individual changes made to it and can
sequentially unwind and undo these changes. There will be memory limitations, but the
system is efficient enough to provide ample undo capacity in most cases. Importantly,
scEmacs will:
| |
|---|---|---|
| undo | C-/, C-_, C-x u | Reverse the last change made to the buffer! |
| disable-undo | None | Turns off Undo for buffer and releases its memory. Restore with reset-undo. |
| reset undo | None | Releases old Undo memory for buffer (if any), then creates anew. |
| print-undo-memory | DEBUG only | Prints image of Undo memory blocks to debug window (stdout). |
| Files & Buffers: | A text editor like scEmacs has to read disk files into memory buffers, display, edit, and otherwise process them, then write them back to disk files. scEmacs can handle multiple buffers and multiple views (panes) of such buffers at a given time. Only a few (C‑x) commands are needed for all this. | |
|---|---|---|
| find-file | C-x C-f | Reads specified file into a new buffer and displays in current pane. Will prompt with directory (pwd) and allow entry/edit of filename. |
| write-file | C-x C-w | Writes and associates/names current buffer to specified file. Will prompt with directory (pwd) and allow entry/edit of filename. Will ask to create any missing directories in the specified path. |
| save-file | C-x C-s | Saves current buffer to its associated file. Calls write-file if buffer has no associated file. |
| save-some-files | C-s s | Goes through all modified buffers and saves their files. |
| insert-file | C-x I | Reads the file and inserts its contents into current buffer at cursor. |
| pwd | None | Displays the current directory in the echo line. |
| switch-to-buffer | C-x b | Prompts for the buffer name and switches current pane to it. |
| buffer-from-list | C-x C-b | Displays pop-up of all buffers, will switch current pane to selection. |
| kill-buffer | C-x k | Removes and deletes current buffer. All Panes displaying buffer will close or switch to another. |
| read-only-mode | C-x C-q | Toggles read-only status of current buffer. |
| unmodify | M-~ | Resets buffer flags to unmodified. (-- in mode line instead of **.) |
| Panes & Frames: | scEmacs supports multiple window frames, each showing one or more panes. Each pane displays and edits a single buffer. Only a single pane is ever active, and it resides on the frontmost frame window. C-x 5 (five for frame) commands control frames. | |
|---|---|---|
| split-pane | C-x 2 | Create a new pane by splitting the current one into two Original pane stays at the top and remains active. |
| other-pane | C-x o | Activates the next pane on the frame instead of the current one. |
| kill-pane | C-x 0 | Remove the current pane from the frame. |
| kill-other-panes | C-x 1 | Removes all other panes on current frame. |
| new-frame | C-x 5 2 | Creates a new frame with a single pane. |
| other-frame | C-x 5 o | Makes the next frame window active. |
| kill-frame | C-x 5 0 | Closes the current frame, but only if there are others. |
| kill-other-frames | C-x 5 1 | Closes all other frames, if there are any. |
| Color: |
scEmacs can display text in a limited (but easily expanded) color palette. Importantly,
Script mode will color source code on the fly using a simple (fast) parser.
These colors are for display only as text files have no reliable way of storing color or
other meta data. Each buffer can have its own color memory which stores color transitions. So a single black-to-red transition mid paragraph would mean all subsequent characters will be drawn in red. Importantly, the same buffer will be displayed with the same colors on all panes. Available colors are: black, gray, red, crimson, orange, brown, green, blue, purple, or yellow. (scEmacs does not include color changes in the undo buffers.) | |
|---|---|---|
| set-color | none | Sets the text color for the selected text region. If no region, sets color from cursor to the next color change, if any. Prompts in the Echo Line to specify color. |
| clear-all-color | none | Removes all color specifications and resets color memory. |
| print-color-memory | DEBUG only | Prints out image of color memory to debug window (stdout). |
| Script: |
scEmacs is the main data and control interface to scScript. In a typical scenario,
script code is written in scEmacs, fed to scScript for compilation, and then executed.
The output of the script goes to the *Output* buffer, and is displayed on an
scEmacs pane in realtime. Scripts can be read from an scEmacs buffer or directly from file:
Scripts may also be run interactively with script-try. This will only compile/execute the selected region, which should be syntactically complete and stand-alone top-level chunk. Importantly, such interactive execution will retain script state between runs, allowing chunks to use previously defined variables and functions. When all is done, script-reset will wipe state information, ready for another clean start. (Most script commands will automatically reset before executing.) Normally, the script will write to its default output buffer which is automatically displayed at execution time. script-show-output and script-wipe-output will display and clean this buffer on command. As a normal buffer, output can also be written/saved to a file. The user may even designate any existing buffer as the output using script-set-output. While running, a script may execute a Sys.Pause function to return control to scEmacs. This is normally done to allow user housekeeping on files and buffers. When completed, the script-resume command will return control back to the script while script-exit will cancel and terminate the paused script. | |
|---|---|---|
| script-mode | none | Sets current buffer to Script mode, auto-scans and colorizes. If already in Script mode, removes color and returns to Text mode. |
| text-mode | none | Sets current buffer to Text mode, leaves color information intact. |
| script-do | none | Read script source code in buffer, compile, and execute. |
| script-compile | none | Read script source code in buffer, compile, and write .bsc binary file. |
| script-run | none | Prompts in echo line to specify .sc or .scb file to be directly read, compiled (.sc only), and executed. No scEmacs buffers are involved! |
| script-try | none | Read, compile, and execute selected text region (chunk) in interactive mode. Script state (variables, values, etc.) will be maintained to try the next chunk |
| script-reset | none | Clear out interactive script state. |
| script-set-output | none | Makes current buffer the Output for Script write instructions. |
| script-show-output | none | Make script Output buffer visible if not so:
|
| script-wipe-output | none | Cleans out the *Output* buffer and shows it. |
| script-new-output | none | Creates new *Output* if existing one is associated with a disk file. Otherwise, does a script-wipe-output. **** |
| script-exit | none | Exits (terminates) paused script. |
| script-resume | none | Resumes paused script. |
| script-vm-init | none | Initialize script memory. Done automatically when scEmacs starts. |
| script-vm-kill | none | Wipe out and delete script memory. Must initialize before running another script. |
| script-vm-stats | none | Display (in *Output*) information about script memory. |
| script-test-dict | DEBUG only | Stress-test for DICT mechanism in script, displays on *Output*. |
| script-test-string | DEBUG only | Stress-test for STR mechanism in script, displays on *Output*. |
**** The *Output* buffer is just another
scEmacs buffer. C-x C-w will associate *Output* with a disk file,
so scScript output can be saved to file. But it is impossible to unassociate a
buffer from a disk file. Instead, script-new-output will create a new pristine
(unassociated) *Output* buffer. Importantly, one can associate (C-x
C-w) the new *Output* buffer with the same disk file again, in
the process getting multiple buffers pointing to the same disk file. Sadly these buffers
will happily over-write each other's disk files! scEmacs does its best to empower
the user, but cannot keep one's metatarsals safe from target practice.
Script-wipe-output will empty out the *Output* buffer even if
associated with a disk file. So script-new-output should be used to get a new
buffer if the intention is to keep the old output around. The latter command may display
the new *Output* buffer on the Pane, in place of the old one, but the old
buffer will remain accessible in scEmacs (using C-x C-b or C-x
buffer-from-list to show a list of buffers).