Function: dcl-calc-cont-indent-relative

dcl-calc-cont-indent-relative is a byte-compiled function defined in dcl-mode.el.gz.

Signature

(dcl-calc-cont-indent-relative CUR-INDENT EXTRA-INDENT)

Documentation

Indent continuation lines to align with words on previous line.

Indent continuation lines to a position relative to preceding significant command line elements.

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

Indented lines will align with either:

* the second word on the command line
  $ set default -
        [-]
* the word after an assignment
  $ a = b + -
        d
* the third word if it's a qualifier
  $ set terminal/width=80 -
                /page=24
* the innermost nonclosed parenthesis
  $ if ((a.eq.b .and. -
         d.eq.c .or. f$function(xxxx, -
                                yyy)))

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/dcl-mode.el.gz
;;;---------------------------------------------------------------------------
(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
significant command line elements.

Set `dcl-calc-cont-indent-function' to this function to customize
indentation of continuation lines.

Indented lines will align with either:

* the second word on the command line
  $ set default -
        [-]
* the word after an assignment
  $ a = b + -
        d
* the third word if it's a qualifier
  $ set terminal/width=80 -
                /page=24
* the innermost nonclosed parenthesis
  $ if ((a.eq.b .and. -
         d.eq.c .or. f$function(xxxx, -
                                yyy)))"
  (let ((case-fold-search t)
	indent)
    (save-excursion
      (dcl-beginning-of-statement)
      (let ((end (save-excursion (forward-line 1) (point))))
	;; Move over blanks and label
	(if (re-search-forward (concat "^\\$[ \t]*\\(" dcl-label-r
				       "\\)*[ \t]*") end t)
	    (progn
	      ;; Move over the first word (might be `@filespec')
	      (if (> (skip-chars-forward "@:[]<>$\\-a-zA-Z0-9_.;" end) 0)
		  (let (was-assignment)
		    (skip-chars-forward " \t" end)
		    ;; skip over assignment if there is one
		    (if (looking-at ":?==?")
			(progn
			  (setq was-assignment t)
			  (skip-chars-forward " \t:=" end)))
		    ;; This could be the position to indent to
		    (setq indent (current-column))

		    ;; Move to the next word unless we have seen an
		    ;; assignment.  If it starts with `/' it's a
		    ;; qualifier and we will indent to that position
		    (if (and (not was-assignment)
			     (> (skip-chars-forward "a-zA-Z0-9_" end) 0))
			(progn
			  (skip-chars-forward " \t" end)
			  (if (= (char-after (point)) ?/)
			      (setq indent (current-column)))))
		    ))))))
    ;; Now check if there are any parenthesis to adjust to.
    ;; If there is, we will indent to the position after the last non-closed
    ;; opening parenthesis.
    (save-excursion
      (beginning-of-line)
      (let* ((start (save-excursion (dcl-beginning-of-statement) (point)))
	     (parse-sexp-ignore-comments t) ; for parse-partial
	     (par-pos (nth 1 (parse-partial-sexp start (point)))))
	(if par-pos		; is nil if no parenthesis was found
	    (setq indent (save-excursion
			   (goto-char par-pos)
			   (1+ (current-column)))))))
    indent))