;;; dcl-mode.el --- major mode for editing DCL command files
-;; Copyright (C) 1997, 2001-2011 Free Software Foundation, Inc.
+;; Copyright (C) 1997, 2001-2016 Free Software Foundation, Inc.
;; Author: Odd Gripenstam <gripenstamol@decus.se>
;; Maintainer: Odd Gripenstam <gripenstamol@decus.se>
:group 'languages)
(defcustom dcl-basic-offset 4
- "*Number of columns to indent a block in DCL.
+ "Number of columns to indent a block in DCL.
A block is the commands between THEN-ELSE-ENDIF and between the commands
dcl-block-begin-regexp and dcl-block-end-regexp.
(defcustom dcl-continuation-offset 6
- "*Number of columns to indent a continuation line in DCL.
+ "Number of columns to indent a continuation line in DCL.
A continuation line is a line that follows a line ending with `-'.
The meaning of this variable may be changed if
(defcustom dcl-margin-offset 8
- "*Indentation for the first command line in DCL.
+ "Indentation for the first command line in DCL.
The first command line in a file or after a SUBROUTINE statement is indented
this much. Other command lines are indented the same number of columns as
the preceding command line.
(defcustom dcl-margin-label-offset 2
- "*Number of columns to indent a margin label in DCL.
+ "Number of columns to indent a margin label in DCL.
A margin label is a label that doesn't begin or end a block, i.e. it
doesn't match dcl-block-begin-regexp or dcl-block-end-regexp."
:type 'integer
(defcustom dcl-comment-line-regexp "^\\$!"
- "*Regexp describing the start of a comment line in DCL.
+ "Regexp describing the start of a comment line in DCL.
Comment lines are not indented."
:type 'regexp
:group 'dcl)
(defcustom dcl-block-begin-regexp "loop[0-9]*:"
- "*Regexp describing a command that begins an indented block in DCL.
+ "Regexp describing a command that begins an indented block in DCL.
Set to nil to only indent at THEN-ELSE-ENDIF."
:type 'regexp
:group 'dcl)
(defcustom dcl-block-end-regexp "endloop[0-9]*:"
- "*Regexp describing a command that ends an indented block in DCL.
+ "Regexp describing a command that ends an indented block in DCL.
Set to nil to only indent at THEN-ELSE-ENDIF."
:type 'regexp
:group 'dcl)
(defcustom dcl-calc-command-indent-function nil
- "*Function to calculate indentation for a command line in DCL.
+ "Function to calculate indentation for a command line in DCL.
If this variable is non-nil it is called as a function:
\(func INDENT-TYPE CUR-INDENT EXTRA-INDENT LAST-POINT THIS-POINT)
INDENT-TYPE is a symbol indicating what kind of indentation should be done.
It can have the following values:
- indent the lines indentation should be increased, e.g. after THEN.
- outdent the lines indentation should be decreased, e.g a line with ENDIF.
+ indent the indentation should be increased, e.g., after THEN.
+ outdent the indentation should be decreased, e.g., a line with ENDIF.
first-line indentation for the first line in a buffer or SUBROUTINE.
CUR-INDENT is the indentation of the preceding command line.
EXTRA-INDENT is the default change in indentation for this line
-\(a negative number for 'outdent).
+\(a negative number for “outdent”).
LAST-POINT is the buffer position of the first significant word on the
previous line or nil if the current line is the first line.
THIS-POINT is the buffer position of the first significant word on the
(defcustom dcl-calc-cont-indent-function 'dcl-calc-cont-indent-relative
- "*Function to calculate indentation for a continuation line.
+ "Function to calculate indentation for a continuation line.
If this variable is non-nil it is called as a function:
\(func CUR-INDENT EXTRA-INDENT)
(defcustom dcl-tab-always-indent t
- "*Controls the operation of the TAB key in DCL mode.
+ "Controls the operation of the TAB key in DCL mode.
If t, pressing TAB always indents the current line.
If nil, pressing TAB indents the current line if point is at the left margin.
Data lines (i.e. lines not part of a command line or continuation line) are
(defcustom dcl-electric-characters t
- "*Non-nil means reindent immediately when a label, ELSE or ENDIF is inserted."
+ "Non-nil means reindent immediately when a label, ELSE or ENDIF is inserted."
:type 'boolean
:group 'dcl)
(defcustom dcl-tempo-comma ", "
- "*Text to insert when a comma is needed in a template, in DCL mode."
+ "Text to insert when a comma is needed in a template, in DCL mode."
:type 'string
:group 'dcl)
(defcustom dcl-tempo-left-paren "("
- "*Text to insert when a left parenthesis is needed in a template in DCL."
+ "Text to insert when a left parenthesis is needed in a template in DCL."
:type 'string
:group 'dcl)
(defcustom dcl-tempo-right-paren ")"
- "*Text to insert when a right parenthesis is needed in a template in DCL."
+ "Text to insert when a right parenthesis is needed in a template in DCL."
:type 'string
:group 'dcl)
; I couldn't decide what looked best, so I'll let you decide...
; Remember, you can also customize this with imenu-submenu-name-format.
(defcustom dcl-imenu-label-labels "Labels"
- "*Imenu menu title for sub-listing with label names."
+ "Imenu menu title for sub-listing with label names."
:type 'string
:group 'dcl)
(defcustom dcl-imenu-label-goto "GOTO"
- "*Imenu menu title for sub-listing with GOTO statements."
+ "Imenu menu title for sub-listing with GOTO statements."
:type 'string
:group 'dcl)
(defcustom dcl-imenu-label-gosub "GOSUB"
- "*Imenu menu title for sub-listing with GOSUB statements."
+ "Imenu menu title for sub-listing with GOSUB statements."
:type 'string
:group 'dcl)
(defcustom dcl-imenu-label-call "CALL"
- "*Imenu menu title for sub-listing with CALL statements."
+ "Imenu menu title for sub-listing with CALL statements."
:type 'string
:group 'dcl)
(defcustom dcl-imenu-generic-expression
- `((nil "^\\$[ \t]*\\([A-Za-z0-9_\$]+\\):[ \t]+SUBROUTINE\\b" 1)
+ `((nil "^\\$[ \t]*\\([A-Za-z0-9_$]+\\):[ \t]+SUBROUTINE\\b" 1)
(,dcl-imenu-label-labels
- "^\\$[ \t]*\\([A-Za-z0-9_\$]+\\):\\([ \t]\\|$\\)" 1)
- (,dcl-imenu-label-goto "\\s-GOTO[ \t]+\\([A-Za-z0-9_\$]+\\)" 1)
- (,dcl-imenu-label-gosub "\\s-GOSUB[ \t]+\\([A-Za-z0-9_\$]+\\)" 1)
- (,dcl-imenu-label-call "\\s-CALL[ \t]+\\([A-Za-z0-9_\$]+\\)" 1))
- "*Default imenu generic expression for DCL.
+ "^\\$[ \t]*\\([A-Za-z0-9_$]+\\):\\([ \t]\\|$\\)" 1)
+ (,dcl-imenu-label-goto "\\s-GOTO[ \t]+\\([A-Za-z0-9_$]+\\)" 1)
+ (,dcl-imenu-label-gosub "\\s-GOSUB[ \t]+\\([A-Za-z0-9_$]+\\)" 1)
+ (,dcl-imenu-label-call "\\s-CALL[ \t]+\\([A-Za-z0-9_$]+\\)" 1))
+ "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.
(defcustom dcl-mode-hook nil
- "*Hook called by `dcl-mode'."
+ "Hook called by `dcl-mode'."
:type 'hook
:group 'dcl)
(defcustom dcl-label-r
- "[a-zA-Z0-9_\$]*:\\([ \t!]\\|$\\)"
+ "[a-zA-Z0-9_$]*:\\([ \t!]\\|$\\)"
"Regular expression describing a label.
A label is a name followed by a colon followed by white-space or end-of-line."
:type 'regexp
(defcustom dcl-electric-reindent-regexps
(list "endif" "else" dcl-label-r)
- "*Regexps that can trigger an electric reindent.
+ "Regexps that can trigger an electric reindent.
A list of regexps that will trigger a reindent if the last letter
is defined as dcl-electric-character.
;; 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)
+; ((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)))
+; "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
dcl-block-begin-regexp
dcl-block-end-regexp
Regexps that match command lines that begin and end, respectively,
- a block of commmand lines that will be given extra indentation.
+ 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.
(defun dcl-end-of-command ()
"Move point to end of current command or next command if not on a command."
(interactive)
- (let ((type (dcl-get-line-type))
- (start (point)))
+ (let ((type (dcl-get-line-type)))
(if (or (eq type '$)
(eq type '-))
(progn
(setq done t) ; not a label-only line, exit the loop
(setq retval (point))))
;; We couldn't go further back, and we haven't found a command yet.
- ;; Return to the start positionn
+ ;; Return to the start position.
(goto-char start)
(setq done t)
(setq retval nil)))
(setq done t) ; not a label-only line, exit the loop
(setq retval (point)))))
;; We couldn't go further back, and we haven't found a command yet.
- ;; Return to the start positionn
+ ;; Return to the start position.
(goto-char start)
(setq done t)
(setq retval nil)))
;;;---------------------------------------------------------------------------
(defun dcl-calc-command-indent-multiple
- (indent-type cur-indent extra-indent last-point this-point)
+ (indent-type cur-indent extra-indent _last-point _this-point)
"Indent lines to a multiple of dcl-basic-offset.
Set dcl-calc-command-indent-function to this function to customize
;;;---------------------------------------------------------------------------
-(defun dcl-calc-cont-indent-relative (cur-indent extra-indent)
+(defun dcl-calc-cont-indent-relative (_cur-indent _extra-indent)
"Indent continuation lines to align with words on previous line.
Indent continuation lines to a position relative to preceding
;;;-------------------------------------------------------------------------
-(defun dcl-option-value-basic (option-assoc)
+(defun dcl-option-value-basic (_option-assoc)
"Guess a value for basic-offset."
(save-excursion
(dcl-beginning-of-command)
;;;-------------------------------------------------------------------------
-(defun dcl-option-value-offset (option-assoc)
+(defun dcl-option-value-offset (_option-assoc)
"Guess a value for an offset.
Find the column of the first non-blank character on the line.
Returns the column offset."
;;;-------------------------------------------------------------------------
-(defun dcl-option-value-margin-offset (option-assoc)
+(defun dcl-option-value-margin-offset (_option-assoc)
"Guess a value for margin offset.
Find the column of the first non-blank character on the line, not
counting labels.
;;;-------------------------------------------------------------------------
-(defun dcl-option-value-comment-line (option-assoc)
+(defun dcl-option-value-comment-line (_option-assoc)
"Guess a value for `dcl-comment-line-regexp'.
Must return a string."
;; Should we set comment-start and comment-start-skip as well?
(if (eolp) (error "Missing colon in local variables entry"))
(skip-chars-backward " \t")
(let* ((str (buffer-substring beg (point)))
- (found-var (read str))
- val)
+ (found-var (read str)))
;; Setting variable named "end" means end of list.
(if (string-equal (downcase str) "end")
(progn
;;;-------------------------------------------------------------------------
+(with-no-warnings
+ ;; Dynamically bound in `dcl-save-mode'.
+ (defvar mode))
+
(defun dcl-save-mode ()
"Save the current mode for this buffer.
Save the current mode in a `Local Variables:'
(interactive)
(let ((mode (prin1-to-string major-mode)))
(if (string-match "-mode$" mode)
- (let ((mode (intern (substring mode 0 (match-beginning 0)))))
+ (let ((mode (intern (substring mode 0 (match-beginning 0)))))
(dcl-save-option 'mode))
(message "Strange mode: %s" mode))))