Variable: fortran-start-block-re

fortran-start-block-re is a variable defined in fortran.el.gz.

Value

"^[     0-9]*\\(\\(\\(\\sw+[    ]*:[    ]*\\)?\\(if[    ]*(\\(.*\\|.*\n\\([^if]*\\([^i].\\|.[^f]\\|.\\>\\)\\)\\)\\<then\\|do\\|select[    ]*case\\|where\\)\\)\\|\\(?:function\\|interface\\|map\\|program\\|s\\(?:\\(?:tructur\\|ubroutin\\)e\\)\\|union\\)\\|block[     ]*data\\)[      ]*"

Documentation

Regexp matching the start of a Fortran "block", from the line start.

A simple regexp cannot do this in fully correct fashion, so this tries to strike a compromise between complexity and flexibility. Used in the Fortran entry in hs-block-start-regexp.

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/fortran.el.gz
(defconst fortran-start-block-re
  (concat
   "^[ \t0-9]*\\("                      ; statement number
   ;; Structure label for DO, IF, SELECT, WHERE.
   "\\(\\(\\sw+[ \t]*:[ \t]*\\)?"
   ;; IF blocks are a nuisance:
   ;; IF ( ... ) foo   is not a block, but a single statement.
   ;; IF ( ... ) THEN  can be split over multiple lines.
   ;; [So can, eg, a DO WHILE (... ), but that is less common, I hope.]
   ;; The regexp below allows for it to be split over at most 2 lines.
   ;; That leads to the problem of not matching two consecutive IF
   ;; statements as one, eg:
   ;; IF ( ... ) foo
   ;; IF ( ... ) THEN
   ;; It simply is not possible to do this in a 100% correct fashion
   ;; using a regexp - see the functions fortran-end-if,
   ;; fortran-beginning-if for the hoops we have to go through.
   ;; An alternative is to match on THEN at a line end, eg:
   ;;   ".*)[ \t]*then[ \t]*\\($\\|!\\)"
   ;; This would also match ELSE branches, though. This does not seem
   ;; right to me, because then one has neighboring blocks that are
   ;; not nested in each other.
   "\\(if[ \t]*(\\(.*\\|"
   ".*\n\\([^if]*\\([^i].\\|.[^f]\\|.\\>\\)\\)\\)\\<then\\|"
   "do\\|select[ \t]*case\\|where\\)\\)\\|"
   (regexp-opt '("interface" "function" "map" "program"
                 "structure" "subroutine" "union"))
   "\\|block[ \t]*data\\)[ \t]*")
  "Regexp matching the start of a Fortran \"block\", from the line start.
A simple regexp cannot do this in fully correct fashion, so this
tries to strike a compromise between complexity and flexibility.
Used in the Fortran entry in `hs-block-start-regexp'.")