Function: fortran-beginning-do
fortran-beginning-do is a byte-compiled function defined in
fortran.el.gz.
Signature
(fortran-beginning-do)
Documentation
Search backwards for first unmatched DO [WHILE].
Return point or nil. Ignores labeled DO loops (ie DO 10 ... 10 CONTINUE).
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/fortran.el.gz
(defun fortran-beginning-do ()
"Search backwards for first unmatched DO [WHILE].
Return point or nil. Ignores labeled DO loops (ie DO 10 ... 10 CONTINUE)."
(let ((case-fold-search t)
(dostart-re "\\(\\(\\sw\\|\\s_\\)+:[ \t]*\\)?do[ \t]+[^0-9]"))
(if (save-excursion
(beginning-of-line)
(skip-chars-forward " \t0-9")
(looking-at dostart-re))
;; Sitting on one.
(match-beginning 0)
;; Search for one.
(save-excursion
(let ((count 1))
(while (and (not (zerop count))
(not (eq (fortran-previous-statement) 'first-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 dostart-re)
(setq count (1- count)))
;; Note labeled loop ends not considered.
((looking-at "end[ \t]*do\\b")
(setq count (1+ count)))))
(and (zerop count)
;; All pairs accounted for.
(point)))))))