Function: fortran-indent-comment

fortran-indent-comment is an interactive and byte-compiled function defined in fortran.el.gz.

Signature

(fortran-indent-comment)

Documentation

Align or create comment on current line.

Existing comments of all types are recognized and aligned. If the line has no comment, a side-by-side comment is inserted and aligned, if the value of comment-start is not nil and allows such comments. Otherwise, a separate-line comment is inserted, on this line or on a new line inserted before this line if this line is not blank.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/fortran.el.gz
(defun fortran-indent-comment ()
  "Align or create comment on current line.
Existing comments of all types are recognized and aligned.
If the line has no comment, a side-by-side comment is inserted and aligned,
if the value of `comment-start' is not nil and allows such comments.
Otherwise, a separate-line comment is inserted, on this line
or on a new line inserted before this line if this line is not blank."
  (interactive "*")
  (beginning-of-line)
  ;; Recognize existing comments of either kind.
  (cond ((fortran-find-comment-start-skip 'all)
         (goto-char (match-beginning 0))
         (if (bolp)
             (fortran-indent-line)
           (unless (= (current-column) (fortran-comment-indent))
             (delete-horizontal-space)
             (indent-to (fortran-comment-indent)))))
        ;; No existing comment.
        ;; If side-by-side comments are defined, insert one,
        ;; unless line is now blank.
        ((and comment-start (not (looking-at "[ \t]*$"))
              (string-match comment-start-skip (concat " " comment-start)))
         (end-of-line)
         (delete-horizontal-space)
         (indent-to (fortran-comment-indent))
         (insert comment-start))
        ;; Else insert separate-line comment, making a new line if nec.
        (t
         (if (looking-at "^[ \t]*$")
             (delete-horizontal-space)
           (beginning-of-line)
           (insert ?\n)
           (forward-char -1))
         (insert fortran-comment-line-start)
         (insert-char (if (stringp fortran-comment-indent-char)
                          (aref fortran-comment-indent-char 0)
                        fortran-comment-indent-char)
                      (- (fortran-calculate-indent) (current-column))))))