153 |
;;; Code: |
;;; Code: |
154 |
|
|
155 |
;; TODO |
;; TODO |
156 |
;; Support for hideshow, align. |
;; Support for align. |
157 |
;; OpenMP, preprocessor highlighting. |
;; OpenMP, preprocessor highlighting. |
158 |
|
|
159 |
(defvar comment-auto-fill-only-comments) |
(defvar comment-auto-fill-only-comments) |
589 |
(make-variable-buffer-local 'f90-cache-position) |
(make-variable-buffer-local 'f90-cache-position) |
590 |
|
|
591 |
|
|
592 |
|
;; Hideshow support. |
593 |
|
(defconst f90-end-block-re |
594 |
|
(concat "^[ \t0-9]*\\<end\\>[ \t]*" |
595 |
|
(regexp-opt '("do" "if" "forall" "function" "interface" |
596 |
|
"module" "program" "select" "subroutine" |
597 |
|
"type" "where" ) t) |
598 |
|
"[ \t]*\\sw*") |
599 |
|
"Regexp matching the end of a \"block\" of F90 code. |
600 |
|
Used in the F90 entry in `hs-special-modes-alist'.") |
601 |
|
|
602 |
|
;; Ignore the fact that FUNCTION, SUBROUTINE, WHERE, FORALL have a |
603 |
|
;; following "(". DO, CASE, IF can have labels; IF must be |
604 |
|
;; accompanied by THEN. |
605 |
|
;; A big problem is that many of these statements can be broken over |
606 |
|
;; lines, even with embedded comments. We only try to handle this for |
607 |
|
;; IF ... THEN statements, assuming and hoping it will be less common |
608 |
|
;; for other constructs. We match up to one new-line, provided ") |
609 |
|
;; THEN" appears on one line. Matching on just ") THEN" is no good, |
610 |
|
;; since that includes ELSE branches. |
611 |
|
;; For a fully accurate solution, hideshow would probably have to be |
612 |
|
;; modified to allow functions as well as regexps to be used to |
613 |
|
;; specify block start and end positions. |
614 |
|
(defconst f90-start-block-re |
615 |
|
(concat |
616 |
|
"^[ \t0-9]*" ; statement number |
617 |
|
"\\(\\(" |
618 |
|
"\\(\\sw+[ \t]*:[ \t]*\\)?" ; structure label |
619 |
|
"\\(do\\|select[ \t]*case\\|if[ \t]*(.*\n?.*)[ \t]*then\\|" |
620 |
|
;; Distinguish WHERE block from isolated WHERE. |
621 |
|
"\\(where\\|forall\\)[ \t]*(.*)[ \t]*\\(!\\|$\\)\\)\\)" |
622 |
|
"\\|" |
623 |
|
"program\\|interface\\|module\\|type\\|function\\|subroutine" |
624 |
|
;; ") THEN" at line end. Problem - also does ELSE. |
625 |
|
;;; "\\|.*)[ \t]*then[ \t]*\\($\\|!\\)" |
626 |
|
"\\)" |
627 |
|
"[ \t]*") |
628 |
|
"Regexp matching the start of a \"block\" of F90 code. |
629 |
|
A simple regexp cannot do this in fully correct fashion, so this |
630 |
|
tries to strike a compromise between complexity and flexibility. |
631 |
|
Used in the F90 entry in `hs-special-modes-alist'.") |
632 |
|
|
633 |
|
;; hs-special-modes-alist is autoloaded. |
634 |
|
(add-to-list 'hs-special-modes-alist |
635 |
|
`(f90-mode ,f90-start-block-re ,f90-end-block-re |
636 |
|
"!" f90-end-of-block nil)) |
637 |
|
|
638 |
|
|
639 |
;; Imenu support. |
;; Imenu support. |
640 |
(defvar f90-imenu-generic-expression |
(defvar f90-imenu-generic-expression |
641 |
(let ((good-char "[^!\"\&\n \t]") (not-e "[^e!\n\"\& \t]") |
(let ((good-char "[^!\"\&\n \t]") (not-e "[^e!\n\"\& \t]") |