diff options
| author | Glenn Morris | 2011-06-25 18:22:45 -0700 |
|---|---|---|
| committer | Glenn Morris | 2011-06-25 18:22:45 -0700 |
| commit | e93db24a10c839126b817ad60baceb2a3335f453 (patch) | |
| tree | 9ae152408f903cc06965b5363405c005f15bbcc6 /lisp | |
| parent | d4f259f7851659a0c5c20935d13c342d624fbde5 (diff) | |
| download | emacs-e93db24a10c839126b817ad60baceb2a3335f453.tar.gz emacs-e93db24a10c839126b817ad60baceb2a3335f453.zip | |
Add support for block and critical blocks to f90.el.
* lisp/progmodes/f90.el (f90-critical-indent): New option.
(f90-font-lock-keywords-2, f90-blocks-re, f90-end-block-re)
(f90-start-block-re, f90-mode-abbrev-table): Add block, critical.
(f90-mode): Doc fix.
(f90-looking-at-critical, f90-looking-at-end-critical): New funcs.
(f90-no-block-limit, f90-calculate-indent, f90-end-of-block)
(f90-beginning-of-block, f90-next-block, f90-indent-region)
(f90-match-end): Handle block, critical.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/ChangeLog | 11 | ||||
| -rw-r--r-- | lisp/progmodes/f90.el | 69 |
2 files changed, 74 insertions, 6 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 7d59a148873..5c65ed8cd13 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,14 @@ | |||
| 1 | 2011-06-26 Glenn Morris <rgm@gnu.org> | ||
| 2 | |||
| 3 | * progmodes/f90.el (f90-critical-indent): New option. | ||
| 4 | (f90-font-lock-keywords-2, f90-blocks-re, f90-end-block-re) | ||
| 5 | (f90-start-block-re, f90-mode-abbrev-table): Add block, critical. | ||
| 6 | (f90-mode): Doc fix. | ||
| 7 | (f90-looking-at-critical, f90-looking-at-end-critical): New funcs. | ||
| 8 | (f90-no-block-limit, f90-calculate-indent, f90-end-of-block) | ||
| 9 | (f90-beginning-of-block, f90-next-block, f90-indent-region) | ||
| 10 | (f90-match-end): Handle block, critical. | ||
| 11 | |||
| 1 | 2011-06-25 Glenn Morris <rgm@gnu.org> | 12 | 2011-06-25 Glenn Morris <rgm@gnu.org> |
| 2 | 13 | ||
| 3 | * calendar/diary-lib.el (diary-included-files): Doc fix. | 14 | * calendar/diary-lib.el (diary-included-files): Doc fix. |
diff --git a/lisp/progmodes/f90.el b/lisp/progmodes/f90.el index 463af61dcf5..db292c2452b 100644 --- a/lisp/progmodes/f90.el +++ b/lisp/progmodes/f90.el | |||
| @@ -208,6 +208,13 @@ | |||
| 208 | :group 'f90-indent | 208 | :group 'f90-indent |
| 209 | :version "23.1") | 209 | :version "23.1") |
| 210 | 210 | ||
| 211 | (defcustom f90-critical-indent 2 | ||
| 212 | "Extra indentation applied to BLOCK, CRITICAL blocks." | ||
| 213 | :type 'integer | ||
| 214 | :safe 'integerp | ||
| 215 | :group 'f90-indent | ||
| 216 | :version "24.1") | ||
| 217 | |||
| 211 | (defcustom f90-continuation-indent 5 | 218 | (defcustom f90-continuation-indent 5 |
| 212 | "Extra indentation applied to continuation lines." | 219 | "Extra indentation applied to continuation lines." |
| 213 | :type 'integer | 220 | :type 'integer |
| @@ -589,12 +596,16 @@ logical\\|double[ \t]*precision\\|\ | |||
| 589 | ;; enum (F2003; must be followed by ", bind(C)"). | 596 | ;; enum (F2003; must be followed by ", bind(C)"). |
| 590 | '("\\<\\(enum\\)[ \t]*," (1 font-lock-keyword-face)) | 597 | '("\\<\\(enum\\)[ \t]*," (1 font-lock-keyword-face)) |
| 591 | ;; end do, enum (F2003), if, select, where, and forall constructs. | 598 | ;; end do, enum (F2003), if, select, where, and forall constructs. |
| 592 | '("\\<\\(end[ \t]*\\(do\\|if\\|enum\\|select\\|forall\\|where\\)\\)\\>\ | 599 | ;; block, critical (F2008). |
| 600 | ;; Note that "block data" may get somewhat mixed up with F2008 blocks, | ||
| 601 | ;; but since the former is obsolete I'm not going to worry about it. | ||
| 602 | '("\\<\\(end[ \t]*\\(do\\|if\\|enum\\|select\\|forall\\|where\\|\ | ||
| 603 | block\\|critical\\)\\)\\>\ | ||
| 593 | \\([ \t]+\\(\\sw+\\)\\)?" | 604 | \\([ \t]+\\(\\sw+\\)\\)?" |
| 594 | (1 font-lock-keyword-face) (3 font-lock-constant-face nil t)) | 605 | (1 font-lock-keyword-face) (3 font-lock-constant-face nil t)) |
| 595 | '("^[ \t0-9]*\\(\\(\\sw+\\)[ \t]*:[ \t]*\\)?\\(\\(if\\|\ | 606 | '("^[ \t0-9]*\\(\\(\\sw+\\)[ \t]*:[ \t]*\\)?\\(\\(if\\|\ |
| 596 | do\\([ \t]*while\\)?\\|select[ \t]*\\(?:case\\|type\\)\\|where\\|\ | 607 | do\\([ \t]*while\\)?\\|select[ \t]*\\(?:case\\|type\\)\\|where\\|\ |
| 597 | forall\\)\\)\\>" | 608 | forall\\|block\\|critical\\)\\)\\>" |
| 598 | (2 font-lock-constant-face nil t) (3 font-lock-keyword-face)) | 609 | (2 font-lock-constant-face nil t) (3 font-lock-keyword-face)) |
| 599 | ;; Implicit declaration. | 610 | ;; Implicit declaration. |
| 600 | '("\\<\\(implicit\\)[ \t]*\\(real\\|integer\\|c\\(haracter\\|omplex\\)\ | 611 | '("\\<\\(implicit\\)[ \t]*\\(real\\|integer\\|c\\(haracter\\|omplex\\)\ |
| @@ -810,7 +821,7 @@ Can be overridden by the value of `font-lock-maximum-decoration'.") | |||
| 810 | ;; F2003. | 821 | ;; F2003. |
| 811 | "enum" "associate" | 822 | "enum" "associate" |
| 812 | ;; F2008. | 823 | ;; F2008. |
| 813 | "submodule")) | 824 | "submodule" "block" "critical")) |
| 814 | "\\)\\>") | 825 | "\\)\\>") |
| 815 | "Regexp potentially indicating a \"block\" of F90 code.") | 826 | "Regexp potentially indicating a \"block\" of F90 code.") |
| 816 | 827 | ||
| @@ -873,7 +884,8 @@ allowed. This minor issue currently only affects \"(/\" and \"/)\".") | |||
| 873 | (concat "^[ \t0-9]*\\<end[ \t]*" | 884 | (concat "^[ \t0-9]*\\<end[ \t]*" |
| 874 | (regexp-opt '("do" "if" "forall" "function" "interface" | 885 | (regexp-opt '("do" "if" "forall" "function" "interface" |
| 875 | "module" "program" "select" "subroutine" | 886 | "module" "program" "select" "subroutine" |
| 876 | "type" "where" "enum" "associate" "submodule") t) | 887 | "type" "where" "enum" "associate" "submodule" |
| 888 | "block" "critical") t) | ||
| 877 | "\\>") | 889 | "\\>") |
| 878 | "Regexp matching the end of an F90 \"block\", from the line start. | 890 | "Regexp matching the end of an F90 \"block\", from the line start. |
| 879 | Used in the F90 entry in `hs-special-modes-alist'.") | 891 | Used in the F90 entry in `hs-special-modes-alist'.") |
| @@ -902,7 +914,7 @@ Used in the F90 entry in `hs-special-modes-alist'.") | |||
| 902 | ;; "abstract interface" is F2003; "submodule" is F2008. | 914 | ;; "abstract interface" is F2003; "submodule" is F2008. |
| 903 | "program\\|\\(?:abstract[ \t]*\\)?interface\\|\\(?:sub\\)?module\\|" | 915 | "program\\|\\(?:abstract[ \t]*\\)?interface\\|\\(?:sub\\)?module\\|" |
| 904 | ;; "enum", but not "enumerator". | 916 | ;; "enum", but not "enumerator". |
| 905 | "function\\|subroutine\\|enum[^e]\\|associate" | 917 | "function\\|subroutine\\|enum[^e]\\|associate\\|block\\|critical" |
| 906 | "\\)" | 918 | "\\)" |
| 907 | "[ \t]*") | 919 | "[ \t]*") |
| 908 | "Regexp matching the start of an F90 \"block\", from the line start. | 920 | "Regexp matching the start of an F90 \"block\", from the line start. |
| @@ -989,11 +1001,13 @@ Set subexpression 1 in the match-data to the name of the type." | |||
| 989 | ("`asy" . "asynchronous" ) | 1001 | ("`asy" . "asynchronous" ) |
| 990 | ("`ba" . "backspace" ) | 1002 | ("`ba" . "backspace" ) |
| 991 | ("`bd" . "block data" ) | 1003 | ("`bd" . "block data" ) |
| 1004 | ("`bl" . "block" ) | ||
| 992 | ("`c" . "character" ) | 1005 | ("`c" . "character" ) |
| 993 | ("`cl" . "close" ) | 1006 | ("`cl" . "close" ) |
| 994 | ("`cm" . "common" ) | 1007 | ("`cm" . "common" ) |
| 995 | ("`cx" . "complex" ) | 1008 | ("`cx" . "complex" ) |
| 996 | ("`cn" . "contains" ) | 1009 | ("`cn" . "contains" ) |
| 1010 | ("`cr" . "critical" ) | ||
| 997 | ("`cy" . "cycle" ) | 1011 | ("`cy" . "cycle" ) |
| 998 | ("`de" . "deallocate" ) | 1012 | ("`de" . "deallocate" ) |
| 999 | ("`df" . "define" ) | 1013 | ("`df" . "define" ) |
| @@ -1073,6 +1087,10 @@ Variables controlling indentation style and extra features: | |||
| 1073 | `f90-program-indent' | 1087 | `f90-program-indent' |
| 1074 | Extra indentation within program/module/subroutine/function blocks | 1088 | Extra indentation within program/module/subroutine/function blocks |
| 1075 | (default 2). | 1089 | (default 2). |
| 1090 | `f90-associate-indent' | ||
| 1091 | Extra indentation within associate blocks (default 2). | ||
| 1092 | `f90-critical-indent' | ||
| 1093 | Extra indentation within critical/block blocks (default 2). | ||
| 1076 | `f90-continuation-indent' | 1094 | `f90-continuation-indent' |
| 1077 | Extra indentation applied to continuation lines (default 5). | 1095 | Extra indentation applied to continuation lines (default 5). |
| 1078 | `f90-comment-region' | 1096 | `f90-comment-region' |
| @@ -1243,6 +1261,25 @@ NAME is nil if the statement has no label." | |||
| 1243 | (if (looking-at "\\<\\(associate\\)[ \t]*(") | 1261 | (if (looking-at "\\<\\(associate\\)[ \t]*(") |
| 1244 | (list (match-string 1)))) | 1262 | (list (match-string 1)))) |
| 1245 | 1263 | ||
| 1264 | (defsubst f90-looking-at-critical () | ||
| 1265 | "Return (KIND) if a critical or block block starts after point." | ||
| 1266 | (if (looking-at "\\(\\(\\sw+\\)[ \t]*:\\)?[ \t]*\\(critical\\|block\\)\\>") | ||
| 1267 | (let ((struct (match-string 3)) | ||
| 1268 | (label (match-string 2))) | ||
| 1269 | (if (or (not (string-equal "block" struct)) | ||
| 1270 | (save-excursion | ||
| 1271 | (skip-chars-forward " \t") | ||
| 1272 | (not (looking-at "data\\>")))) | ||
| 1273 | (list struct label))))) | ||
| 1274 | |||
| 1275 | (defsubst f90-looking-at-end-critical () | ||
| 1276 | "Return non-nil if a critical or block block ends after point." | ||
| 1277 | (if (looking-at "end[ \t]*\\(critical\\|block\\)\\>") | ||
| 1278 | (or (not (string-equal "block" (match-string 1))) | ||
| 1279 | (save-excursion | ||
| 1280 | (skip-chars-forward " \t") | ||
| 1281 | (not (looking-at "data\\>")))))) | ||
| 1282 | |||
| 1246 | (defsubst f90-looking-at-where-or-forall () | 1283 | (defsubst f90-looking-at-where-or-forall () |
| 1247 | "Return (KIND NAME) if a where or forall block starts after point. | 1284 | "Return (KIND NAME) if a where or forall block starts after point. |
| 1248 | NAME is nil if the statement has no label." | 1285 | NAME is nil if the statement has no label." |
| @@ -1369,7 +1406,8 @@ if all else fails." | |||
| 1369 | (save-excursion | 1406 | (save-excursion |
| 1370 | (not (or (looking-at "end") | 1407 | (not (or (looking-at "end") |
| 1371 | (looking-at "\\(do\\|if\\|else\\(if\\|where\\)?\ | 1408 | (looking-at "\\(do\\|if\\|else\\(if\\|where\\)?\ |
| 1372 | \\|select[ \t]*\\(case\\|type\\)\\|case\\|where\\|forall\\)\\>") | 1409 | \\|select[ \t]*\\(case\\|type\\)\\|case\\|where\\|forall\\|\ |
| 1410 | block\\|critical\\)\\>") | ||
| 1373 | (looking-at "\\(program\\|\\(?:sub\\)?module\\|\ | 1411 | (looking-at "\\(program\\|\\(?:sub\\)?module\\|\ |
| 1374 | \\(?:abstract[ \t]*\\)?interface\\|block[ \t]*data\\)\\>") | 1412 | \\(?:abstract[ \t]*\\)?interface\\|block[ \t]*data\\)\\>") |
| 1375 | (looking-at "\\(contains\\|\\sw+[ \t]*:\\)") | 1413 | (looking-at "\\(contains\\|\\sw+[ \t]*:\\)") |
| @@ -1413,6 +1451,8 @@ Does not check type and subprogram indentation." | |||
| 1413 | (f90-looking-at-where-or-forall) | 1451 | (f90-looking-at-where-or-forall) |
| 1414 | (f90-looking-at-select-case)) | 1452 | (f90-looking-at-select-case)) |
| 1415 | (setq icol (+ icol f90-if-indent))) | 1453 | (setq icol (+ icol f90-if-indent))) |
| 1454 | ;; FIXME this makes no sense, because this section/function is | ||
| 1455 | ;; only for if/do/select/where/forall ? | ||
| 1416 | ((f90-looking-at-associate) | 1456 | ((f90-looking-at-associate) |
| 1417 | (setq icol (+ icol f90-associate-indent)))) | 1457 | (setq icol (+ icol f90-associate-indent)))) |
| 1418 | (end-of-line)) | 1458 | (end-of-line)) |
| @@ -1426,12 +1466,16 @@ Does not check type and subprogram indentation." | |||
| 1426 | (f90-looking-at-where-or-forall) | 1466 | (f90-looking-at-where-or-forall) |
| 1427 | (f90-looking-at-select-case)) | 1467 | (f90-looking-at-select-case)) |
| 1428 | (setq icol (+ icol f90-if-indent))) | 1468 | (setq icol (+ icol f90-if-indent))) |
| 1469 | ;; FIXME this makes no sense, because this section/function is | ||
| 1470 | ;; only for if/do/select/where/forall ? | ||
| 1429 | ((f90-looking-at-associate) | 1471 | ((f90-looking-at-associate) |
| 1430 | (setq icol (+ icol f90-associate-indent))) | 1472 | (setq icol (+ icol f90-associate-indent))) |
| 1431 | ((looking-at f90-end-if-re) | 1473 | ((looking-at f90-end-if-re) |
| 1432 | (setq icol (- icol f90-if-indent))) | 1474 | (setq icol (- icol f90-if-indent))) |
| 1433 | ((looking-at f90-end-associate-re) | 1475 | ((looking-at f90-end-associate-re) |
| 1434 | (setq icol (- icol f90-associate-indent))) | 1476 | (setq icol (- icol f90-associate-indent))) |
| 1477 | ((f90-looking-at-end-critical) | ||
| 1478 | (setq icol (- icol f90-critical-indent))) | ||
| 1435 | ((looking-at "end[ \t]*do\\>") | 1479 | ((looking-at "end[ \t]*do\\>") |
| 1436 | (setq icol (- icol f90-do-indent)))) | 1480 | (setq icol (- icol f90-do-indent)))) |
| 1437 | (end-of-line)) | 1481 | (end-of-line)) |
| @@ -1479,6 +1523,8 @@ Does not check type and subprogram indentation." | |||
| 1479 | (setq icol (+ icol f90-type-indent))) | 1523 | (setq icol (+ icol f90-type-indent))) |
| 1480 | ((f90-looking-at-associate) | 1524 | ((f90-looking-at-associate) |
| 1481 | (setq icol (+ icol f90-associate-indent))) | 1525 | (setq icol (+ icol f90-associate-indent))) |
| 1526 | ((f90-looking-at-critical) | ||
| 1527 | (setq icol (+ icol f90-critical-indent))) | ||
| 1482 | ((or (f90-looking-at-program-block-start) | 1528 | ((or (f90-looking-at-program-block-start) |
| 1483 | (looking-at "contains[ \t]*\\($\\|!\\)")) | 1529 | (looking-at "contains[ \t]*\\($\\|!\\)")) |
| 1484 | (setq icol (+ icol f90-program-indent))))) | 1530 | (setq icol (+ icol f90-program-indent))))) |
| @@ -1498,6 +1544,8 @@ Does not check type and subprogram indentation." | |||
| 1498 | (setq icol (- icol f90-type-indent))) | 1544 | (setq icol (- icol f90-type-indent))) |
| 1499 | ((looking-at f90-end-associate-re) | 1545 | ((looking-at f90-end-associate-re) |
| 1500 | (setq icol (- icol f90-associate-indent))) | 1546 | (setq icol (- icol f90-associate-indent))) |
| 1547 | ((f90-looking-at-end-critical) | ||
| 1548 | (setq icol (- icol f90-critical-indent))) | ||
| 1501 | ((or (looking-at "contains[ \t]*\\(!\\|$\\)") | 1549 | ((or (looking-at "contains[ \t]*\\(!\\|$\\)") |
| 1502 | (f90-looking-at-program-block-end)) | 1550 | (f90-looking-at-program-block-end)) |
| 1503 | (setq icol (- icol f90-program-indent)))))))))) | 1551 | (setq icol (- icol f90-program-indent)))))))))) |
| @@ -1604,6 +1652,7 @@ Interactively, pushes mark before moving point." | |||
| 1604 | (f90-looking-at-select-case) | 1652 | (f90-looking-at-select-case) |
| 1605 | (f90-looking-at-type-like) | 1653 | (f90-looking-at-type-like) |
| 1606 | (f90-looking-at-associate) | 1654 | (f90-looking-at-associate) |
| 1655 | (f90-looking-at-critical) | ||
| 1607 | (f90-looking-at-program-block-start) | 1656 | (f90-looking-at-program-block-start) |
| 1608 | (f90-looking-at-if-then) | 1657 | (f90-looking-at-if-then) |
| 1609 | (f90-looking-at-where-or-forall))) | 1658 | (f90-looking-at-where-or-forall))) |
| @@ -1665,6 +1714,7 @@ Interactively, pushes mark before moving point." | |||
| 1665 | (f90-looking-at-select-case) | 1714 | (f90-looking-at-select-case) |
| 1666 | (f90-looking-at-type-like) | 1715 | (f90-looking-at-type-like) |
| 1667 | (f90-looking-at-associate) | 1716 | (f90-looking-at-associate) |
| 1717 | (f90-looking-at-critical) | ||
| 1668 | (f90-looking-at-program-block-start) | 1718 | (f90-looking-at-program-block-start) |
| 1669 | (f90-looking-at-if-then) | 1719 | (f90-looking-at-if-then) |
| 1670 | (f90-looking-at-where-or-forall))) | 1720 | (f90-looking-at-where-or-forall))) |
| @@ -1706,6 +1756,7 @@ A block is a subroutine, if-endif, etc." | |||
| 1706 | (f90-looking-at-select-case) | 1756 | (f90-looking-at-select-case) |
| 1707 | (f90-looking-at-type-like) | 1757 | (f90-looking-at-type-like) |
| 1708 | (f90-looking-at-associate) | 1758 | (f90-looking-at-associate) |
| 1759 | (f90-looking-at-critical) | ||
| 1709 | (f90-looking-at-program-block-start) | 1760 | (f90-looking-at-program-block-start) |
| 1710 | (f90-looking-at-if-then) | 1761 | (f90-looking-at-if-then) |
| 1711 | (f90-looking-at-where-or-forall)) | 1762 | (f90-looking-at-where-or-forall)) |
| @@ -1842,6 +1893,8 @@ If run in the middle of a line, the line is not broken." | |||
| 1842 | f90-type-indent) | 1893 | f90-type-indent) |
| 1843 | ((setq struct (f90-looking-at-associate)) | 1894 | ((setq struct (f90-looking-at-associate)) |
| 1844 | f90-associate-indent) | 1895 | f90-associate-indent) |
| 1896 | ((setq struct (f90-looking-at-critical)) | ||
| 1897 | f90-critical-indent) | ||
| 1845 | ((or (setq struct (f90-looking-at-program-block-start)) | 1898 | ((or (setq struct (f90-looking-at-program-block-start)) |
| 1846 | (looking-at "contains[ \t]*\\($\\|!\\)")) | 1899 | (looking-at "contains[ \t]*\\($\\|!\\)")) |
| 1847 | f90-program-indent))) | 1900 | f90-program-indent))) |
| @@ -1877,6 +1930,8 @@ If run in the middle of a line, the line is not broken." | |||
| 1877 | f90-type-indent) | 1930 | f90-type-indent) |
| 1878 | ((setq struct (f90-looking-at-associate)) | 1931 | ((setq struct (f90-looking-at-associate)) |
| 1879 | f90-associate-indent) | 1932 | f90-associate-indent) |
| 1933 | ((setq struct (f90-looking-at-critical)) | ||
| 1934 | f90-critical-indent) | ||
| 1880 | ((setq struct (f90-looking-at-program-block-start)) | 1935 | ((setq struct (f90-looking-at-program-block-start)) |
| 1881 | f90-program-indent))) | 1936 | f90-program-indent))) |
| 1882 | (setq ind-curr ind-lev) | 1937 | (setq ind-curr ind-lev) |
| @@ -1895,6 +1950,7 @@ If run in the middle of a line, the line is not broken." | |||
| 1895 | ((looking-at f90-end-type-re) f90-type-indent) | 1950 | ((looking-at f90-end-type-re) f90-type-indent) |
| 1896 | ((looking-at f90-end-associate-re) | 1951 | ((looking-at f90-end-associate-re) |
| 1897 | f90-associate-indent) | 1952 | f90-associate-indent) |
| 1953 | ((f90-looking-at-end-critical) f90-critical-indent) | ||
| 1898 | ((f90-looking-at-program-block-end) | 1954 | ((f90-looking-at-program-block-end) |
| 1899 | f90-program-indent))) | 1955 | f90-program-indent))) |
| 1900 | (if ind-b (setq ind-lev (- ind-lev ind-b))) | 1956 | (if ind-b (setq ind-lev (- ind-lev ind-b))) |
| @@ -2100,6 +2156,7 @@ Leave point at the end of line." | |||
| 2100 | (f90-looking-at-select-case) | 2156 | (f90-looking-at-select-case) |
| 2101 | (f90-looking-at-type-like) | 2157 | (f90-looking-at-type-like) |
| 2102 | (f90-looking-at-associate) | 2158 | (f90-looking-at-associate) |
| 2159 | (f90-looking-at-critical) | ||
| 2103 | (f90-looking-at-program-block-start) | 2160 | (f90-looking-at-program-block-start) |
| 2104 | ;; Interpret a single END without a block | 2161 | ;; Interpret a single END without a block |
| 2105 | ;; start to be the END of a program block | 2162 | ;; start to be the END of a program block |