Previous Up Next

11 Modes

jed supports two internal modes as well as user defined modes. The two internal modes consist of a “C” mode for C Language programming and a “Wrap” mode for ordinary text editing. Examples of user defined modes are Fortran mode and DCL mode.

Online documentation is provided for nearly every mode jed defines. For help on the current mode, press Esc X and enter describe_mode. A window will appear with a short description of the special features of the mode as well as a description of the variables affecting the mode.

11.1 Wrap Mode

In this mode, text is wrapped at the column given by the WRAP variable. The default is 78. The text does not wrap until the cursor goes beyond the wrap column and a space is inserted.

11.1.1 Formatting paragraphs

Paragraph delimiters are: blank lines, lines that begin with either a percent character, %, or a backslash character \. This definition is ideally suited for editing LATEX documents. However, it is possible for the user to change this definition. See the discussion of the hook, is_paragraph_separator, in the section on hooks for explicit details on how to do this.

The paragraph is formatted according to the indentation of the current line. If the current line is indented, the paragraph will be given the same indentation. The default binding for this function is Esc q.

In addition, a paragraph may be “narrowed” by the narrow_paragraph function which is bound to Esc N by default. This differs from the ordinary format_paragraph function described above in that the right margin is reduced by an amount equal to the indentation of the current line. For example:

      This paragraph is the result of using the
      function ``narrow_paragraph''.  Note how the
      right margin is less here than in the above
      paragraph.

Finally, if either of these functions is called from the keyboard with a prefix argument, the paragraph will be justified as well. For example, pressing Esc 1 Esc N on the previous paragraph yields:

      This paragraph  is  the  result   of   using  the
      function   ``narrow_paragraph''.    Note  how the
      right margin   is less here  than  in   the above
      paragraph.

See the discussion of format_paragraph_hook in the section on hooks for details on how this is implemented.

11.2 Smart Quotes

You have probably noticed that many key words in this document are quoted in double quotes like “this is double quoted” and ‘this is single quoted’. By default, the double quote key (") and single quote key (’) are bound to the function text_smart_quote. With this binding and in wrap mode, the single quote key inserts a single quote with the “proper” orientation and the double quote key inserts two single quotes of the “proper” direction. To turn this off, rebind the keys to self_insert_cmd. Some modes already do this (e.g., EDT).

This brings up the question: if the double quote key is bound to text_smart_quote then how does one insert the character (")? The most common way is to use the quoted_insert function which, by default, is bound to the single backquote () key. This is the same mechanism that is used to insert control characters. The other method is to use the fact that if the preceding character is a backslash, \, the character simply self inserts. Again, this is ideal for writing TEX documents.

11.3 C Mode

C Mode facilitates the editing of C files. Much of the latter part of the development of the jed editor was done using this mode. This mode may be customized by a judicious choice of the variables C_INDENT and C_BRACE as well as the bindings of the curly brace keys { and }. Experiment to find what you like or write your own using the S-Lang interface.

By default, the Enter key is bound to the function newline_and_indent. This does what its name suggests: inserts a newline and indents. Again, some modes may rebind this key. In addition, the keys {, }, and Tab are also special in this mode. The Tab key indents the current line and the { and } keys insert themselves and reindent. If you do not like any of these bindings, simply rebind the offending one to self_insert_cmd.

Finally, the key sequence Esc ; is bound to a function called c_make_comment. This function makes and indents a C comment to the column specified by the value of the variable C_Comment_Column. If a comment is already present on the line, it is indented.

11.4 Fortran Mode

Fortran Mode is written entirely in S-Lang and is designed to facilitate the writing of Fortran programs. It features automatic indentation of Fortran code as well as automatic placement of Fortran statement Labels.

In this mode, the keys 0-9 are bound to a function for_elebel which does the following:

  1. Inserts the calling character (0-9) into the buffer.
  2. If the character is preceded by only other digit characters, it assumes the character is for a label and moves it to the appropriate position.
  3. Reindents the line.

This function is very similar to the one Emacs uses for labels.


Previous Up Next