Lugaru's Epsilon
Programmer's
Editor

Context:
Epsilon User's Manual and Reference
   Commands by Topic
      . . .
      Repeating Commands
         Repeating a Single Command
         Keyboard Macros
      Simple Customizing
         . . .
         Variables
         Saving Customizations
         Command Files
         Using National Characters
      Advanced Topics
         Changing Commands with EEL
         Updating from an Old Version
         Keys and their Representation
         Altering Keys
         Customizing the Mouse
      . . .

Previous   Up    Next
Saving Customizations  Commands by Topic   Using National Characters


Epsilon User's Manual and Reference > Commands by Topic > Simple Customizing >

Command Files

Epsilon provides several commands to create and execute command files. These files contain macro definitions and key bindings in a human-readable format, as described below. The load-file command asks you for the name of a file, then executes the commands contained in it. The load-buffer command asks you for the name of a buffer, then executes the commands contained in that buffer.

Epsilon's command files appear in a human-readable format, so you can easily modify them. Parentheses surround each command. Inside the parentheses appear a command name, and one or two strings, sections of text enclosed in double quotes ("). Spaces separate one field from the next. Thus, each command looks something like this:

(command-name "first-string" "second-string") 

You can include comments in a command file by putting a semicolon or hash sign ("#") anywhere an opening parenthesis may appear. Such a comment extends to the end of the line. Note that you cannot put a comment inside a string.

Command files may contain three types of commands. The first, bind-to-key, functions like the regular Epsilon command of the same name. For bind-to-key, the first string specifies the name of some Epsilon command, and the second string represents the key whose binding you wish to modify, in a format we'll describe in detail in a moment. For instance, the following command binds the command show-matching-delimiter to }:

;  This example binds show-matching-delimiter to the
;  } character so that typing a } shows the matching
;  { character.
(bind-to-key "show-matching-delimiter" "}")

Unlike the regular command version, bind-to-key in a command file can unbind a prefix key. Say you want to make Ctrl-X no longer function as a prefix key, but instead have it invoke down-line. If, from the keyboard, you typed F4 to invoke bind-to-key, supplied the command name down-line, and then typed Ctrl-X as the key to rebind, Epsilon would assume you meant to rebind some subcommand of Ctrl-X, and wait for you to type a Ctrl-K, for instance, to bind down-line to Ctrl-X Ctrl-K. Epsilon doesn't know you have finished typing the key sequence. But in a command file, quotes surround each of the arguments to bind-to-key. Because of this, Epsilon can tell exactly where a key sequence ends, and you could rebind Ctrl-X as above (discarding the bindings available through Ctrl-X in the process) by saying:

(bind-to-key "down-line" "C-X") 

In a command file, define-macro allows you to define a keyboard macro. Its first string specifies the name of the new Epsilon command to define, and its second string specifies the sequence of keys you want the command to type. The define-macro command does not correspond to any single regular Epsilon command, but functions like a combination of start-kbd-macro, end-kbd-macro, and name-kbd-macro.

The third command file command, create-prefix-command, takes a single string, which specifies a key, and makes that key a prefix character. It works just as the regular command of the same name does.

The strings that describe keys in each of these commands use a representation similar to what Epsilon uses when it refers to some key. Normal characters represent themselves, control characters have a "C-" before them, alt characters have an "A-", and function keys have an "F-" followed by the number of the function key. Cursor keys appear in a notation like <Home>. See Keys and their Representation for details.

In practice, you don't need to remember exactly how to refer to a particular key, because Epsilon provides commands that construct command files for you. See the insert-macro and insert-binding commands, described below.

You can also use the special syntax <!cmdname> in a keyboard macro to run a command cmdname without knowing which key it's bound to. For example, <!find-file> runs the find-file command. When you define a keyboard macro interactively and invoke commands from the menu bar or tool bar, Epsilon will use this syntax to define them, since there may be no key sequence that invokes the specified command.

Do not put extra spaces in command file strings that represent keys. For example, the string "C-X F" represents "C-X <Space> F", not "C-X F" with no <Space>. When Epsilon describes a multi-key sequence to you (during help, for example), it typically puts in spaces for readability.

If a backslash character "\" appears in a string, it removes any special meaning from the character that follows. For instance, to make a string with a quote character (") the sequence """ doesn't work, because Epsilon interprets it as a string, followed by a quote. Instead, use "\"".

If you need a string with the character "<" or the sequence "C-" in it (or "A-", "S-", "F-" or "N-"), you'll need to put a backslash (\) before it, to prevent its interpretation as a Control, Alt or other special character. You can get a backslash in a string with a pair of backslashes, the first preventing special interpretation of the second. Thus, the DOS file name \job\letter.txt in a string looks like \\job\\letter.txt.

Consider this example command file:

; This macro makes the window below the
; current one advance to the next page.
(define-macro "scroll-next-window" "C-XnC-VC-Xp")
(bind-to-key "scroll-next-window" "C-A-v")

;This macro asks for a file and puts
;it in another window.
(define-macro "split-and-find" "A-Xsplit-window
A-Xredisplay
A-Xfind-file
")

The first two lines contain comments. The third line begins the definition of a macro called scroll-next-window. It contains three commands. First Ctrl-x n invokes next-window, to move to the next window on the screen. The Ctrl-v key runs next-page, scrolling that window forward, and Ctrl-x p then invokes previous-window, to return to the original window. The fourth line of this example binds this new macro to the Ctrl-Alt-v key, so that from then on, typing a "v" with Control and Alt depressed will scroll the next window forward.

The file defines a second macro named split-and-find. It invokes three commands by name. Notice that the macro could have invoked two of the commands by key. Invoking by name makes the macro easier to read and modify later. The redisplay command shows the action of split-window before the find-file command prompts the user for a file name.

Rather than preparing command files according to the rules presented here, you may wish to have Epsilon write parts of them automatically. Epsilon has two commands that produce the special bind-to-key and define-macro commands appropriate to recreate a current binding or macro.

The insert-binding command asks you for a key, and inserts a bind-to-key command into the current buffer. When you load the command buffer, Epsilon will restore the binding of that key.

The insert-macro command creates an appropriate define-macro command for a macro whose name you specify, and inserts the command it builds into the current buffer. This comes in handy for editing a keyboard macro that already exists.

In addition to the above syntax with commands inside parentheses, command files may contain special lines that define variables, macros, key tables or bindings. Epsilon understands all the different types of lines generated by the list-all and list-colors commands. Let's say you want to create a command file with many different macros or bindings you've defined in the current session. You could type the command file in manually, or you could use the insert-binding and insert-macro commands described above to write the command file line by line. But you may find it easier to run list-all, and then extract just the lines you want.

Besides listing variables, macros, key tables, and bindings, the list-all command also creates lines that report that a command or subroutine with a particular name exists. These lines give the name, but not the definition. When Epsilon sees a line like that, it makes sure that a command or subroutine with the given name exists. If not, it reports an error. Epsilon does the same thing with variables that have complicated types (pointers or structures, for example).

Standard bindings:

    load-file
   load-buffer
   insert-binding
   insert-macro
 



Previous   Up    Next
Saving Customizations  Commands by Topic   Using National Characters


Lugaru Copyright (C) 1984, 2020 by Lugaru Software Ltd. All rights reserved.