Skip to content

Commit e46a134

Browse files
committed
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.
1 parent 3674317 commit e46a134

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

lisp/progmodes/f90.el

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -895,8 +895,10 @@ Can be overridden by the value of `font-lock-maximum-decoration'.")
895895

896896
;; This is for a TYPE block, not a variable of derived TYPE.
897897
;; 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.
898900
(defconst f90-type-def-re
899-
;; type word
901+
;; type word (includes "type is")
900902
;; type :: word
901903
;; type, attr-list :: word
902904
;; where attr-list = attr [, attr ...]
@@ -953,7 +955,7 @@ Used in the F90 entry in `hs-special-modes-alist'.")
953955
;; Avoid F2003 "type is" in "select type",
954956
;; and also variables of derived type "type (foo)".
955957
;; "type, foo" must be a block (?).
956-
"type[ \t,]\\("
958+
"\\(?:type\\|class\\)[ \t,]\\("
957959
"[^i(!\n\"& \t]\\|" ; not-i(
958960
"i[^s!\n\"& \t]\\|" ; i not-s
959961
"is\\(?:\\sw\\|\\s_\\)\\)\\|"
@@ -1452,6 +1454,7 @@ if all else fails."
14521454
(not (or (looking-at "end")
14531455
(looking-at "\\(do\\|if\\|else\\(if\\|where\\)?\
14541456
\\|select[ \t]*\\(case\\|type\\)\\|case\\|where\\|forall\\|\
1457+
\\(?:class\\|type\\)[ \t]*is\\|\
14551458
block\\|critical\\|enum\\|associate\\)\\_>")
14561459
(looking-at "\\(program\\|\\(?:sub\\)?module\\|\
14571460
\\(?:abstract[ \t]*\\)?interface\\|block[ \t]*data\\)\\_>")

test/automated/f90.el

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,4 +255,22 @@ end program prog")
255255
(forward-line -2)
256256
(should (= 5 (current-indentation)))))
257257

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+
258276
;;; f90.el ends here

0 commit comments

Comments
 (0)