Function: fortran-comment-region

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

Signature

(fortran-comment-region BEG-REGION END-REGION ARG)

Documentation

Comment every line in the region.

Inserts the string variable fortran-comment-region(var)/fortran-comment-region(fun) at the beginning of every line in the region. BEG-REGION and END-REGION specify the region boundaries. With non-nil ARG, uncomments the region.

View in manual

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/fortran.el.gz
(defun fortran-comment-region (beg-region end-region arg)
  "Comment every line in the region.
Inserts the string variable `fortran-comment-region' at the beginning of
every line in the region.
BEG-REGION and END-REGION specify the region boundaries.
With non-nil ARG, uncomments the region."
  (interactive "*r\nP")
  (let ((end-region-mark (copy-marker end-region))
        (save-point (point-marker)))
    (goto-char beg-region)
    (beginning-of-line)
    (if arg
        (let ((com (regexp-quote fortran-comment-region))) ; uncomment
          (if (looking-at com)
              (delete-region (point) (match-end 0)))
          (while (and (zerop (forward-line 1))
                      (< (point) end-region-mark))
            (if (looking-at com)
                (delete-region (point) (match-end 0)))))
      (insert fortran-comment-region)   ; comment
      (while (and (zerop (forward-line 1))
                  (< (point) end-region-mark))
        (insert fortran-comment-region)))
    (goto-char save-point)
    (set-marker end-region-mark nil)
    (set-marker save-point nil)))