Function: fortran-end-do

fortran-end-do is a byte-compiled function defined in fortran.el.gz.

Signature

(fortran-end-do)

Documentation

Search forward for first unmatched ENDDO.

Return point or nil.

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/fortran.el.gz
(defun fortran-end-do ()
  "Search forward for first unmatched ENDDO.
Return point or nil."
  (let ((case-fold-search t))
    (if (save-excursion (beginning-of-line)
                        (skip-chars-forward " \t0-9")
                        (looking-at "end[ \t]*do\\b"))
        ;; Sitting on one.
        (match-beginning 0)
      ;; Search for one.
      (save-excursion
        (let ((count 1))
          (while (and (not (zerop count))
                      (not (eq (fortran-next-statement) 'last-statement))
                      ;; Keep local to subprogram.
                      (not (and (looking-at fortran-end-prog-re)
                                (fortran-check-end-prog-re))))
            (skip-chars-forward " \t0-9")
            (cond ((looking-at "end[ \t]*do\\b")
                   (setq count (1- count)))
                  ((looking-at
                    "\\(\\(\\sw\\|\\s_\\)+:[ \t]*\\)?do[ \t]+[^0-9]")
                   (setq count (1+ count)))))
          (and (zerop count)
               ;; All pairs accounted for.
               (point)))))))