[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

12. Editing Shell Script (sh, ksh, bash) Code

This mode is used for editing shell scripts written for the Bourne (sh), Korn (ksh) or Bourne Again (bash) shells. It is NOT automatically invoked for any particular file extension. To invoke this mode while editing a file, type M-x ksh-mode.

The following key mappings are defined:

linefeed reindent-then-newline-and-indent
tab ksh-indent-line
C-c << Prefix Command >>
C-i ksh-indent-line
C-j reindent-then-newline-and-indent
M-tab ksh-complete-symbol
M-C-i ksh-complete-symbol
C-c tab ksh-completion-init-and-pickup
C-c C-i ksh-completion-init-and-pickup

The variables controlling indentation style are:

Indentation of ksh statements with respect to containing block. Default value is 2.

Additional indentation for statements under case items. Default value is nil which will align the statements one position past the ")" of the pattern.

Additional indentation for case items within a case statement. Default value is 2.

Additional indentation for keywords "do" and "then". Default value is -2.

Additional indentation of "{" under functions or brace groupings. Default value is 0.

Additional indentation of line that is preceded of a line ending with a \ to make it continue on next line.

Controls the operation of the TAB key. If t (the default), always reindent the current line. If nil, indent the current line only if point is at the left margin or in the line's indentation; otherwise insert a tab.

If non-nil echo in the minibuffer the matching compound command for the "done", "}", "fi", or "esac". Default value is t.

Controls whether nested constructs align from the keyword or the current indentation. If non-nil, indentation will be relative to the column the keyword starts. If nil, indentation will be relative to the current indentation of the line the keyword is on. The default value is non-nil.

Regular expression used to recognize comments. Customize to support ksh-like languages. Default value is "\s *#".

An example of how to set up this mode is as follows:

  (setq ksh-mode-hook
       (function (lambda ()
          (font-lock-mode 1)             ;; font-lock the buffer
          (setq ksh-indent 8)
	  (setq ksh-group-offset -8)
	  (setq ksh-brace-offset -8)   
          (setq ksh-tab-always-indent t)
          (setq ksh-match-and-tell t)
          (setq ksh-align-to-keyword t)	;; Turn on keyword alignment

To configure this package please view the source code. This can be done by typing C-x 4 l ksh-mode.

For a related package, see sh-script.

[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

This document was generated by XEmacs Webmaster on October, 2 2007 using texi2html