diff options
| author | Glenn Morris | 2017-10-19 20:05:48 -0400 |
|---|---|---|
| committer | Glenn Morris | 2017-10-19 20:05:48 -0400 |
| commit | ddd547fada112c603dae7a204fa0b141429f1927 (patch) | |
| tree | 91192ade05b1c8499a80988039acad0087d74b21 | |
| parent | 234b1e3864b8b940f72f3727fe7087cf7e90b43d (diff) | |
| download | emacs-ddd547fada112c603dae7a204fa0b141429f1927.tar.gz emacs-ddd547fada112c603dae7a204fa0b141429f1927.zip | |
Improve treatment of Fortran's "class default"
* lisp/progmodes/f90.el (f90-start-block-re, f90-no-block-limit):
Handle "class default". (Bug#28786)
* test/automated/f90.el (f90-test-bug25039): Add "class default".
| -rw-r--r-- | lisp/progmodes/f90.el | 12 | ||||
| -rw-r--r-- | test/lisp/progmodes/f90-tests.el | 14 |
2 files changed, 18 insertions, 8 deletions
diff --git a/lisp/progmodes/f90.el b/lisp/progmodes/f90.el index 6421ba60dce..72156288eba 100644 --- a/lisp/progmodes/f90.el +++ b/lisp/progmodes/f90.el | |||
| @@ -909,6 +909,8 @@ Can be overridden by the value of `font-lock-maximum-decoration'.") | |||
| 909 | [ \t]*\\(\\(?:\\sw\\|\\s_\\)+\\)" | 909 | [ \t]*\\(\\(?:\\sw\\|\\s_\\)+\\)" |
| 910 | "Regexp matching the definition of a derived type.") | 910 | "Regexp matching the definition of a derived type.") |
| 911 | 911 | ||
| 912 | ;; Maybe this should include "class default", but the constant is no | ||
| 913 | ;; longer used. | ||
| 912 | (defconst f90-typeis-re | 914 | (defconst f90-typeis-re |
| 913 | "\\_<\\(class\\|type\\)[ \t]*is[ \t]*(" | 915 | "\\_<\\(class\\|type\\)[ \t]*is[ \t]*(" |
| 914 | "Regexp matching a CLASS/TYPE IS statement.") | 916 | "Regexp matching a CLASS/TYPE IS statement.") |
| @@ -955,10 +957,14 @@ Used in the F90 entry in `hs-special-modes-alist'.") | |||
| 955 | ;; Avoid F2003 "type is" in "select type", | 957 | ;; Avoid F2003 "type is" in "select type", |
| 956 | ;; and also variables of derived type "type (foo)". | 958 | ;; and also variables of derived type "type (foo)". |
| 957 | ;; "type, foo" must be a block (?). | 959 | ;; "type, foo" must be a block (?). |
| 960 | ;; And a partial effort to avoid "class default". | ||
| 958 | "\\(?:type\\|class\\)[ \t,]\\(" | 961 | "\\(?:type\\|class\\)[ \t,]\\(" |
| 959 | "[^i(!\n\"& \t]\\|" ; not-i( | 962 | "[^id(!\n\"& \t]\\|" ; not-id( |
| 960 | "i[^s!\n\"& \t]\\|" ; i not-s | 963 | "i[^s!\n\"& \t]\\|" ; i not-s |
| 961 | "is\\(?:\\sw\\|\\s_\\)\\)\\|" | 964 | "d[^e!\n\"& \t]\\|" ; d not-e |
| 965 | "de[^f!\n\"& \t]\\|" ; de not-f | ||
| 966 | "def[^a!\n\"& \t]\\|" ; def not-a | ||
| 967 | "\\(?:is\\|default\\)\\(?:\\sw\\|\\s_\\)\\)\\|" | ||
| 962 | ;; "abstract interface" is F2003; "submodule" is F2008. | 968 | ;; "abstract interface" is F2003; "submodule" is F2008. |
| 963 | "program\\|\\(?:abstract[ \t]*\\)?interface\\|\\(?:sub\\)?module\\|" | 969 | "program\\|\\(?:abstract[ \t]*\\)?interface\\|\\(?:sub\\)?module\\|" |
| 964 | ;; "enum", but not "enumerator". | 970 | ;; "enum", but not "enumerator". |
| @@ -1454,7 +1460,7 @@ if all else fails." | |||
| 1454 | (not (or (looking-at "end") | 1460 | (not (or (looking-at "end") |
| 1455 | (looking-at "\\(do\\|if\\|else\\(if\\|where\\)?\ | 1461 | (looking-at "\\(do\\|if\\|else\\(if\\|where\\)?\ |
| 1456 | \\|select[ \t]*\\(case\\|type\\)\\|case\\|where\\|forall\\|\ | 1462 | \\|select[ \t]*\\(case\\|type\\)\\|case\\|where\\|forall\\|\ |
| 1457 | \\(?:class\\|type\\)[ \t]*is\\|\ | 1463 | \\(?:class\\|type\\)[ \t]*is\\|class[ \t]*default\\|\ |
| 1458 | block\\|critical\\|enum\\|associate\\)\\_>") | 1464 | block\\|critical\\|enum\\|associate\\)\\_>") |
| 1459 | (looking-at "\\(program\\|\\(?:sub\\)?module\\|\ | 1465 | (looking-at "\\(program\\|\\(?:sub\\)?module\\|\ |
| 1460 | \\(?:abstract[ \t]*\\)?interface\\|block[ \t]*data\\)\\_>") | 1466 | \\(?:abstract[ \t]*\\)?interface\\|block[ \t]*data\\)\\_>") |
diff --git a/test/lisp/progmodes/f90-tests.el b/test/lisp/progmodes/f90-tests.el index 0c03a190ca2..2a9100adff6 100644 --- a/test/lisp/progmodes/f90-tests.el +++ b/test/lisp/progmodes/f90-tests.el | |||
| @@ -256,21 +256,25 @@ end program prog") | |||
| 256 | (should (= 5 (current-indentation))))) | 256 | (should (= 5 (current-indentation))))) |
| 257 | 257 | ||
| 258 | (ert-deftest f90-test-bug25039 () | 258 | (ert-deftest f90-test-bug25039 () |
| 259 | "Test for https://debbugs.gnu.org/25039 ." | 259 | "Test for https://debbugs.gnu.org/25039 and 28786." |
| 260 | (with-temp-buffer | 260 | (with-temp-buffer |
| 261 | (f90-mode) | 261 | (f90-mode) |
| 262 | (insert "program prog | 262 | (insert "program prog |
| 263 | select type (a) | 263 | select type (a) |
| 264 | class is (c1) | ||
| 265 | x = 1 | ||
| 266 | type is (t1) | 264 | type is (t1) |
| 267 | x = 2 | 265 | x = 2 |
| 266 | class is (c1) | ||
| 267 | x = 1 | ||
| 268 | class default | ||
| 269 | x=3 | ||
| 268 | end select | 270 | end select |
| 269 | end program prog") | 271 | end program prog") |
| 270 | (f90-indent-subprogram) | 272 | (f90-indent-subprogram) |
| 271 | (forward-line -3) | 273 | (forward-line -3) |
| 272 | (should (= 2 (current-indentation))) ; type is | 274 | (should (= 2 (current-indentation))) ; class default |
| 275 | (forward-line -2) | ||
| 276 | (should (= 2 (current-indentation))) ; class is | ||
| 273 | (forward-line -2) | 277 | (forward-line -2) |
| 274 | (should (= 2 (current-indentation))))) ; class is | 278 | (should (= 2 (current-indentation))))) ; type is |
| 275 | 279 | ||
| 276 | ;;; f90-tests.el ends here | 280 | ;;; f90-tests.el ends here |