Function: fortran-indent-to-column

fortran-indent-to-column is a byte-compiled function defined in fortran.el.gz.

Signature

(fortran-indent-to-column COL)

Documentation

Indent current line to column COL.

notes: 1) A non-zero/non-blank character in column 5 indicates a continuation
          line, and this continuation character is retained on indentation;
       2) If fortran-continuation-string is the first non-whitespace
          character, this is a continuation line;
       3) A non-continuation line which has a number as the first
          non-whitespace character is a numbered line.
       4) A TAB followed by a digit indicates a continuation line.

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/fortran.el.gz
(defun fortran-indent-to-column (col)
  "Indent current line to column COL.
notes: 1) A non-zero/non-blank character in column 5 indicates a continuation
          line, and this continuation character is retained on indentation;
       2) If `fortran-continuation-string' is the first non-whitespace
          character, this is a continuation line;
       3) A non-continuation line which has a number as the first
          non-whitespace character is a numbered line.
       4) A TAB followed by a digit indicates a continuation line."
  (save-excursion
    (beginning-of-line)
    (if (looking-at fortran-comment-line-start-skip)
        (if fortran-comment-indent-style
            (let* ((char (if (stringp fortran-comment-indent-char)
                             (aref fortran-comment-indent-char 0)
                           fortran-comment-indent-char))
                   (chars (string ?\s ?\t char)))
              (goto-char (match-end 0))
              ;; relint suppression: Duplicated character
              (skip-chars-backward chars)
              ;; relint suppression: Duplicated character
              (delete-region (point) (progn (skip-chars-forward chars)
                                            (point)))
              (insert-char char (- col (current-column)))))
      (if (looking-at "\t[1-9]")
          (if indent-tabs-mode
              (goto-char (match-end 0))
            (delete-char 2)
            (insert-char ?\s 5)
            (insert fortran-continuation-string))
        (if (looking-at " \\{5\\}[^ 0\n]")
            (if indent-tabs-mode
                (progn (delete-char 6)
                       (insert ?\t (fortran-numerical-continuation-char) 1))
              (forward-char 6))
          (delete-horizontal-space)
          ;; Put line number in columns 0-4, or
          ;; continuation character in column 5.
          (cond ((eobp))
                ((looking-at (regexp-quote fortran-continuation-string))
                 (if indent-tabs-mode
                     (progn
                       (indent-to
                        (if indent-tabs-mode
                            fortran-minimum-statement-indent-tab
                          fortran-minimum-statement-indent-fixed))
                       (delete-char 1)
                       (insert-char (fortran-numerical-continuation-char) 1))
                   (indent-to 5)
                   (forward-char 1)))
                ((looking-at "[0-9]+")
                 (let ((extra-space (- 5 (- (match-end 0) (point)))))
                   (if (< extra-space 0)
                       (message "Warning: line number exceeds 5-digit limit.")
                     (indent-to (min fortran-line-number-indent extra-space))))
                 (skip-chars-forward "0-9")))))
      ;; Point is now after any continuation character or line number.
      ;; Put body of statement where specified.
      (delete-horizontal-space)
      (indent-to col)
      ;; Indent any comment following code on the same line.
      (when (fortran-find-comment-start-skip)
        (goto-char (match-beginning 0))
        (unless (= (current-column) (fortran-comment-indent))
          (delete-horizontal-space)
          (indent-to (fortran-comment-indent)))))))