aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris2004-05-17 18:52:51 +0000
committerGlenn Morris2004-05-17 18:52:51 +0000
commit799dee7ac4e07c82660542286fdbbb4a53be87d6 (patch)
tree7e304533d224f3fb0151498747743e528eecf45d
parent410019e59c74f64a85344edcb0f72210b063b339 (diff)
downloademacs-799dee7ac4e07c82660542286fdbbb4a53be87d6.tar.gz
emacs-799dee7ac4e07c82660542286fdbbb4a53be87d6.zip
(f90-end-block-re, f90-start-block-re): New constants.
(hs-special-modes-alist): Add an f90-mode entry. This will not be 100% successful, but should handle a sizable majority of code.
-rw-r--r--lisp/progmodes/f90.el49
1 files changed, 48 insertions, 1 deletions
diff --git a/lisp/progmodes/f90.el b/lisp/progmodes/f90.el
index aada9be16dc..53165fbecb7 100644
--- a/lisp/progmodes/f90.el
+++ b/lisp/progmodes/f90.el
@@ -153,7 +153,7 @@
153;;; Code: 153;;; Code:
154 154
155;; TODO 155;; TODO
156;; Support for hideshow, align. 156;; Support for align.
157;; OpenMP, preprocessor highlighting. 157;; OpenMP, preprocessor highlighting.
158 158
159(defvar comment-auto-fill-only-comments) 159(defvar comment-auto-fill-only-comments)
@@ -589,6 +589,53 @@ characters long.")
589(make-variable-buffer-local 'f90-cache-position) 589(make-variable-buffer-local 'f90-cache-position)
590 590
591 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.
600Used 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.
629A simple regexp cannot do this in fully correct fashion, so this
630tries to strike a compromise between complexity and flexibility.
631Used 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
592;; Imenu support. 639;; Imenu support.
593(defvar f90-imenu-generic-expression 640(defvar f90-imenu-generic-expression
594 (let ((good-char "[^!\"\&\n \t]") (not-e "[^e!\n\"\& \t]") 641 (let ((good-char "[^!\"\&\n \t]") (not-e "[^e!\n\"\& \t]")