Function: dcl-mode

dcl-mode is an autoloaded, interactive and byte-compiled function defined in dcl-mode.el.gz.

Signature

(dcl-mode)

Documentation

Major mode for editing DCL-files.

This mode indents command lines in blocks. (A block is commands between THEN-ELSE-ENDIF and between lines matching dcl-block-begin-regexp and dcl-block-end-regexp.)

Labels are indented to a fixed position unless they begin or end a block. Whole-line comments (matching dcl-comment-line-regexp) are not indented. Data lines are not indented.

Key bindings:

: dcl-electric-character
C-M-i tempo-complete-tag
C-M-q dcl-indent-command
C-c C-b tempo-backward-mark
C-c C-f tempo-forward-mark
C-c C-o dcl-set-option
E dcl-electric-character
F dcl-electric-character
M-RET dcl-split-line
M-^ dcl-delete-indentation
M-a dcl-backward-command
M-e dcl-forward-command
M-m dcl-back-to-indentation
TAB dcl-tab
e dcl-electric-character
f dcl-electric-character
Commands not usually bound to keys:

M-x dcl-save-nondefault-options (dcl-save-nondefault-options) Save changed options
M-x dcl-save-all-options (dcl-save-all-options) Save all options
M-x dcl-save-option (dcl-save-option) Save any option
M-x dcl-save-mode (dcl-save-mode) Save buffer mode

Variables controlling indentation style and extra features:

 dcl-basic-offset
    Extra indentation within blocks.

 dcl-continuation-offset
    Extra indentation for continued lines.

 dcl-margin-offset
    Indentation for the first command line in a file or SUBROUTINE.

 dcl-margin-label-offset
    Indentation for a label.

 dcl-comment-line-regexp
    Lines matching this regexp will not be indented.

 dcl-block-begin-regexp
 dcl-block-end-regexp
    Regexps that match command lines that begin and end, respectively,
    a block of command lines that will be given extra indentation.
    Command lines between THEN-ELSE-ENDIF are always indented; these variables
    make it possible to define other places to indent.
    Set to nil to disable this feature.

 dcl-calc-command-indent-function
    Can be set to a function that customizes indentation for command lines.
    Two such functions are included in the package:
dcl-calc-command-indent-multiple
dcl-calc-command-indent-hang

 dcl-calc-cont-indent-function
    Can be set to a function that customizes indentation for continued lines.
    One such function is included in the package:
dcl-calc-cont-indent-relative (set by default)

 dcl-tab-always-indent
    If t, pressing TAB always indents the current line.
    If nil, pressing TAB indents the current line if point is at the left
    margin.

 dcl-electric-characters
    Non-nil causes lines to be indented at once when a label, ELSE or ENDIF is
    typed.

 dcl-electric-reindent-regexps
    Use this variable and function dcl-electric-character to customize
    which words trigger electric indentation.

 dcl-tempo-comma
 dcl-tempo-left-paren
 dcl-tempo-right-paren
    These variables control the look of expanded templates.

 dcl-imenu-generic-expression
    Default value for imenu-generic-expression. The default includes
    SUBROUTINE labels in the main listing and sub-listings for
    other labels, CALL, GOTO and GOSUB statements.

 dcl-imenu-label-labels
 dcl-imenu-label-goto
 dcl-imenu-label-gosub
 dcl-imenu-label-call
    Change the text that is used as sub-listing labels in imenu.

Turning on DCL mode calls the value of the variable dcl-mode-hook with no args, if that value is non-nil.

The following example uses the default values for all variables:

$! This is a comment line that is not indented (it matches
$! dcl-comment-line-regexp)
$! Next follows the first command line. It is indented dcl-margin-offset.
$ i = 1
$ ! Other comments are indented like command lines.
$ ! A margin label indented dcl-margin-label-offset:
$ label:
$ if i.eq.1
$ then
$ ! Lines between THEN-ELSE and ELSE-ENDIF are
$ ! indented dcl-basic-offset
$ loop1: ! This matches dcl-block-begin-regexp...
$ ! ...so this line is indented dcl-basic-offset
$ text = "This " + - ! is a continued line
                       "lined up with the command line"
$ type sys$input
Data lines are not indented at all.
$ endloop1: ! This matches dcl-block-end-regexp
$ endif
$


There is some minimal font-lock support (see vars dcl-font-lock-defaults and dcl-font-lock-keywords).

Probably introduced at or before Emacs version 20.1.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/dcl-mode.el.gz
;; Must be defined after dcl-cmd-r
;; This version is more correct but much slower than the one
;; above.  This version won't find GOTOs in comments or text strings.
;(defvar dcl-imenu-generic-expression
;  (`
;   ((nil "^\\$[ \t]*\\([A-Za-z0-9_$]+\\):[ \t]+SUBROUTINE\\b" 1)
;    ("Labels" "^\\$[ \t]*\\([A-Za-z0-9_$]+\\):\\([ \t]\\|$\\)" 1)
;    ("GOTO" (, (concat dcl-cmd-r "GOTO[ \t]+\\([A-Za-z0-9_$]+\\)")) 5)
;    ("GOSUB" (, (concat dcl-cmd-r
;			"GOSUB[ \t]+\\([A-Za-z0-9_$]+\\)")) 5)
;    ("CALL" (, (concat dcl-cmd-r "CALL[ \t]+\\([A-Za-z0-9_$]+\\)")) 5)))
;  "Default imenu generic expression for DCL.

;The default includes SUBROUTINE labels in the main listing and
;sub-listings for other labels, CALL, GOTO and GOSUB statements.
;See `imenu-generic-expression' for details.")


;;; *** Mode initialization *************************************************


;;;###autoload
(define-derived-mode dcl-mode prog-mode "DCL"
  "Major mode for editing DCL-files.

This mode indents command lines in blocks.  (A block is commands between
THEN-ELSE-ENDIF and between lines matching dcl-block-begin-regexp and
dcl-block-end-regexp.)

Labels are indented to a fixed position unless they begin or end a block.
Whole-line comments (matching dcl-comment-line-regexp) are not indented.
Data lines are not indented.

Key bindings:

\\{dcl-mode-map}
Commands not usually bound to keys:

\\[dcl-save-nondefault-options]\t\tSave changed options
\\[dcl-save-all-options]\t\tSave all options
\\[dcl-save-option]\t\t\tSave any option
\\[dcl-save-mode]\t\t\tSave buffer mode

Variables controlling indentation style and extra features:

 dcl-basic-offset
    Extra indentation within blocks.

 dcl-continuation-offset
    Extra indentation for continued lines.

 dcl-margin-offset
    Indentation for the first command line in a file or SUBROUTINE.

 dcl-margin-label-offset
    Indentation for a label.

 dcl-comment-line-regexp
    Lines matching this regexp will not be indented.

 dcl-block-begin-regexp
 dcl-block-end-regexp
    Regexps that match command lines that begin and end, respectively,
    a block of command lines that will be given extra indentation.
    Command lines between THEN-ELSE-ENDIF are always indented; these variables
    make it possible to define other places to indent.
    Set to nil to disable this feature.

 dcl-calc-command-indent-function
    Can be set to a function that customizes indentation for command lines.
    Two such functions are included in the package:
	dcl-calc-command-indent-multiple
	dcl-calc-command-indent-hang

 dcl-calc-cont-indent-function
    Can be set to a function that customizes indentation for continued lines.
    One such function is included in the package:
	dcl-calc-cont-indent-relative    (set by default)

 dcl-tab-always-indent
    If t, pressing TAB always indents the current line.
    If nil, pressing TAB indents the current line if point is at the left
    margin.

 dcl-electric-characters
    Non-nil causes lines to be indented at once when a label, ELSE or ENDIF is
    typed.

 dcl-electric-reindent-regexps
    Use this variable and function dcl-electric-character to customize
    which words trigger electric indentation.

 dcl-tempo-comma
 dcl-tempo-left-paren
 dcl-tempo-right-paren
    These variables control the look of expanded templates.

 dcl-imenu-generic-expression
    Default value for `imenu-generic-expression'.  The default includes
    SUBROUTINE labels in the main listing and sub-listings for
    other labels, CALL, GOTO and GOSUB statements.

 dcl-imenu-label-labels
 dcl-imenu-label-goto
 dcl-imenu-label-gosub
 dcl-imenu-label-call
    Change the text that is used as sub-listing labels in imenu.

Turning on DCL mode calls the value of the variable `dcl-mode-hook'
with no args, if that value is non-nil.


The following example uses the default values for all variables:

$! This is a comment line that is not indented (it matches
$! dcl-comment-line-regexp)
$! Next follows the first command line.  It is indented dcl-margin-offset.
$       i = 1
$       ! Other comments are indented like command lines.
$       ! A margin label indented dcl-margin-label-offset:
$ label:
$       if i.eq.1
$       then
$           ! Lines between THEN-ELSE and ELSE-ENDIF are
$           ! indented dcl-basic-offset
$           loop1: ! This matches dcl-block-begin-regexp...
$               ! ...so this line is indented dcl-basic-offset
$               text = \"This \" + - ! is a continued line
                       \"lined up with the command line\"
$               type sys$input
Data lines are not indented at all.
$           endloop1: ! This matches dcl-block-end-regexp
$       endif
$


There is some minimal font-lock support (see vars
`dcl-font-lock-defaults' and `dcl-font-lock-keywords')."
  (setq-local indent-line-function #'dcl-indent-line)
  (setq-local comment-start "!")
  (setq-local comment-end "")
  (setq-local comment-multi-line nil)

  ;; This used to be "^\\$[ \t]*![ \t]*" which looks more correct.
  ;; The drawback was that you couldn't make empty comment lines by pressing
  ;; C-M-j repeatedly - only the first line became a comment line.
  ;; This version has the drawback that the "$" can be anywhere in the line,
  ;; and something inappropriate might be interpreted as a comment.
  (setq-local comment-start-skip "\\$[ \t]*![ \t]*")

  (setq imenu-generic-expression dcl-imenu-generic-expression)
  (setq imenu-case-fold-search t)
  (setq imenu-create-index-function #'dcl-imenu-create-index-function)

  (make-local-variable 'dcl-comment-line-regexp)
  (make-local-variable 'dcl-block-begin-regexp)
  (make-local-variable 'dcl-block-end-regexp)
  (make-local-variable 'dcl-basic-offset)
  (make-local-variable 'dcl-continuation-offset)
  (make-local-variable 'dcl-margin-label-offset)
  (make-local-variable 'dcl-margin-offset)
  (make-local-variable 'dcl-tab-always-indent)
  (make-local-variable 'dcl-electric-characters)
  (make-local-variable 'dcl-calc-command-indent-function)
  (make-local-variable 'dcl-calc-cont-indent-function)
  (make-local-variable 'dcl-electric-reindent-regexps)

  ;; font lock
  (setq-local font-lock-defaults dcl-font-lock-defaults)

  (tempo-use-tag-list 'dcl-tempo-tags))