Function: fortran-beginning-of-block

fortran-beginning-of-block is an interactive and byte-compiled function defined in fortran.el.gz.

Signature

(fortran-beginning-of-block &optional NUM)

Documentation

Move point backwards to the start of the current code block.

With optional argument NUM, go backward that many balanced blocks. If NUM is negative, go forward to the end of a block. Does not check for consistency of block types. Interactively, pushes mark before moving point.

Probably introduced at or before Emacs version 22.1.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/fortran.el.gz
(defun fortran-beginning-of-block (&optional num)
  "Move point backwards to the start of the current code block.
With optional argument NUM, go backward that many balanced
blocks.  If NUM is negative, go forward to the end of a block.
Does not check for consistency of block types.  Interactively,
pushes mark before moving point."
  (interactive "p")
  (if (called-interactively-p 'any) (push-mark (point) t))
  (and num (< num 0) (fortran-end-of-block (- num)))
  (let ((case-fold-search t)
        (count (or num 1)))
    (beginning-of-line)
    (while (and (> count 0)
                (re-search-backward
                 (concat "\\(" fortran-blocks-re
                         (if fortran-check-all-num-for-matching-do
                             "\\|^[ \t]*[0-9]+" "")
                         "\\|continue\\|end\\)\\>")
                 nil 'move))
      (beginning-of-line)
      (if (if (looking-at (concat "^[0-9 \t]*" fortran-if-start-re))
              (fortran-looking-at-if-then)
            (looking-at fortran-start-block-re))
          (setq count (1- count))
        (if (or (looking-at fortran-end-block-re)
                (and (or (looking-at "^[0-9 \t]*continue")
                         (and fortran-check-all-num-for-matching-do
                              (looking-at "[ \t]*[0-9]+")))
                     (fortran-check-for-matching-do)))
            (setq count (1+ count)))))
    ;; Includes an un-named main program block.
    (if (> count 0) (error "Missing block start"))))