Function: dcl-calc-command-indent-hang

dcl-calc-command-indent-hang is a byte-compiled function defined in dcl-mode.el.gz.

Signature

(dcl-calc-command-indent-hang INDENT-TYPE CUR-INDENT EXTRA-INDENT LAST-POINT THIS-POINT)

Documentation

Indent lines as default, but indent THEN, ELSE and ENDIF extra.

Set dcl-calc-command-indent-function to this function to customize indentation of command lines.

This function supports a formatting style like this:

$ if cond
$ then
$ xxx
$ endif
$ xxx

If you use this function you will probably want to add "then" to dcl-electric-reindent-regexps and define the key "n" as dcl-electric-character.

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/dcl-mode.el.gz
;;;---------------------------------------------------------------------------
;; Some people actually writes likes this.  To each his own...
(defun dcl-calc-command-indent-hang
  (indent-type cur-indent extra-indent last-point this-point)
  "Indent lines as default, but indent THEN, ELSE and ENDIF extra.

Set dcl-calc-command-indent-function to this function to customize
indentation of command lines.

This function supports a formatting style like this:

$ if cond
$   then
$     xxx
$   endif
$ xxx

If you use this function you will probably want to add \"then\" to
dcl-electric-reindent-regexps and define the key \"n\" as
dcl-electric-character."
  (let ((case-fold-search t))
    (save-excursion
      (cond
       ;; No indentation, this word is `then': +2
       ;; last word was endif: -2
       ((null indent-type)
	(or (progn
	      (goto-char this-point)
	      (if (looking-at "\\bthen\\b")
		  (+ cur-indent extra-indent 2)))
	    (progn
	      (goto-char last-point)
	      (if (looking-at "\\bendif\\b")
		  (- (+ cur-indent extra-indent) 2)))))
       ;; Indentation, last word was `then' or `else': -2
       ((equal indent-type 'indent)
	(goto-char last-point)
	(cond
	 ((looking-at "\\bthen\\b")
	  (- (+ cur-indent extra-indent) 2))
	 ((looking-at "\\belse\\b")
	  (- (+ cur-indent extra-indent) 2))))
       ;; Outdent, this word is `endif' or `else': + 2
       ((equal indent-type 'outdent)
	(goto-char this-point)
	(cond
	 ((looking-at "\\bendif\\b")
	  (+ cur-indent extra-indent 2))
	 ((looking-at "\\belse\\b")
	  (+ cur-indent extra-indent 2))))))))