diff options
| author | Glenn Morris | 2016-11-27 16:05:02 -0800 |
|---|---|---|
| committer | Glenn Morris | 2016-11-27 16:05:02 -0800 |
| commit | e46a13446a0dc68e5bc10636d9c40ce5b331efb9 (patch) | |
| tree | 49562aeda927218ea0cb4d37442cb829d330cd0e | |
| parent | 3674317311131a597dacc8920c5e1cd258ccd6d7 (diff) | |
| download | emacs-e46a13446a0dc68e5bc10636d9c40ce5b331efb9.tar.gz emacs-e46a13446a0dc68e5bc10636d9c40ce5b331efb9.zip | |
Improve treatment of Fortran's "class is"
* lisp/progmodes/f90.el (f90-start-block-re, f90-no-block-limit):
Handle "class is". (Bug#25039)
* test/automated/f90.el (f90-test-bug25039): New test.
| -rw-r--r-- | lisp/progmodes/f90.el | 7 | ||||
| -rw-r--r-- | test/automated/f90.el | 18 |
2 files changed, 23 insertions, 2 deletions
diff --git a/lisp/progmodes/f90.el b/lisp/progmodes/f90.el index 58397530e4f..d9a34720046 100644 --- a/lisp/progmodes/f90.el +++ b/lisp/progmodes/f90.el | |||
| @@ -895,8 +895,10 @@ Can be overridden by the value of `font-lock-maximum-decoration'.") | |||
| 895 | 895 | ||
| 896 | ;; This is for a TYPE block, not a variable of derived TYPE. | 896 | ;; This is for a TYPE block, not a variable of derived TYPE. |
| 897 | ;; Hence no need to add CLASS for F2003. | 897 | ;; Hence no need to add CLASS for F2003. |
| 898 | ;; Note that this also matches "type is", so you might need to use | ||
| 899 | ;; f90-typeis-re as well. | ||
| 898 | (defconst f90-type-def-re | 900 | (defconst f90-type-def-re |
| 899 | ;; type word | 901 | ;; type word (includes "type is") |
| 900 | ;; type :: word | 902 | ;; type :: word |
| 901 | ;; type, attr-list :: word | 903 | ;; type, attr-list :: word |
| 902 | ;; where attr-list = attr [, attr ...] | 904 | ;; where attr-list = attr [, attr ...] |
| @@ -953,7 +955,7 @@ Used in the F90 entry in `hs-special-modes-alist'.") | |||
| 953 | ;; Avoid F2003 "type is" in "select type", | 955 | ;; Avoid F2003 "type is" in "select type", |
| 954 | ;; and also variables of derived type "type (foo)". | 956 | ;; and also variables of derived type "type (foo)". |
| 955 | ;; "type, foo" must be a block (?). | 957 | ;; "type, foo" must be a block (?). |
| 956 | "type[ \t,]\\(" | 958 | "\\(?:type\\|class\\)[ \t,]\\(" |
| 957 | "[^i(!\n\"& \t]\\|" ; not-i( | 959 | "[^i(!\n\"& \t]\\|" ; not-i( |
| 958 | "i[^s!\n\"& \t]\\|" ; i not-s | 960 | "i[^s!\n\"& \t]\\|" ; i not-s |
| 959 | "is\\(?:\\sw\\|\\s_\\)\\)\\|" | 961 | "is\\(?:\\sw\\|\\s_\\)\\)\\|" |
| @@ -1452,6 +1454,7 @@ if all else fails." | |||
| 1452 | (not (or (looking-at "end") | 1454 | (not (or (looking-at "end") |
| 1453 | (looking-at "\\(do\\|if\\|else\\(if\\|where\\)?\ | 1455 | (looking-at "\\(do\\|if\\|else\\(if\\|where\\)?\ |
| 1454 | \\|select[ \t]*\\(case\\|type\\)\\|case\\|where\\|forall\\|\ | 1456 | \\|select[ \t]*\\(case\\|type\\)\\|case\\|where\\|forall\\|\ |
| 1457 | \\(?:class\\|type\\)[ \t]*is\\|\ | ||
| 1455 | block\\|critical\\|enum\\|associate\\)\\_>") | 1458 | block\\|critical\\|enum\\|associate\\)\\_>") |
| 1456 | (looking-at "\\(program\\|\\(?:sub\\)?module\\|\ | 1459 | (looking-at "\\(program\\|\\(?:sub\\)?module\\|\ |
| 1457 | \\(?:abstract[ \t]*\\)?interface\\|block[ \t]*data\\)\\_>") | 1460 | \\(?:abstract[ \t]*\\)?interface\\|block[ \t]*data\\)\\_>") |
diff --git a/test/automated/f90.el b/test/automated/f90.el index fece86ca1d8..29c608847f1 100644 --- a/test/automated/f90.el +++ b/test/automated/f90.el | |||
| @@ -255,4 +255,22 @@ end program prog") | |||
| 255 | (forward-line -2) | 255 | (forward-line -2) |
| 256 | (should (= 5 (current-indentation))))) | 256 | (should (= 5 (current-indentation))))) |
| 257 | 257 | ||
| 258 | (ert-deftest f90-test-bug25039 () | ||
| 259 | "Test for http://debbugs.gnu.org/25039 ." | ||
| 260 | (with-temp-buffer | ||
| 261 | (f90-mode) | ||
| 262 | (insert "program prog | ||
| 263 | select type (a) | ||
| 264 | class is (c1) | ||
| 265 | x = 1 | ||
| 266 | type is (t1) | ||
| 267 | x = 2 | ||
| 268 | end select | ||
| 269 | end program prog") | ||
| 270 | (f90-indent-subprogram) | ||
| 271 | (forward-line -3) | ||
| 272 | (should (= 2 (current-indentation))) ; type is | ||
| 273 | (forward-line -2) | ||
| 274 | (should (= 2 (current-indentation))))) ; class is | ||
| 275 | |||
| 258 | ;;; f90.el ends here | 276 | ;;; f90.el ends here |