Directory Handling Directory Handling

To save having to use absolute pathnames when you want to edit a nearby file JOVE allows you to move around the filesystem just as the c-shell does. These commands are:

cd dir
    Change to the specified directory.

pushd [dir]
    Like cd, but save the old directory on the directory stack. With no directory argument, simply exchange the top two directories on the stack and cd to the new top.

popd
    Take the current directory off the stack and cd to the directory now at the top.

dirs
    Display the contents of the directory stack.

The names and behavior of these commands were chosen to mimic those in the c-shell. Editing C Programs Editing C Programs

This section details the support provided by JOVE for working on C programs. Indentation Commands Indentation Commands

To save having to lay out C programs "by hand", JOVE has an idea of the correct indentation of a line, based on the surrounding context. When you are in C Mode, JOVE treats tabs specially — typing a tab at the beginning of a new line means "indent to the right place". Closing braces are also handled specially, and are indented to match the corresponding open brace. Parenthesis and Brace Matching Parenthesis and Brace Matching

To check that parentheses and braces match the way you think they do, turn on Show Match mode (ESC X show-match-mode). Then, whenever you type a close brace or parenthesis, the cursor moves momentarily to the matching opener, if it's currently visible. If it's not visible, JOVE displays the line containing the matching opener on the message line. C Tags C Tags

Often when you are editing a C program, especially someone else's code, you see a function call and wonder what that function does. You then search for the function within the current file and if you're lucky find the definition, finally returning to the original spot when you are done. However, if are unlucky, the function turns out to be external (defined in another file) and you have to suspend the edit, grep for the function name in every .c that might contain it, and finally visit the appropriate file.

To avoid this diversion or the need to remember which function is defined in which file, Berkeley has a program called ctags(1), which takes a set of source files and looks for function definitions, producing a file called tags as its output.

JOVE has a command called C-X T (find-tag) that prompts you for the name of a function (a tag), looks up the tag reference in the previously constructed tags file, then visits the file containing that tag in a new buffer, with point positioned at the definition of the function. There is another version of this command, namely find-tag-at-point, that uses the identifier at point.

So, when you've added new functions to a module, or moved some old ones around, run the ctags program to regenerate the tags file. JOVE looks in the file specified in the tag-file variable. The default is "./tags", that is, the tag file in the current directory. If you wish to use an alternate tag file, you use C-U C-X T, and JOVE will prompt for a file name. If you find yourself specifying the same file again and again, you can set tag-file to that file, and run find-tag with no numeric argument.

To begin an editing session looking for a particular tag, use the -t tag command line option to JOVE. For example, say you wanted to look at the file containing the tag SkipChar, you would invoke JOVE as: % jove -t SkipChar Compiling Your Program Compiling Your Program

You've typed in a program or altered an existing one and now you want to run it through the compiler to check for errors. To save having to suspend the edit, run the compiler, scribble down error messages, and then resume the edit, JOVE allows you to compile your code while in the editor. This is done with the C-X C-E (compile-it) command. If you run compile-it with no argument it runs the make program into a buffer; If you need a special command or want to pass arguments to make, run compile-it with any argument (C-U is good enough) and you will be prompted for the command to execute.

If any error messages are produced, they are treated specially by JOVE. That treatment is the subject of the next section. Error Message Parsing and Spelling Checking Error Message Parsing Spelling Checking

JOVE knows how to interpret the error messages from many commands; In particular, the messages from cc, grep and lint can be understood. After running the compile-it command, the parse-errors command is automatically executed, and any errors found are displayed in a new buffer. The files whose names are found in parsing the error messages are each brought into JOVE buffers and the point is positioned at the first error in the first file. The commands current-error, C-X C-N (next-error), and C-X C-P (previous-error) can be used to traverse the list of errors.

If you already have a file called errs containing, say, c compiler messages then you can get JOVE to interpret the messages by invoking it as: % jove -p errs

JOVE has a special mechanism for checking the the spelling of a document; It runs the spell program into a buffer. You then delete from this buffer all those words that are not spelling errors and then JOVE runs the parse-spelling-errors command to yield a list of errors just as in the last section. Simple Customization Simple Customization

Major Modes Major Modes

To help with editing particular types of file, say a paper or a C program, JOVE has several major modes. These are as follows: Text mode Text mode

This is the default major mode. Nothing special is done. C mode C mode

This mode affects the behavior of the tab and parentheses characters. Instead of just inserting the tab, JOVE determines where the text "ought" to line up for the C language and tabs to that position instead. The same thing happens with the close brace and close parenthesis; they are tabbed to the "right" place and then inserted. Using the auto-execute-command command, you can make JOVE enter C Mode whenever you edit a file whose name ends in .c. Lisp mode Lisp mode

This mode is analogous to C Mode, but performs the indentation needed to lay out Lisp programs properly. Note also the grind-s-expr command that prettyprints an s-expression and the kill-mode-expression command. Minor Modes Minor Modes

In addition to the major modes, JOVE has a set of minor modes. These are as follows: Auto Indent Auto Indent

In this mode, JOVE indents each line the same way as that above it. That is, the Return key in this mode acts as the Linefeed key ordinarily does. Show Match Show Match

Move the cursor momentarily to the matching opening parenthesis when a closing parenthesis is typed. Auto Fill Auto Fill

In Auto Fill mode, a newline is automatically inserted when the line length exceeds the right margin. This way, you can type a whole paper without having to use the Return key. Over Write Over Write

In this mode, any text typed in will replace the previous contents. (The default is for new text to be inserted and "push" the old along.) This is useful for editing an already-formatted diagram in which you want to change some things without moving other things around on the screen. Word Abbrev Word Abbrev

In this mode, every word you type is compared to a list of word abbreviations; whenever you type an abbreviation, it is replaced by the text that it abbreviates. This can save typing if a particular word or phrase must be entered many times. The abbreviations and their expansions are held in a file that looks like: abbrev:phrase This file can be set up in your ~/.joverc with the read-word-abbrev-file command. Then, whenever you are editing a buffer in Word Abbrev mode, JOVE checks for the abbreviations you've given. See also the commands read-word-abbrev-file, write-word-abbrev-file, edit-word-abbrevs, define-global-word-abbrev, define-mode-word-abbrev, and bind-macro-to-word-abbrev, and the variable auto-case-abbrev. Variables Variables

JOVE can be tailored to suit your needs by changing the values of variables. A JOVE variable can be given a value with the set command, and its value displayed with the print command.

The variables JOVE understands are listed along with the commands in the alphabetical list at the end of this document. Key Re-binding Key Re-binding

Many of the commands built into JOVE are not bound to specific keys. The command handler in JOVE is used to invoke these commands and is activated by the execute-extended-command command (ESC X). When the name of a command typed in is unambiguous, that command will be executed. Since it is very slow to have to type in the name of each command every time it is needed, JOVE makes it possible to bind commands to keys. When a command is bound to a key any future hits on that key will invoke that command. All the printing characters are initially bound to the command self-insert. Thus, typing any printing character causes it to be inserted into the text. Any of the existing commands can be bound to any key. (A key may actually be a control character or an escape sequence as explained previously under Command Input Conventions).

Since there are more commands than there are keys, two keys are treated as prefix commands. When a key bound to one of the prefix commands is typed, the next character typed is interpreted on the basis that it was preceded by one of the prefix keys. Initially ^X and ESC are the prefix keys and many of the built in commands are initially bound to these "two stroke" keys. (For historical reasons, the Escape key is often referred to as "Meta"). Keyboard Macros Keyboard Macros

Although JOVE has many powerful commands, you often find that you have a task that no individual command can do. JOVE allows you to define your own commands from sequences of existing ones "by example"; Such a sequence is termed a macro. The procedure is as follows: First you type the start-remembering command, usually bound to C-X (. Next you "perform" the commands which as they are being executed are also remembered, which will constitute the body of the macro. Then you give the stop-remembering command, usually bound to C-X ). You now have a keyboard macro. To run this command sequence again, use the command execute-keyboard-macro, usually bound to C-X E. You may find this bothersome to type and re-type, so there is a way to bind the macro to a key. First, you must give the keyboard macro a name using the name-keyboard-macro command. Then the binding is made with the bind-macro-to-key command. We're still not finished because all this hard work will be lost if you leave JOVE. What you do is to save your macros into a file with the write-macros-to-file command. To retrieve your macros in the next editing session (but not their bindings), you can simply execute the source command on that file. Initialization Files Initialization Files

Users will likely want to modify the default key bindings to their liking. Since it would be quite annoying to have to set up the bindings each time JOVE is started up, JOVE has the ability to read in a "startup" file. Whenever JOVE is started, it reads commands from the file .joverc in the user's home directory.

These commands are read as if they were typed to the command handler (ESC X) during an edit. There can be only one command per line in the startup file. Lines that start with ``#'' are comments. Lines may be indented.

Sometimes it is useful for a startup file to do different things in different circumstances. To make this possible, there are two conditional commands: if and ifenv. The if command takes as an operand a shell command, which it runs. If the command succeeds, the commands after the if, until a line containing else or endif, are performed. Otherwise, these commands are suppressed. The commands after any else, up until an endif, are executed only if the shell command failed. Conditionals nest in the normal way.

The ifenv command takes as operands the name of an environment variable and a pattern. If the environment variable is defined and its value matches the pattern, the if succeeds.

If there is a file /usr/lib/jove/joverc, then this file will be read before the user's .joverc file. This can be used to set up a system-wide default startup mode for JOVE that is tailored to the needs of that system.

The source command can be used to read commands from a specified file at any time during an editing session, even from inside the .joverc file. This means that a macro can be used to change the key bindings, e.g., to enter a mode, by reading from a specified file which contains all the necessary bindings.